2013-03-08 172 views
0
不工作

我一直在試圖跟隨這http://msdn.microsoft.com/en-us/library/cc668202(v=vs.90).aspx自定義路由在ASP.NET

我創造了這個添加到我的web.config:

<modules> 
     <remove name="ScriptModule"/> 
     <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> 
     <remove name="UrlRoutingModule" /> 
     <add name="UrlRoutingModule" 
      type="System.Web.Routing.UrlRoutingModule, 
       System.Web.Routing, 
       Version=3.5.0.0, 
       Culture=neutral, 
       PublicKeyToken=31BF3856AD364E35"/> 
    </modules> 

而且,我已經加入這個全球我.asax:

protected void Application_Start(Object sender, EventArgs e) 
     { 
      SplendidInit.InitApp(); 
      RegisterRoutes(RouteTable.Routes); 
     } 

public static void RegisterRoutes(RouteCollection routes) 
     { 
      routes.Add("ShortUrl_Attachment_NoLogin", new Route 
      (
       "a", 
       new CustomRouteHandler("~/FACTS/Attachments/Attachment_NoLogin.aspx") 
      )); 
     } 

     public class CustomRouteHandler : IRouteHandler 
     { 
      public CustomRouteHandler(string virtualPath) 
      { 
       this.VirtualPath = virtualPath; 
      } 

      public string VirtualPath { get; private set; } 

      public IHttpHandler GetHttpHandler(RequestContext 
        requestContext) 
      { 
       var page = BuildManager.CreateInstanceFromVirtualPath 
        (VirtualPath, typeof(Page)) as IHttpHandler; 
       return page; 
      } 
     } 

當我導航到/FACTS/Attachments/Attachment_NoLogin.aspx它的工作原理;但是,當我嘗試導航到我的自定義路由/a時,它說:「HTTP錯誤404.0 - 未找到」。

我怎樣才能讓我的自定義路線的工作?

謝謝你的幫助。

編輯:

我使用.NET 3.5,在IIS 7.5中,如果有差別(我假設它)。

回答