• λ我爱Aspx >> Asp.Net >> 用好ASP.NET 2.0的URL映射
  • 用好ASP.NET 2.0的URL映射

  • :未知  Դ:internet  :2007-5-20 16:43:27  ؼ:.net,asp.net,asp
  • http://aspalliance.com/1 (article ID 1, which is my Excel Reports in ASP article).

    The nice thing about this is that it uses Context.RewritePath, so there is no Response.Redirect and the user never sees the actual URL of the page handling the request. The regex I'm using is here:

    http://regexlib.com/REDetails.aspx?regexp_id=456

    The actual code looks like this:

    string originalUrl = Request.Url.ToString();

    // Check for article shortcuts (e.g. http://aspalliance.com/1 )

    string newUrl = AspAlliance.Web.Core.HttpRedirect.GetRedirect(originalUrl);

    if(newUrl != originalUrl)

    {

    System.Uri myUri = new System.Uri(newUrl);

    Context.RewritePath(myUri.PathAndQuery);

    }

    // GetRedirect:

    System.Text.RegularExpressions.Regex regex =

    new System.Text.RegularExpressions.Regex(@"\.com/(\d+)$",

    (System.Text.RegularExpressions.RegexOptions.Compiled |

    Ҷƪл˵?
  • һƪ试用TEMP版VS2005---下雪了
    һƪASP.NET 2.0 中收集的小功能点