ASP.NET CORE .CSS扩展名为控制器



i将我的ASP.NET应用程序迁移到ASP.NET Core。

http://localhost:56623/js/jquery.js

工作正常,但是

http://localhost:56623/css/bootstrap.css

致电我的类别Controller的CheckIscustompage操作,因此我的应用程序当然会提出例外。

我该怎么办?

app.UseMvc(routes =>
{
    routes.MapRoute(
        name: "Category",
        template: "{sefLink}/{pageNumber}",
        defaults: new { controller = "Category", action = "CheckIsCustomPage", pageNumber = "1" }
    );
    routes.MapRoute(
        name: "Ajax",
        template: "ajax/{action}",
        defaults: new { controller = "Ajax" });
    routes.MapRoute(
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");
});

听起来好像您没有配置静态文件。如果您的路由正在发挥作用,那是应提供静态文件的点。在您之前:

app.UseMvc ...

确保您有:

app.UseStaticFiles();

并且您的css文件夹在wwwroot

最新更新