c# - 在 IIS6 上使用 Decimal In Route 进行路由

标签 c# .net asp.net-mvc asp.net-mvc-3 asp.net-routing

我的 MVC3 项目中有一个路由,当通过调试器和 IIS7 运行时,该路由在本地运行得非常好。但是,我们的服务器是 IIS6,当我将我的应用程序移出时,出现“找不到页面”错误。我的猜测是它与 route 的小数点有关..

所以我尝试实现一个 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”设置一个通配符应用程序映射。两个通配符都必须取消选中“验证文件是否存在”选项。

关于c# - 在 IIS6 上使用 Decimal In Route 进行路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7530827/

相关文章:

c# - 处理 Process.Start() 抛出的 Win32Exception

c# - 在 ASP.NET MVC 5 中填充 User.Identity

c# - System.Data.Entity.Infrastruct.UnintentionalCodeFirstException

javascript - jquery ui - 未定义不是对话框上的函数

c# - 使用 Linq 执行 SQL 函数

C# 互操作格式验证列表

.net - 在 C# 中验证 XSD,就好像它是 XML : doesn't give expected warnings

c# - 处理 WCF 服务应用程序上的数据库更改

c# - Entity Framework 底层提供者打开失败

c# - Web API 2/MVC 5 : Attribute Routing passing parameters as querystring to target different actions on same controller