views:

318

answers:

4

I've got a problem in that changing the way I'm doing Url Rewriting in an Asp.Net application has changed the IIS log files from looking like this:

/page/ 80 etc.. /page/anotherpage/ 80 etc...

to

default.aspx page=1 80 etc... default.aspx page=2 80 etc...

I'm a bit stumped as to how this happened. Is there a setting I'm missing (Win 2008, ASP.NET 2.0) The 'runAllManagedRequests' setting in the has also been switched on.

A: 

I don't know what method you are using to rewrite the URLs, but I know that with Apache (and ISAPI_Rewrite on Windows) you have to add a flag to each rule in the .htaccess file (or equivalent) to tell it to log the rewritten URL and not the original.

Mark B
That is interesting. The Url Rewriting is done with a .net http Module, not an ISAP dll. Perhaps there is an option in the url rewrite method to enable the original Url.
Bruce Chapman
A: 

As far as i am aware this will be by design as IIS only ever recives the rewritten URL not the orignal, as the rewritten url is sent to the .Net appliction and its the appliction that dose the converting.

TheAlbear
The original url rewriting logged the 'requested' url, and not the rewritten url. So there is a way to do it, I'm just not sure what.
Bruce Chapman
+1  A: 

Is the URL rewriting being done by a module? If it is, then it's possible the rewriting module is running before the logging module. You can change the order that modules run in IIS Manager. Go into Modules in IIS Manager and select View Ordered List...; then you can move modules up and down into the order you want.

Daniel Richardson
A: 

This question is a duplicate.

I've had exactly the same problem. One way around this is to use Server.Transfer instead of Context.RewritePath. Server.Transfer doesn't restart the entire page lifecycle so the original URL will still be logged. Be sure to pass "true" for the "preserveForm" parameter so that the QueryString and Form collections are available to the 2nd page.

David