Shortened URL

  • Thread starter Thread starter Shabam
  • Start date Start date
S

Shabam

I have an application and I'd like to shorten the url for some of the pages.
Instead of:
www.domain.com/page.aspx?key=12345

I'd like it to be like this:

www.domain.com/12345

Obviously this brings into this equation 2 issues.

#1. is the document being served. I believe it will automatically submit
the data to the default page (default.aspx in this case), so I just need to
rename the script to that. Am I right?

#2. is the variable. Since I'm no longer supplying the key, the application
will need to figure it out on its own. How best to handle this part?
 
You can do this with HTTP handlers.

You may want to shorten your url to www.domain.com/12345.xyz where .xyz is
whatever extension you want to use.

See the following articles:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;308001
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconhttphandlers.asp

You can also google on "ASP.NET HTTP Handler" and get dozens more hits.

Hope this helps.
--- Nick

Shabam said:
I have an application and I'd like to shorten the url for some of the pages.
Instead of:
www.domain.com/page.aspx?key=12345

I'd like it to be like this:

www.domain.com/12345

Obviously this brings into this equation 2 issues.

#1. is the document being served. I believe it will automatically submit
the data to the default page (default.aspx in this case), so I just need to
rename the script to that. Am I right?

no. That will not work. IIS will try to find a resource called "12345" in
your web site, and will fail when it doesn't find it.
 
Shabam said:
I have an application and I'd like to shorten the url for some of the
pages. Instead of:
www.domain.com/page.aspx?key=12345

I'd like it to be like this:

www.domain.com/12345

Obviously this brings into this equation 2 issues.

#1. is the document being served. I believe it will automatically
submit the data to the default page (default.aspx in this case), so I
just need to rename the script to that. Am I right?

#2. is the variable. Since I'm no longer supplying the key, the
application will need to figure it out on its own. How best to
handle this part?

This article on MSDN should get you started:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/urlrewriting.asp

Cheers,
 
Back
Top