Question

The general problem:

We have urls coming to our IIS web servers formatted like:

http://www.server.com/page.aspx

We are also seeing that urls like this are coming in:

http://www.server.com//page.aspx

We would like to get rid of that extra path character because when the user agent is Internet Explorer, this is resolving as 2 different pages, and thus, downloading the content twice when it should be resolved from a cache.

I am not sure if this is a problem to be solved with something like a url-rewriting module, or if there is a configuration setting.

Was it helpful?

Solution

I think the problem's with IE and not IIS.

Url Rewriting usually refers to the process of mapping a URL from http://example/shoes/clarkes to http://example/shoes.aspx?maker=clarkes on the server so that the browser doesn't know about it.

What you need to do is Redirect the browser from http://www.server.com//page.aspx to http://www.server.com/page.aspx using a 301 Http response code.

In theory:

As you seem to be using ASP.NET, the most transparent way to do this would be to write a HttpModule that checks for double slashes in the requested URI and does the redirect.

The easiest way to do it is to put some code in Global.ascx.(cs|vb) to check the requested URI on BeginRequest.

Either way, the code to do the checking would be the same.

In Practise:

It might be that IIS or ASP.NET swallows up the double "/" before you get the chance to see it. If it's IIS then you might have to use a proxy in front of IIS. If it's ASP.NET then you might be able to find an ISAPI Extension that will do the job for you.

Other Options

You could either

  • Split the page up so that most of the individual resources can be cached separately from the html content
  • Educate users that they don't need to put the extra slash in.

OTHER TIPS

Fix your links!

More than likely you are seeing the double slash because you have erroneous links on your own site, either hard-coded or script generated. It's easy to do this by mistake in a script that concatenates http://example.com/ + /page.aspx. Pay close attention to those types of concatenations!

IIS cleanses out extra slashes and so this cannot be addressed with any ASP.NET code or HttpModule. The extra slashes don't even make it into the IIS log file. I tested using IIS7 and telnet and could not get extra slashes into the log or ASP.NET.

I am not certain why the original question appears to involve IE only. Both IE and FF allow extra slashes in the URL and appear to transmit them, though I did not use packet sniffing to verify.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top