2010-06-14 24 views
0

我必須在iis6上託管我的項目,我無法更改服務器上的iis設置。 因此,我修改了像下面這樣的global.asax。iis6上的mvc2主機:傳入的請求不匹配任何路由

如果我添加一個default.aspx並瀏覽項目,我得到如下錯誤:傳入的請求不匹配任何路由。

,如果我不添加默認的aspx我HTTP錯誤403.14

有什麼想法? 感謝

public static void RegisterRoutes(RouteCollection routes) 
     { 
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 


      routes.MapRoute("Default", // Route name 
        "{controller}.aspx/{action}/{id}", 
        new { controller = "Home", action = "Index", id = "" } // Parameter defaults) 
       ); 
      routes.MapRoute("Detail", // Route name 
        "{controller}.aspx/{action}/{id}/{sid}", 
        new { controller = "Home", action = "Index", id = "", sid="" } // Parameter defaults) 
        ); 
      routes.MapRoute("ForGoogle", // Route name 
        "{controller}.aspx/{action}/{friendlyUrl}/{id}/{partialName}", 
        new { controller = "Home", action = "Index", friendlyUrl = "", id = "", partialName =""} // Parameter defaults) 
        ); 
      routes.MapRoute(
        "PostFeed", 
        "Feed/{type}", 
        new { controller = "Product", action = "PostFeed", type = "rss" } 
       ); 

     } 

回答

1

添加index.htm文件,該文件重定向到正確的頁面。這有一個好處:它不需要啓動webapp,因此可以在webapp第一次啓動時顯示圖像或文本。

看上jQuery的 「載入中...」 - 頁我在一些項目中使用:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title>(loading...)</title> 

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 

    <script type="text/javascript"> 
    $(document).ready(function() { 
    $.ajax({ type: 'GET', url: 'Home.aspx', success: function() { location.href = 'Home.aspx'; } }); 
    }); 
    </script> 

</head> 
<body> 
<div id="loading"> 
    (show "loading..." text here) 
</div> 
</body> 
</html> 
相關問題