RewritePath issues


Corey O'Mara

Hello all,

I'd like to have personalized URL's in my application. For example, should be accessible via 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, but the
username still remains in the URL, resulting in a 404 error.

Any insight is much appreciated.




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.




Corey O'Mara

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

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

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?