Welcome to Professional ASP.NET - Chris Love's Official Blog Sign in | Join | Help

Chris Love's Official ASP.NET Blog

Chris Love's Helpful tips, tricks and pragmatic development knowledge for the ASP.NET world.
Add to Technorati Favorites


ASP Insider Follow Me On Twitter
Get Your Head Out of the LAMP's ASS and See Some Light - ASP.NET URL Rewriting Works Great!

Last week Jonathan Hochman wrote an article about how URL Rewriting does not work properly on the ASP.NET/IIS platform. He could not be farther from the truth if it bit him on his big toe and drew blood. Jonathan admits that he was extremely green to the ASP.NET platform and was doing research on how to perform URL Rewriting, permanent redirects and custom error pages. Well anyone with more than a day or two working with ASP.NET most likely is aware of how to configure custom error pages, and I plan on covering that in another post.

Permanent redirects are when you tell the client the resource has been permanently moved and provide the new URL. In the process you pass a 301 status code in the response header. I will go into more detail about that in another article too. I have already covered 301 permanent redirects in ASP.NET to a certain extent more than a year ago.

What really got my goat was Jonathan's comment "Microsoft's URL rewriting technology does not inspire much confidence." and pointing out an erroneous entry from Matt Cutts that ASP.NET URL Rewriting throws a 302 status code (temporary redirect) instead of a 200 status code indicating a successful request.

Today I want to directly address Matt Cutts' article from July 5 2006. For those of you who are not in the know, Matt is the Scott Guthrie of search engine optimization world and works for Google. If you are anyone in the search engine optimization world you hang on his every word like stock traders used to hang on Allen Greenspan's every word in front of congress.

In Matt's article he points us to an entry on the Community Server's forums where a member states that his Community Server site is tossing up 302 status codes when a page is requested through URL Rewriting. I checked my Blog, since it is Community Server and could not replicate this issue at all. I then checked several sites I am using the RewritePath method to perform URL Rewriting and could not replicate this person's issue.

As it turns out it was a bug in Community Server, not ASP.NET. Well not really, the RewritePath method has several overloads and the version that Community Server 2.0 was using needed to be adjusted.

ReWritePath Method Overloads as Provided by Reflector

Public Sub RewritePath(ByVal path As String)
Public Sub RewritePath(ByVal path As String, ByVal rebaseClientPath As Boolean)
Public Sub RewritePath(ByVal filePath As String, ByVal pathInfo As String, ByVal queryString As String)
Public Sub RewritePath(ByVal filePath As String, ByVal pathInfo As String, ByVal queryString As String, ByVal setClientFilePath As Boolean)
Friend Sub RewritePath(ByVal filePath As VirtualPath, ByVal pathInfo As VirtualPath, ByVal queryString As String, ByVal setClientFilePath As Boolean)

While I think forums like on CommunityServer.org and Forums.ASP.NET are great ways for the developer community to grow, they can also be the source of hysteria. In this case it was a bog, just not really with the framework. I know from experience that Search Engine Optimization forums like Digital Point are used way too often to cause the competition to waste hours down the wrong paths. I try to stay on top of what Matt post on his blog, but to this day I have not seen him point out what the issue really was, so people like Jonathan just assume ASP.NET is inferior. Not that I am calling Matt dishonest, but it would be nice for a admitted Microsoft bigot to admit that Microsoft products are not that bad once in a while. Yes I called him a Microsoft bigot, you should have heard him on this podcast I caught the other day!

I have checked and rechecked this situation and just do not have the issue on any of my sites.

So here is what I plan on doing over the next month or so, do a series on URL Rewriting, Custom Error pages and response Status Codes from a technical and a Search Engine Optimization point of view. I use httpHanlders, Regular Expressions and anything else I need to get the job done. I hope when I am done there will be no confusion for anyone out there about the functionality of ASP.NET URL Rewriting.


Share this post :
Posted: Monday, September 24, 2007 8:13 PM

by Chris Love

Comments

Guy Harwood said:

good! looking forward to the articles on rewriting

# September 25, 2007 4:58 AM

TrackBack said:

# September 25, 2007 9:59 PM

TrackBack said:

# September 25, 2007 9:59 PM

Chris Love's Official Blog - Professional ASP.NET said:

Earlier this week I started with a rant about ASP.NET and Search Engine Optimization and was really tired

# October 2, 2007 3:17 PM

Michael K. Campbell said:

Chris, Wish I shared your optimism. I launched a site 1 week ago and have been fighting weird issues where bots seemed to always encounter strange problems and errors. I've spent an insane amount of time: a) making sure that my site would be OBSCENELY SEO friendly once launched (specifically with vanity urls) and b) trying to figure out why EVERYONE could see my friggin site, but search engines kept crashing the damn thing. At first I thought it was some of my own code designed to make sure that bots don't get counted when it comes to recording ad impressions. Imagine my surprise when I was finally able to track down the error to RewritePath()? To put it mildly, I'm pissed beyond belief and plan on letting the ASP.NET team know that they've completely dropped the ball here. Granted, i'm sure that one of the umpteen billion overloads that I'm using is the culprit (haven't quite figured it out yet), but the fact that this JUST screws you in production when BOTS come to your site can't be understated enough. I'll be lucky, when done with this fiasco, if google forgives me. Otherwise, the implications are so huge I can't even bring myself to think about them. And here's a great post summarizing just what I'm up against: http://todotnet.com/archive/0001/01/01/7472.aspx Though, sadly, the exact repro they provide there isn't what's hosing me (I'm starting to think that it might be my RewriteForm code, or an older set of browser definitions..... ) That said: NOTHING quite like testing this crap out against robots - because no matter HOW HARD i try with various tools (fiddler included) i can't duplicate the behavior that the robots get when visiting the site. So... while I'm not disagreeing with you that some LAMP folks are too religious, as a guy who bet the farm on ASP.NET, I'm now pretty pissed at just how insanely hard I've been burned by MS' major problems when it comes to SEO.
# August 6, 2008 7:58 PM

BryanS said:

ASP.NET aas a number of features but having implemented the SEO as recommended in the Professional SEO with asp.net the proposed solutions do have limitations - this includes a loss or relative addressing and usnig REGEX introdcues a debugging challenge. Yes, ASP.NET does have soem degree of capability but sadly lacks basic features as seen for some time within the LAMP. Another guy who bet the farm on ASP.NET
# September 10, 2009 11:38 PM

Chris Love said:

You should not be using Regex for SEO. It is hard to hydrate SEO urls back to article titles for example.

# September 11, 2009 12:03 PM

Web Design West Palm Beach said:

Another web 3.0 topic worth discussing in detail.

# February 22, 2010 5:26 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS