温馨提示:本文翻译自stackoverflow.com,查看原文请点击:c# - ASP.NET Core .css Extension Goes To Controller
asp.net-core asp.net-mvc c#

c# - ASP.NET Core .css扩展进入控制器

发布于 2020-03-27 10:16:33

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

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

工作正常,但

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

调用我的CategoryController的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?}");
});

查看更多

查看更多

提问者
Yargicx
被浏览
331
Owen Pauling 2019-07-03 21:12

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

app.UseMvc ...

确保您具有:

app.UseStaticFiles();

而且您的css文件夹在wwwroot