gpt4 book ai didi

c# - ASP.NET Core .css 扩展转到 Controller

转载 作者:太空宇宙 更新时间:2023-11-03 19:39:03 25 4
gpt4 key购买 nike

我将我的 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?}");
});

最佳答案

听起来你没有 static files配置。如果您的路由开始发挥作用,那就是在应该提供静态文件之后。在您之前:

app.UseMvc ...

确保你有:

app.UseStaticFiles();

而且你的 css 文件夹在 wwwroot

关于c# - ASP.NET Core .css 扩展转到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56870855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com