Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2005
    Location
    NYC
    Posts
    49
    Thanks
    4
    Thanked 1 Time in 1 Post

    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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    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.
    I am the luckiest man in the world

  • Users who have thanked Roelf for this post:

    bermanbp (02-25-2008)

  • #3
    Regular Coder
    Join Date
    Jun 2008
    Location
    SE Wisconsin, US
    Posts
    222
    Thanks
    1
    Thanked 20 Times in 20 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •