Click here to Skip to main content
15,892,965 members
Articles / Web Development / ASP.NET

URL rewriting using ASP.NET routing

Rate me:
Please Sign up or sign in to vote.
4.83/5 (23 votes)
7 Jul 2009CPOL2 min read 135.6K   6.4K   70  
MVC style search engine friendly URLs using ASP.NET routing, which comes as an enhancement in SP1 of ASP.NET 3.5.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using System.Web.Compilation;
using System.Web.UI;

/// <summary>
/// Summary description for RouteHandler
/// </summary>
public class RouteHandler : IRouteHandler
{
    public RouteHandler()
    {

    }
    public RouteHandler(string virtualPath)
    {
        _virtualPath = virtualPath;
    }

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

     string _virtualPath;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Apdynamics Inc
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions