开发者

Routing on IIS6 With Decimal In Route

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 r开发者_运维技巧oute 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