Author: bill.schriver | Posted on: 6/21/2008 1:13:57 PM | Views : 288

I am working on a social networking project which allows users to create "URLs" to get directly to their profile pages (just like myspace does). I am writing the redirection code in the global.asax file in the application_beginrequest code block.

I started off with some basic code to get the hang of redirecting the request.

void Application_BeginRequest(object sender, EventArgs e)
{
//Profile URL Check
if (string.Compare(this.Request.Url.AbsolutePath, "/bill", StringComparison.OrdinalIgnoreCase) == 0)
     {
     this.Response.Redirect("/profile_viewprofile.aspx?friendid=1", true);
     }
 }

Then it hit me. This method is fired for EVERY request including the css, any js files am using and of course all images. I also realized that I don't want to let people surf to folders like /images, /bin, etc. So I created a filter ...

Go to the complete details ...