I have been trying to following this http://msdn.microsoft.com/en-us/library/cc668202(v=vs.90).aspx
I have created add this to my 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>
And, I have added this to my Global.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;
}
}
When I navigate to /FACTS/Attachments/Attachment_NoLogin.aspx
it works; but, when I try to navigate to my custom route /a
, it says, "HTTP Error 404.0 - Not Found."
How can I make my custom route work?
Thank you for your help.
Edit:
I am using .NET 3.5, on IIS 7.5, if that makes a difference (which I assume it does).
The solution I used was to just download and install the IIS Rewrite module. It was super easy, and super cool :)