2011-09-23 53 views
2

我有一個路徑在我的MVC3項目中,在通過調試器和IIS7運行時在本地完美地工作。但是,我們的服務器是IIS6,當我移動我的應用程序時,我收到「無法找到頁面」錯誤。我的猜測是它與路線中的小數有關..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); 
    } 
} 

基本上,我想用連字符替換小數點來解決這個問題。任何建議都會非常令人滿意。

+0

您是否禁用了文件存在檢查(在IIS本身中),並在IIS中將通配符(文件擴展名)映射配置爲asp.net? –

+0

我有文件擴展名映射與驗證文件存在未選中,但我添加了通配符應用程序映射到相同的文件,現在問題得到解決。 – shuniar

+1

真棒;對不起,我沒有發佈答案,但我無法確定你的設置。 –

回答

1

因此,事實證明,除了應用程序擴展通配符外,我還需要爲「aspnet_isapi.dll」設置通配符應用程序映射。兩個通配符都必須選中「驗證文件存在」選項。