RewritePath issues

Discussion in 'ASP .Net' started by Corey O'Mara, Feb 27, 2004.

  1. Corey O'Mara

    Corey O'Mara Guest

    Hello all,

    I'd like to have personalized URL's in my application. For example,
    http://mydomain.com/sites/page.aspx should be accessible via
    http://mydomain.com/sites/username/page.aspx. I'd like to parse the URL and
    grab the username so I can deliver the appropriate content on the page. This
    seems to be accomplished by the HttpContext.RewritePath method. I've read
    that ASP.NET uses it to strip out the SessionID when cookieless sessions are
    turned on.

    Unfortunately, the RewritePath method seems to only affect the filename
    portion of the URL. For example, I can strip out the username and append it
    to the end of the URL in the form
    http://mydomain.com/sites/username/page.aspx?Parameter1=username, but the
    username still remains in the URL, resulting in a 404 error.

    Any insight is much appreciated.
     
    Corey O'Mara, Feb 27, 2004
    #1
    1. Advertisements

  2. Corey O'Mara

    matt Guest

    You should be able to do exactly what you are aiming to achieve using
    rewritepath, we use this method in our cms with no such issues. Please post
    the code used to perform the rewritepath, and I'll have a look.

    Matt
    http://www.3internet.co.uk
     
    matt, Feb 27, 2004
    #2
    1. Advertisements

  3. Corey O'Mara

    Corey O'Mara Guest

    Hello Matt,

    What I'm seeing is that it's not the code itself, but rather the location
    of the code.

    In my development environment (WinXP laptop), I'm using localhost/appname.
    Underneath that dir is the sites subdir with the appropriate aspx files
    inside.

    here's the request: http://localhost/appname/sites/username/page.aspx
    here's the rewrite:
    http://localhost/appname/sites/page.aspx?username=username

    If I put the code in the global.asax in the localhost/appname dir, I can
    only rewrite the path up to the aspx file itself. However, if I place the
    code in the root of the website (default web site, c:\inetpub\wwwroot), it
    will intercept the request before ir gets to the app so I have complete
    control over the whole path. I'm stripping out the username and redirecting
    to "localhost/appname/sites/page.aspx?username=username"

    Unfortunately, this severly affects Forms Autneication. I want to have a
    web.config file in the root of the app, but I get an error that it's invalid
    to have a declartion beyond "machine to application." It's the one that
    signifies that the virtual directory is not setup as an application in IIS.
    Never mind the fact that it is configured as an application, I think I can
    make things work if I put the web.config in the root of the server, just
    like the global.asax.

    I've gotten the redirection to work, but now I'm getting "Could not load
    type" errors on the pages I'm redirecting to.

    Part of my problem (I think) is the folder structure. Is there a way to
    point VS.NET to the root of the webserver rather than using a subdir?
     
    Corey O'Mara, Mar 1, 2004
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.