Created
April 26, 2010 15:19
-
-
Save JeremySkinner/379459 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //global.asax | |
| RouteTable.Routes.Add("ProductsRoute", new Route | |
| ( | |
| "products/apparel", | |
| new CustomRouteHandler("~/Products/ProductsByCategory.aspx", | |
| "category=18") | |
| )); | |
| //CustomRouteHandler.cs | |
| public class CustomRouteHandler : IRouteHandler | |
| { | |
| public CustomRouteHandler(string virtualPath, string queryString) | |
| { | |
| this.VirtualPath = virtualPath; | |
| this.QueryString = queryString; | |
| } | |
| public string VirtualPath { get; private set; } | |
| public string QueryString { get; private set; } | |
| public IHttpHandler GetHttpHandler(RequestContext |#A | |
| requestContext) |#A | |
| { | |
| requestContext.HttpContext.RewritePath( | |
| String.Format("{0}?{1}", VirtualPath, QueryString)); | |
| var page = BuildManager.CreateInstanceFromVirtualPath | |
| (VirtualPath, typeof(Page)) as IHttpHandler; | |
| return page; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment