2009-07-28 32 views
3

Ich änderte meine global.asax Routen wie folgt registrieren: Public Class MvcApplicationHosting asp.net MVC auf IIS6

Inherits System.Web.HttpApplication 

    Shared Sub RegisterRoutes(ByVal routes As RouteCollection) 

     routes.IgnoreRoute("{resource}.axd/{*pathInfo}") 

     ' MapRoute takes the following parameters, in order: 

     ' (1) Route name 

     ' (2) URL with parameters 

     ' (3) Parameter defaults 

     routes.MapRoute(_ 

      "Default", _ 

      "{controller}.aspx/{action}/{id}", _ 

      New With {.controller = "Home", .action = "Index", .id = ""} _ 

     ) 

     routes.MapRoute(_ 

      "Root", _ 

      "", _ 

      New With {.controller = "Home", .action = "Index", .id = ""} _ 

     ) 

    End Sub 

    Sub Application_Start() 

     RegisterRoutes(RouteTable.Routes) 

    End Sub 

End Class 

alles funktioniert gut, aber die Wurzelpfad (www.mysite.com) nicht Arbeit und ich bekomme einen Fehler wie: "Die Website lehnte ab, um diese Webseite HTTP 403 zu zeigen"

Wie kann ich das loswerden ??

Antwort

3

Wenn Sie eine Default.aspx-Seite mit dem folgenden Page_Load-Code hinzufügen, wird es funktionieren:

 public void Page_Load(object sender, System.EventArgs e) 
     { 
      // Change the current path so that the Routing handler can correctly interpret 
      // the request, then restore the original path so that the OutputCache module 
      // can correctly process the response (if caching is enabled). 

      string originalPath = Request.Path; 
      HttpContext.Current.RewritePath(Request.ApplicationPath, false); 
      IHttpHandler httpHandler = new MvcHttpHandler(); 
      httpHandler.ProcessRequest(HttpContext.Current); 
      HttpContext.Current.RewritePath(originalPath, false); 
     } 
3

Obwohl die Lösung von Nebakanerer für den Stamm der Site funktioniert, ist es nicht für Urls funktioniert das schlug Unterordner vor.

Also stattdessen habe ich nicht für die Dateioption Default.aspx aber alle Wildcards in IIS6-basierte Website zu aspnet_isapi.dll zugeordnet. Grundsätzlich macht ASP.NET alle Anfragen unabhängig.

Dieser Blog-Eintrag erläutert den Prozess: [http://weblogs.asp.net/scottgu/archive/2007/03/04/tip-trick-integrating-asp-net-security-with-classic-asp-and-non-asp-net-urls.aspx][1]