KBD

Keith Devens .com

Saturday, May 17, 2008 Flag waving
Sometimes a man with too broad a perspective reveals himself as having no real perspective at all. A man who... – Steven Den Beste

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 →
May 2008
SunMonTueWedThuFriSat
 123
45678910
11121314151617
18192021222324
25262728293031



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

new⇒Maps of Iraq

my husband is in Scania too..he​says it's not too bad..he's been at​worse...

Cristy: May 16, 3:54pm

"IMDB for music"

IMDB for Music? It looks to be a​couple of years old...​http://MusicTell.co...

Ken Empie: May 14, 9:57pm

Generated in about 0.049s.

(Used 7 db queries)