Geeks With Blogs
Jeff Krebsbach
A few months ago I set up a web forms project for a new client using Visual Studio 2013.  One of the default NuGet packages - ASPNet.FriendlyURLs - was very exciting to see - 


And as I've been really enjoying MVC's routing tools it's very nice to see that also available for web form technologies.  However, once we deployed to the dev server things went wrong.

Apparently even on Windows Server 2008, FriendlyURL also relies on the URL Rewrite extension to be installed on IIS: More info here which really surprised me - I expected having the right version of .Net being installed to be sufficient.  But, the web server was not routing the FriendlyURL addresses and was instead delivering 500 errors.

Rather than add an additional dependency on the project - I removed the FriendlyURL NuGet package from the project.  Things worked fine on the web server, but I noticed something strange on my local machine even after removing FriendlyURL from the solution.

Internet Explorer on my local machine kept sending me to Default instead of Default.aspx, and Settings instead of Settings.aspx.  Chrome didn't seem to have a problem, and any pages that I added afterwards also didn't have this redirect issue.  Somehow Administration.aspx and Import.aspx weren't trying to redirect to their non-existent friendly URL versions.

Digging deeper, I wanted to see if somehow my IISExpress was holding onto FriendlyURLs and was doing something about requests coming from IE - but watching the logs, the request coming into IISExpress was already being changed to drop the aspx extension.

This told me that the problem had to be coming from inside Internet Explorer - somehow the IE browser when it first was redirected by the FriendlyURL component several months ago, it kept that in a super secret cache and wasn't letting go.  Now ever time I tried to navigate to the unfriendly version (default.aspx), IE said "I know where you really want to go" and instead redirected me to the friendly URL (default) - which is no longer being handled and would give a 404 error.

Apparently somebody at PennState had this problem not too long ago - and wrote up a little internal article describing the problem. And in case PennState ever goes away, here is the jist of the article:

A "redirect" is feature that allows a web server to tell a browser "You asked for page X, now I'm going to send you to page Y." This is commonly used to create short URLs, similar to the service bit.ly provides. Unfortunately, IE9 permanently caches these redirects and they cannot be purged by clearing the browser cache.

(Since I'm running IE 11 and seeing this problem, this functionality has been around for quite a while...)

And then their solution:

Solution

There appears to be no way to purge the redirect from the browser cache by using the standard cache purging functionality in the Internet Options configuration screen.

One method that appears to work:

  • Clear your browser history and cache. These instructions are for IE8, but will work in IE9 as well.
  • Go to the Tools menu and enable InPrivate Browsing (anonymous browsing) mode.  This will open a new window.
  • Paste the original URL of the page that incorrectly redirects into the URL bar of the new window
  • Verify this redirects to the correct page.
  • Close and restart Internet Explorer.

Definitely more complex of a solution than I would have ever expected for a problem that seems like it should be pretty common...  At least I didn't have to use my black bag of voodoo chicken bones...  I'll save that for next time.
Posted on Thursday, January 23, 2014 8:42 PM ASP.NET , WebForms , MVC , Friendly URLs , Internet Explorer | Back to top


Comments on this post: Friendly URLs with Visual Studio 2013

# re: Friendly URLs with Visual Studio 2013
Requesting Gravatar...
I used visual studio. Thanks share your article.
Left by uttkarsh sing on Jan 28, 2014 6:15 AM

# re: Friendly URLs with Visual Studio 2013
Requesting Gravatar...
thanks mate, this was killing me.
Left by Angus on Apr 09, 2014 4:54 PM

# re: Friendly URLs with Visual Studio 2013
Requesting Gravatar...
Thanks so much!! I've been searching for weeks for a fix to this issue!!
Left by Dan on May 08, 2014 1:08 PM

# re: Friendly URLs with Visual Studio 2013
Requesting Gravatar...
THANKS SO MUCH!!!
Left by Mariana on Sep 12, 2014 3:21 PM

Your comment:
 (will show your gravatar)


Copyright © jkrebsbach | Powered by: GeeksWithBlogs.net