When Written: Oct 2009
Many of the other improvements have been enhancements to the .NET framework which is now at version 4. Obviously there is no room to describe them all here but a few that caught my attention were URL Routing, Permanent Redirect and Autostart. URL Routing enables you to tidy up your URLs to ones that are more user and search engine friendly so for example :
This makes for a friendlier URL but so what? In the never ending game of trying to increase your page ranking with the search engines just bear in mind that many search engines use the URL itself to index the page. So if searching on the web for ‘books’ a page with ‘books’ in the URL will increase the page’s relevance over one that has productid=23 in the URL.
The tricky thing in the past with URL Routing in ASP .NET was preserving the postback, which is where a page will make a call back to the server to get more data without redrawing the whole page. If the URL differed between the calling page and the URL on the web server then all sorts of kludges had to be coded to get things to work. Now with .NET4 all this become a breeze. Another handy enhancement is the Response.RedirectPermanent() method which is used to redirect the browser to another web page. This differs from the usual Response.Redirect() method which will issue a HTTP code 302 and redirect the client browser to a new page. With the RedirectPermanent method an HTTP code 301 is issued and the client browser or search engine will use this redirected URL for all future requests, which saves on unnecessary callbacks to the server and helps with search engine rankings.
The final new feature of ASP .NET 4 that I will discuss here is a big one called ‘auto-start’. The reason for this feature is that a big problem with ASP .NET web applications is that there is often a considerable delay when the first request hits the server whilst various initialisation and data queries are performed. However, after this first request the web site will perform how it should. If there are no requests for a period of time then the same delay will occur on the next request, which can be quite annoying, particularly as it can sometimes result in a timeout on slow servers.
One way round this is to code an application that periodically accesses the web site to keep things ‘alive’ but this is a bit of a kludge. When I asked Microsoft three months ago what they suggested to avoid this delay, and was there a ‘best practices’, answer there came none! So now with .NET 4 you can force an application pool which is the area of memory that one or more web sites run in, to be always running. You would not want to set this on all web sites as some may start up quickly without this help and setting Autostart for all web sites would cause a lot of unnecessary process cycles on the web server, possibly to the detriment of web sites hosted on it as even the rarely accessed web sites would be running all the time. To use this feature you need to add to your applicationHost.config file the lines:
<add name="MyApplicationPool" startMode="AlwaysRunning" />
If you have more than one web site running in the same application pool then you still use this feature but the coding is a little more involved. Web design made easy ? Not really but certainly a move in the right direction.
Article by: Mark Newton
Published in: Mark Newton