Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-22-2008, 06:49 PM   PM User | #1
bermanbp
New Coder

 
Join Date: Dec 2005
Location: NYC
Posts: 49
Thanks: 4
Thanked 1 Time in 1 Post
bermanbp is an unknown quantity at this point
URL Rewrting in ASP.net 2.0 and/or IIS 6.0

Hello,

I have a page, custom.aspx, that accepts a parameter in the query string called 'id'. Depending on the ID, it will load the proper content for a custom donation page.

I need to be able to set one of these ID, e.g 999, to be the default page. So instead of going to website.com/donate/custom.aspx?id=999, I would like the end user to be able to navigate simply to website.com/donate and for it to display custom.aspx?id=999. I cannot simply do a forward as I never want the user to see the custom.aspx?id=999 for the default page. All the other non-default pages should be available through website.com/donate/custom.aspx?id=xxx.

I have not been able to figure how to do this and am not sure if this is something I should be tackling in IIS or in my ASP.net code-behind. Any pointers, examples, or help is greatly appreciated!

Thanks,
Brett
bermanbp is offline   Reply With Quote
Old 02-23-2008, 03:25 PM   PM User | #2
Roelf
Senior Coder

 
Join Date: Jun 2002
Location: Zwolle, The Netherlands
Posts: 1,110
Thanks: 2
Thanked 28 Times in 28 Posts
Roelf is on a distinguished road
what you can do in your custom.aspx code behind, is check if the id is present as a url parameter. If not, load/show the stuff from the database as if id=999 was present in the url. You also have to tell iis that custom.aspx is the default page for this subfolder of your website. Probably have to define it as a virtual directory and set the custom.aspx as the default in the documents tab.
Roelf is offline   Reply With Quote
Users who have thanked Roelf for this post:
bermanbp (02-25-2008)
Old 01-27-2009, 04:03 AM   PM User | #3
demtron
Regular Coder

 
Join Date: Jun 2008
Location: SE Wisconsin, US
Posts: 222
Thanks: 1
Thanked 20 Times in 20 Posts
demtron is on a distinguished road
One way to accomplish rewriting it to create a handler to parse the url, determine what the target path will be, then call HttpContext.ReWrite() with the new path. Hope that helps.
__________________
Milwaukee Web Designer and SEO Milwaukee Firm specializing in ASP.Net, C#, VB.Net, SQL Server and Access.
demtron is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:06 PM.


Advertisement
Log in to turn off these ads.