我在ASP.NET Core 3.1应用程序中使用Captcha,验证码库生成 ashx 文件以独立显示图像。
我必须为此定义特殊的路由,因为我的主项目包含SPA项目(现有的ClientApp文件夹),并且当对此路由“ http://localhost:5000/captcha.ashx”执行请求时,此路由将被忽略并导航到angular项目中的已定义路由,然后最终显示404。
如何定义此路线?
在我的启动文件中
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapControllerRoute(
name: "default",pattern: "{controller}/{action=Index}/{id?}");
endpoints.MapAreaControllerRoute(
name: "areas","areas",pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapHub<NotificationHub>("/notification");
});
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start");
}
});