in

ASP.NET Weblogs

This Blog

Syndication

Jason Salas' WebLog

On-air and online: making people laugh, making people think, pissing people off

The new "in" thing for web development: get rid of the query string

After I commented yesterday about MSNBC.com's site redesign, Robert McLaws had the wisdom to point out that the site's URLs are now in the following format: http://msnbc.msn.com/id/3695726/, making each story look like its own subdirectory.

In similar fashion, I've also taken note that Steve Smith at ASPAlliance also recently migrated his site's URL convention, lopping off the query string for user-submitted articles: http://aspalliance.com/324

After having migrated my own site to ASP.NET, I now use a convention that MSNBC previously used, employing my database’s ID field as the disguised filename: http://www.kuam.com/news/3457.aspx.  The facilities within ASP.NET for handling dynamically rewriting a path (namely, the RewitePath() method) make pulling this off incredibly easy. 

This draws to light a new theme that seems to be popping up more and more within the web development community, in particular from ASP.NET-driven sites: ridding oneself of the query string.  It would appear that site designers are now considering the cosmetic appeal of a URL as part of the site's total usability, and an Internet address' psychological effect on the user. 

Perhaps this infers that a user's thought pattern might be that if a URL is messy and complex, the site will be, too?

It seems that people are finally catching on to a principle that as a marketing guy, I've held since the first day I saw it: that query string-based URLs are really ugly.  Using one or more appended name/value pairs in a site's URL is incredibly hard to remember, and the values that were once extracted can now be accessed and persisted in other places just as well (Cache API, Session, ViewState).  I recall how people flocked to adding query string values to their URLs circa 1997 - whether they really needed them, or not - just to look advanced, shying away from plain 'ol “/directory/filename.html”. 

Apparently, people are starting to realize the promotional potential and KISS charm in simple page addressing schemes.  Good to see.

Comments

 

Robert McLaws said:

Whenever I had to build an app that made heavy use of query strings, I'd pop it up in a window with no address bar after login. Then they couldn't fudge with the app if they knew what they were doing.
December 13, 2003 6:10 PM
 

Jason Salas said:

Sweet. I did the same thing on numberous occasions - although a few crafty users were able to point it out from getting into IE's History folder and hovering over the page title.

Even though it's quite frequently recommended, I'm not a big fan of <input type="HIDDEN"/>.
December 13, 2003 6:15 PM
 

Waseem Sadiq said:

I would like to add that it's not only the appealing part of the query string that drives site builders to using 'friendly querystrings' but also the fact that search engines treat these url's as directory indexes thus successfully indexing them in contarary to the bla.asp?foo=bar pages.

That was the original concept behind the Apache MultiViews trick anyway, not sure if the search engines have become smarter nowadays,

- Cheers
December 13, 2003 6:39 PM
 

Jon Galloway said:

Hiding your address bar is by no means foolproof - Ctrl-N pops up a new window with default settings, including the address bar; if you're relying on hiding a querystring like ?superuseradmin=false, it's not tough to get around that.

We used a similar url rewriting technique on a CMS driven website recently - it's nice for other reasons, too. Search engines and website traffic analysis tools (webtrends, etc.), can catagorize by folder locations (even though they're virtual) a lot better than by querystrings, usually.
December 13, 2003 6:44 PM
 

Jason Salas said:

Hi Waseem,

Thanks for the tip...I'd read before that there were certain search engine advantages advantages to not using the query string. :)
December 14, 2003 1:58 AM
 

Jason Salas said:

Hi Jon,

Yeah...totall not foolproof!
December 14, 2003 1:58 AM
 

Jason Salas said:

Of note: here's a good link about making search engine-friendly URLs: http://www.codetoad.com/asp.net_ma_searchenginefriendly.asp
December 14, 2003 2:04 AM
 

denny said:

IMHO what I try to do is:

1) hide the "engine" I am asked to build "Web based applications" not web sites.
in word you don't get to see the name of the cpp files they used so why see the .asp / .aspx / .pl and so on ?

2) reduce the "attack surface"
things I am working on include striping off all the MS / IIS headers that annonuce what kind of server hardware / software is running that application, after killing off the
"IIS 6.0" and the "Powered By ASP.NET" and related headers the next thing is to make the cracker think the pages are just html if ican.
while a dedicated attach will figure out what I have done a casul peek at a site that only uses www.acme.com/this/that/foo/12637gf/at66/
and never serves up a foo.aspx or the like will be a tad less likeky to get targeted for more time cracking it.

and for some apps I toss up a frameset that grabs the /sss/ttt/sss stuff and just lets the user see: http://www.acme.com/
thats it, all the pages are called from under the master frame page thats just a big 100% * 100% frame.
so back to the "application" ness.... you just started "http://www.crm.acme.com/"
so thats all the URL bar should show in that case... as we don't want our customer data to be "Googled" .... so we add in https and no-cache and all that stuff....

December 14, 2003 7:59 AM
 

Tim Marman said:

I don't think Google will spider URLs based on querystring...
December 14, 2003 10:26 AM
 

Jason Salas said:

Hi Tim,

When my site's former naming convetion used ID columns in the query string, Google would index them this way, but it was sporadic. I think your chances will be better faking a filename or directory.
December 14, 2003 4:25 PM
 

Scott Mitchell said:

Tim, Google will spider URLs based on QueryString quite nicely. For example, ASPFAQs.com - http://www.aspfaqs.com/ - has a single "render" page - ShowFAQ.aspx - which takes in a querystring value to determine what FAQ to show. Google has all the ASPFAQs.com FAQs available...
December 14, 2003 6:44 PM
 

