Routing on IIS6 With Decimal In Route

混江龙づ霸主 提交于 2019-12-20 03:13:01

问题


I have a route in my MVC3 project that works perfectly fine locally when run through the debugger and through IIS7. However, our servers are IIS6 and when I move my application out I am getting a "The page cannot be found" error. My guess is it has to do with the decimal in the route..

So I have tried implementing a RouteHandler which seems to be getting called but is not working correctly because the value isn't overwritten in the route?

Anyway, here is my route:

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();

and my route handler:

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);
    }
}

Basically, I am trying to replace the decimal point with a hyphen to work around the issue. Any suggestions would be greatly appreicated.


回答1:


So it turns out that I also needed to set a Wildcard application map for "aspnet_isapi.dll" in addition to the application extension wildcard. Both wildcards must have the "verify that file exists" option unchecked.



来源:https://stackoverflow.com/questions/7530827/routing-on-iis6-with-decimal-in-route

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!