相关疑难解决方法(0)

如何忽略asp.net中的路由表单url路由

我正在使用.NET 3.5 SP1框架,并在我的应用程序中实现了URL路由.我收到了javascript错误:

Error: ASP.NET Ajax client-side framework failed to load.
Resource interpreted as script but transferred with MIME type text/html.
ReferenceError: Can't find variable: Sys

我相信这是因为我的路由选择了微软的axd文件而没有正确发送javascript.我做了一些研究,发现我可以使用Routes.IgnoreRoute,这应该允许我忽略下面的axd:

Routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
Run Code Online (Sandbox Code Playgroud)

但是,当我将该行添加到我的Global.asax时,我收到此错误:

CS1061: 'System.Web.Routing.RouteCollection' does not contain a definition for 'IgnoreRoute' and no extension method 'IgnoreRoute' accepting a first argument of type 'System.Web.Routing.RouteCollection' could be found (are you missing a using directive or an assembly reference?)

我有System.Web.Routing导入的命名空间,任何想法?

c# asp.net url-routing ignoreroute axd

22
推荐指数
2
解决办法
2万
查看次数

ASP.NET MVC Routing - 为路由添加.html扩展名

我是MVC和路由的新手,我被要求修改应用程序以使用不同的URL.因为我没有经验,所以有点超过我的任务.

好吧,让我们谈一下代码:

routes.MapRoute(
"CategoryBySeName", // Route name
"products/{SeName}", // URL with parameters
new { controller = "Catalog", action = "CategoryBySeName" }
);
Run Code Online (Sandbox Code Playgroud)

这按预期工作,但客户端在路径的末尾想要".html",所以我改变了:

"products/{SeName}", // URL with parameters
Run Code Online (Sandbox Code Playgroud)

至:

"products/{SeName}.html", // URL with parameters
Run Code Online (Sandbox Code Playgroud)

失败(IIS 404页面 - MapRequestHandler)似乎iis正在尝试加载具有该名称的物理文件,而不是将其传递给应用程序.

类似:ASP.NET MVC路由从html页面开始(未回答,不重复)

c# asp.net-mvc-routing iis-7.5

16
推荐指数
2
解决办法
2万
查看次数