URL Rewritting and manipulation

asp.net , css , db Thrissūr, India
  • 13 years ago

    Hi all,

    I have two problems all related to URL manipulation.

    1. I am in the process of creating a network marketing website using ASP.NET 2.0. When user signs up, I want him to have his own replicated website. So at the moment each user get his "own replicated" website and the URL is www.mysite.com/default.aspx?id=username, that works fine however it is a bit ugly and would be hard to remember for an ordinary user. So I want them to give an URL in the form www.mysite.com/username , which would be easy to remember. A lot of websites do that. I have tried using <urlMapping> in web.config like that

    <urlMappings enabled="true">
          <add url="~/john" mappedUrl="~/Default.aspx?id=john"/>
    </urlMappings>

    It does work partially. It does redirect to that page, however there is a problem with my css styles. I have all my css files in App_Themes/DefaultTheme folder and in webconfig I set website Theme. However it doesn't seem to pick it up when I use urlMapping. I guess there is a problem with a virtual path. I have tried to explicitly set Theme in the Default.aspx by setting StylesheetTheme="DefaultTheme" and Theme="DefaultTheme", but that didn't help.

    So can anyone help, maybe there is a better solution, as with this one even if I get css working I would need to put dynamically a lot of entries into the web.config for mapping. I know there is a way with url rewritting using RegEx. But i didn't really get it. Please help.

    2. Second issue is that I want to hide page name. So I will have a link saying "Click Here", that redirects to www.mysite.asp/SignUp.aspx. However when it goes to that page, I don't want users to be able to see that page name in the address bar. But I dont want to hide or disable address bar. So when users click on the link "click here" it takes them to SignUp.aspx page but in the browser's address bar it should show www.mysite.com. I know there is a way with framesets, but I don't want to mess with framesets. So please, can anyone help. 

    Thanks a lot   

  • 13 years ago

    Hi,

    I have not used the URL mapping section before, i hear it has some powerful applications, just not had time to dig around with it.

    When i last had to re-map URLs i used the global.asax file to do the work on the begin request event.

    I used this to hide a database driven website from crawlers, so for example, you went to a link on the site called home.aspx, you are actually visiting index.aspx?page=home

    This is the command i used in the event: Context.RewritePath("index.aspx?page=" & strPage)

    Not sure if it will help, but it might open up some other avenues.

    Can't help on point two tho sorry.

    Si

  • 13 years ago

     

    hi there,
    There are several articles based on your requirements just checkout the given links.

    http://aspnet.4guysfromrolla.com/articles/011007-1.aspx

    http://www.codeproject.com/KB/aspnet/URLMapping.aspx
    http://www.codeproject.com/KB/aspnet/urlrewriter.aspx
    http://www.codeproject.com/KB/aspnet/Chameleon.aspx
    http://www.codeproject.com/KB/aspnet/Url_ReWritting_made_Easy.aspx
    http://msdn2.microsoft.com/en-us/library/ms972974.aspx
    http://www.isapirewrite.com/
    http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/

    Hope this will help you.
    Thanks & Regards
    DIlipv

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone” - Bjarne Stroustrup