ASP.NET Core 3.1为ashx文件添加终结点

我在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");
       }
 });
sbsm_001 回答:ASP.NET Core 3.1为ashx文件添加终结点

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2921414.html

大家都在问