KBD

Keith Devens .com

Thursday, March 18, 2010 Flag waving
I'm afraid of happy people. They're chemically unbalanced. – Shirley Manson

Archive: April 17, 2006

← April 14, 2006April 18, 2006 →

Daily link icon Monday, April 17, 2006

  1. Coding Horror: XP Automatic Update Nagging. I set "Re-prompt for restart with scheduled installations" to 720 minutes (12 hours).

       (0) Tags: [Windows]

How to do clean URIs in your ASP.NET application

It's actually very simple to do clean URIs in an ASP.NET application. In your Global.asax file:

string root = "/rootofyourapp";

void Application_Start(object sender, EventArgs e){
    Dictionary<string,string> mapping = new Dictionary<string,string>();
    mapping[root+"/page"]=root+"/page.aspx";
    Application.Add("mapping",mapping);
}

void Application_BeginRequest(object sender, EventArgs e){
    HttpContext context = HttpContext.Current;
    string path = context.Request.Path;
    Dictionary<string,string> mapping =
        (Dictionary<string,string>)Application["mapping"];
    
    if(mapping.ContainsKey(path)){
        context.RewritePath(mapping[path]);
    }else{
        Response.AddHeader("Content-type","text/plain;charset=UTF-8");
        Response.Write("Invalid request: "+path+"\n\n");
        Response.End();
    }
}

And to forward all requests through to a single URI:

void Application_BeginRequest(object sender, EventArgs e){
    HttpContext.Current.RewritePath("~/Default.aspx");
}
  1. MySpace does 1.5 billion page views per day using ASP.NET 2.0. They just switched from ColdFusion, a Java based technology, and their server load went down dramatically. Of course it's not surprising that switching from Java would make your app run faster, but what makes this so ironic is that they're still largely using ColdFusion, but using a .NET-based reimplementation called BlueDragon. So, a .NET-based reimplementation of ColdFusion runs dramatically faster than the original Java-based implementation.

       (2) Tags: [.NET, ColdFusion, Java]
← April 14, 2006April 18, 2006 →
March 2010
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
28293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 2 posts

Recent comments XML

I hate ASP.NET

I hate ASP... I was doing wonders​with PHP, then suddenly one of my​clients...

Johnies: Mar 17, 6:14am

Quantum physics and free will

I knew you were going to say that....

Tom Massey: Mar 15, 9:26pm

Generated in about 0.052s.

(Used 7 db queries)