Home > ASP.NET > Magic !! Access aspx page without aspx page

Magic !! Access aspx page without aspx page

Suppose you have a Users folder in your web application

there is Default.aspx page inside Users folder. if you access a page like http://yoursite.com/users/anyname.aspx will show error.

Using HTTP handler we can handle the request coming to any aspx page


1. Create a website in Visual studio

2. Create a folder as “users”

3. Create a an aspx page Default.aspx inside “users” folder

4. Right Button solution -> Add new item -> Class -> enter class name as Handler

Code inside this handler look like this

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;


///Summary description for Handler


public class Handler : IHttpHandler


public Handler()



// TODO: Add constructor logic here



public bool IsReusable


get { return false; }


public void ProcessRequest(HttpContext context)


string vPath = context.Request.RawUrl;

int vIndexOfFolder = vPath.IndexOf(“/users”,StringComparison.OrdinalIgnoreCase);

if (vIndexOfFolder > 0)


string vUserName = vPath.Substring(vIndexOfFolder + 7);

//remove aspx extension

vUserName = vUserName.Substring(0, vUserName.Length – 5);

context.Response.Write(“Welcome “+vUserName);




5. Edit web.config with handler settings


<add verb=”*” path=”users/*.aspx” type=”Handler”/>


Access http://yoursite.com/users/anyname.aspx  !!

you can check the name is available in database and go for further processing.

Categories: ASP.NET
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: