我的 MVC3 项目中有一条路线,当通过调试器和 IIS7 运行时,该路线在本地运行得非常好。但是,我们的服务器是 IIS6,当我将应用程序移出时,我收到“找不到页面”错误。我的猜测是这与路线中的小数有关。
所以我尝试实现一个 RouteHandler ,它似乎被调用但无法正常工作,因为该值在路由中没有被覆盖?
无论如何,这是我的路线:
var route = context.MapRoute(
"Management_version",
"Management/Version/{versionNumber}/{action}",
new { area = "Management", controller = "Version", action = "View" },
new[] { "FRSDashboard.Web.Areas.Management.Controllers" }
);
route.RouteHandler = new HyphenatedRouteHandler();
和我的路线处理程序:
public class HyphenatedRouteHandler : MvcRouteHandler
{
protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
{
var versionNumberContext = requestContext.RouteData.Values["versionNumber"];
requestContext.RouteData.DataTokens["versionNumber"] = versionNumberContext.ToString().Replace(".", "-");
return base.GetHttpHandler(requestContext);
}
}
基本上,我试图用连字符替换小数点来解决这个问题。任何建议将不胜感激。
所以事实证明,除了应用程序扩展通配符之外,我还需要为“aspnet_isapi.dll”设置通配符应用程序映射。两个通配符都必须取消选中“验证文件存在”选项。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)