kemal said:

hi,

I always wandered how to do the "get rid of the querystring" thing.

does anyone knows how ?

kem
December 14, 2003 10:58 PM
 

Jason Salas said:

H, Kemal

Here's a sample, borrowed from Steve Walther's seminal work "ASP.NET Unleashed", which runs in the Application_Request event of your web app's GLOBAL.ASAX file:

public void Application_BeginRequest(object sender, EventArgs e)
{
string currentPath;
string customPath;

currentPath = Request.Path.ToLower();
if(currentPath.IndexOf("/content/") > 0 && System.IO.Path.GetExtension(currentPath) == ".aspx")
{
// the request is within the /CONTENT/ directory, so re-write the URL to appear to be a filename, rather than a URL with a query string.
customPath = String.Format("/mysite/content/templatefile.aspx?headline={0}",System.IO.Path.GetFileNameWithoutExtension(Request.Path));
Context.RewritePath(customPath);
}
}
December 15, 2003 12:11 AM
 

Mark Lapierre said:

For anyone interested, here's an <a href="http://www.alistapart.com/articles/succeed/">article</a> on A List Apart which talks about URL rewriting.

Their's was the method I'd used in the past when building PHP driven web sites.

<a href="http://www.alistapart.com/articles/tacklingusability/">This article</a> talks further about URL rewriting, as used in the redesign of their site not too long ago.
December 15, 2003 5:27 AM
 

Mark Lapierre said:

*gulp*

Excuse the messed up links, I should have noted that .Text doesn't permit html in comments :/
December 15, 2003 5:30 AM
 

Jason Salas said:

Also, note that in ASP.NET 2.0, you can manually control URL mapping for complex, unattractive URLs to friendlier addresses with web.config.

<urlMappings enabled=“true”>
<add url=“~/dir/dir2/filename.aspx?key=val&key2=val2” mappedUrl= “~/MySite/index.aspx”/>
</urlMappings>
December 15, 2003 6:46 AM
 

Scott said:

This is neat, but hardly new. Apache has had mod_rewrite for quite some time now. http://httpd.apache.org/docs/misc/rewriteguide.html

It's nice to see a easy method of doing this in ASP.NET. All of the other methods I've seen were ISAPI based. Ick. I've got some querystring based parameters, nothing like "admin=false" or anything like that, that would be nice to hide from an aestethic point of view.
December 15, 2003 9:45 AM
 

TrackBack said:

December 25, 2003 7:45 AM
 

Jason Salas said:

Just a follow-up...Steve Smith explains how he pulled off this trick with Regular Expressions: http://weblogs.asp.net/ssmith/archive/2003/11/06/36191.aspx
December 25, 2003 5:40 PM
 

TrackBack said:

December 29, 2003 1:52 PM
 

PatF said:


If you can change the 404 page used on your site to a .aspx page, you can effectively have the .net framework process any path you want (as long as that path doesn't actually exist).

You could use this to have your asp.net pages look like .html pages or directories, or anything you like :

protected void Application_BeginRequest(Object sender, EventArgs e)
{
string strPath=Request.RawUrl;

if(strPath.IndexOf("404.aspx") > 0 && strPath.IndexOf("mypage.html") > 0)
{
Context.RewritePath("realpage.aspx");
}

}

This would translate any request with the string mypage.html in it to the page realpage.aspx.

April 6, 2004 11:39 AM
 

TrackBack said:

July 5, 2004 10:11 AM
 

TrackBack said:

July 6, 2004 4:14 AM
 

TrackBack said:

Ping Back来自:blog.csdn.net
August 24, 2004 3:08 PM
 

TrackBack said:

Ping Back来自:blog.csdn.net
August 31, 2004 3:32 PM
 

TrackBack said:

Ping Back来自:blog.csdn.net
September 9, 2004 8:35 PM
 

TrackBack said:

Ping Back来自:blog.csdn.net
November 16, 2004 6:27 AM
 

TrackBack said:

April 15, 2005 6:59 AM
 

TrackBack said:

April 15, 2005 7:00 AM
 

hoyaoknow said:

引言
让我们花点时间来看一下网站上的一些 URL。您是否发现一些类似于 http://yoursite.com/info/dispEmployeeInfo.aspx?EmpID=459-099
June 26, 2006 11:22 PM
 

cybermat said:

URL 重写是截取传入 Web 请求并自动将请求重定向到其他资源的过程。执行 URL 重写时,通常会检查被请求的 URL,并基于 URL 的值将请求重定向到其他 URL。例如,在进行网站重组而将 /people/ 目录下的所有网页移动到 /info/employees/ 目录中时,您可能希望使用 URL 重写来检查 Web 请求是否指向了 /people/ 目录中的文件。如果请求指向 /people/ 目录中的文件,您可能希望自动将请求重定向到 /info/employees/ 目录中的同一文件

August 11, 2006 2:18 AM
 

free music codes video myspace said:

free music codes video myspace

September 22, 2007 1:39 PM
 

get more website traffic said:

Copyright Seo Toast-

March 29, 2008 1:27 PM
 

podcast directory said:

I wholeheartedly 100% agree. I could not have said it any better

May 21, 2008 6:46 AM
 

wiki directory said:

/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /

August 7, 2008 8:37 PM
 

Marry Luxury said:

if you're relying on hiding a querystring like ?superuseradmin=false, it's not tough to get around that.

That was the original concept behind the Apache MultiViews trick anyway, not sure if the search engines have become smarter nowadays,

February 8, 2009 1:30 AM

Leave a Comment

(required)  
(optional)
(required)  
Add