10 Features why Asp.Net 4 is better for public website

Updated [09/10/19] Thanks for all the retweets and trackback. I think it started rolling from ScottGu's tweet mentioning this post. Please don't forget to follow me at Twitter @ronaldwidha.

I'm excited about Asp.Net 4 and just finished reading the Asp.Net 4.0 Beta 2 Overview. On this post, I want to highlight a few enhancement on this framework which makes it better for implementing a public website.

The overall approach seem to be ’˜trusting the developer more'. Microsoft have built a few crucial extensibility points which allow us to extend further from the Asp.net in-built implementations.

1. Accessibility: Control over Url

image

Those of us who have played with Asp.Net MVC must appreciate the degree of control we have over how URL is handled. We don't have to care anymore about writing our own HttpModule to handle internal and external Url.

This feature has been available on Asp.Net 3.5, but Asp.Net 4 introduce a couple of features to make it easier for us to use it, this includes:

  • setting up routing specific to Asp.Net requirement (mapping to a physical aspx file)
  • Reading routing information in a Web Form page is now almost as easy as reading from query string
    Page.RouteData.Values["blogtitle"] as string;

  • Accessing routing Information in Markup: no more hard-coding Url into our markup
     NavigateUrl="<%$RouteUrl:Search=ronaldwidha%>"

2. Accessibility: Permanently Redirecting a Page

As you might already know there are numerous redirection headers; 301 is one of them. 301 signifies that a page has been moved permanently to a new location. Prior to Asp.Net 4.0, we have to construct the response header manually by doing:

Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","https://new-location");

Now we can simply use the helper class available in Asp.Net 4:

RedirectPermanent("https://new-location");

3. Accessibility: Extensible Browser Capabilities

Browser Definition is a feature Asp.Net uses to determine the capability of a browser. This feature have been introduced in the Asp.Net 3.5 SP1, however it requires change XML files and some command prompt action.

Side Note: Scott Hanselman spoke to Chris Woods, a program manager at Microsoft on the Mobile Browse Platform Team about a database of mobile device capabilities which uses the same mechanism.

On Asp.net 4, Microsoft include quite an extensive browser definition files which includes browsers like iphone, chrome, safari and opera.

3g-iphone-earrings_2 
taken from https://www.geeky-gadgets.com

Adding to that, this feature is extensible by the usual Provider model.

4. Performance: Extensible Output and Object Caching

No great site can survive without a good caching strategy. Asp.Net does always have a caching mechanism built in, but it lacks native support to external distributed caching engines.

On Asp.Net 4, output and object caching are implemented using the Provider model, which means you can use the normal cache object to interact with your own custom cache engine!

Or even better, implement your own custom caching strategy based usage patterns, time of day, etc.

5. Performance: Control over Client ID

image

With the prior versions of Asp.net, we lost control over what Html ID gets generated to the clients. This introduce 2 problems: performance (size of download gets bigger) and it becomes so darn hard to write client side script without a reliable client ID.

Side Note: QA team also often finds it difficult to write consistent Automated UAT Script (using WatiN or Selenium) having the client ID automatically generated by Asp.Net.

Asp.Net 4 introduce ClientIDMode which lets you set AutoID, Static, Predictable and Inherit.

Static : specifies the ClientID to use the value as the ID of the web user control without the parent naming containers.

Predictable : specifies the Client ID with a specified row suffix. This is generally used for controls with repeating templates.

6. Performance: More Granular View State Control

In prior Asp.Net versions, ViewState is enabled by default and can't be disabled sitewide. In Asp.Net 4 this is now possible. Possible values include Enabled, Disabled and Inherit.

Remember, View State aren't evil but it has to be utilized carefully.

image

7. Performance: Session State Compression

Handling massive amount of session state can be quiet expensive on a large website. Asp.Net 4 introduce a simple switch to turn Gzip compression on out-of-process session state providers. Very cool!

8. Performance: Auto-Start Web Applications

Some sites have extensive Application_Start procedure, for e.g eager cache static content, or let the load balancer know that the server is ready to start serving requests. However in previous Asp.net versions, Application_Start happens upon the first user visit the site causing terrible experience for this unlucky person.

Side Note: hence often we have an automated ping to fake the first request to kick off the application

Asp.Net 4 with IIS 7.5 introduce an always on mode which start the web site automatically.

9. Security: Extensible HTML, URL and HTTP Header Encoding

Have you ever had problems of not being able to escape special characters by using HttpUtility.Encode ? In the previous Asp.Net versions the encoding technique doesn't seem to be aggressive enough. In Asp.Net 4, Microsoft again introduce an extensibility point to built our own and have it configured from the web.config file.

<httpRuntime encoderType="Samples.MyCustomEncoder, Samples" /> 

10. Security : Extensible Http Request Validation

Asp.Net 4 introduce a few things that improves security when it comes to handling http requests:

  • Url character check configuration.

    afraid of script injection/XSS (cross side scripting) attacks from the url? fear no more, now we can specify a list of invalid chars. If it failed the test, http 400 will be returned back
  • Request Validation

    This is an attempt to validate all HTTP request data. We have to see how effective it really is.
  • As you might start to recognize a pattern from the previous points, guess what? Request Validation feature is also extensible, so if Microsoft isn't doing a good enough job, you could implement it yourself.

The Bad news is there seem to be  not much improvement over the rendering of the web controls. Render=Flow still generate a bunch of span-s instead of div-s which I personally found limiting.


online calculator
mortgage calculator
calculator
bmi calculator
money converter
conversion
loan calculator
love calculator
gpa calculator
temperature conversion
unit converter
calorie calculator
paycheck calculator
weight conversion
emi calculator
weight loss calculator
unit conversion
payroll calculator
tax refund calculator
calculate gpa
currency exchange
scientific calculator
percentage calculator
kalkulator
calculator online
salary calculator
tax calculator
graphing calculator
exchange rate calculator
auto loan calculator
car loan calculator
income tax calculator
texas instruments
fraction calculator
car payment calculator
retirement calculator
mortgage payment calculator
currency calculator
amortization calculator
subnet calculator
interest calculator
online graphing calculator
calculate bmi
compound interest calculator
home loan calculator
vat calculator
conversion calculator
factoring calculator
calc
payment calculator
body fat calculator
online scientific calculator
graphing calculator online
algebra calculator
tire size calculator
concrete calculator
google calculator
calculater
currency exchange rates
percent calculator
scientific calculator online
atar calculator
calculate gpa
mortgage repayment calculator
loan repayment calculator
savings calculator
finance calculator
mortgage loan calculator
financial calculator
stamp duty calculator
kalkulator online
car finance calculator
annuity calculator
investment calculator
sales tax calculator
interest rate calculator
caculator
free calculator
free online calculator
probability calculator
postage calculator
calculate percentage
loan payment calculator
ato tax calculator
personal loan calculator
psu calculator
bmi calculator male
budget calculator
tax calculator 2011
gfr calculator
day calculator
ip subnet calculator
fractions calculator
calculate
ratio calculator
tip calculator
weight calculator
mortgage amortization calculator
gst calculator
morgage calculator
mortage calculator
pay calculator
calculating bmi
online calculator free
calculating percentages
exchange rates calculator
texas instruments calculators
math calculator
bmi calculator women
tire calculator
present value calculator
mortgage rate calculator
volume calculator
home mortgage calculator
apr calculator
mortgage calculators
metric conversion calculator
calculator.com
currency converter calculator
trigonometry calculator
calculators
loan amortization calculator
simple interest calculator
car tax calculator
btu calculator
bmi calculation
future value calculator
car calculator
auto payment calculator
auto calculator
parlay calculator
roth ira calculator
college gpa calculator
calculation
currency converter
currency convertor

  1. Paco Márquez says:

    Nice Post!

  2. Fajar says:

    Good news there! Any ideas about porting existing ASP.NET 3.5 to this version?

  3. ronaldwidha says:

    Looking at the Asp.net 4 overview document, there isn't seem a whole lot of information about what gets deprecated. But my guess would be it's gonna be straightforward. From ASP.net perspective, all the web controls and http related classes are still supported. So is in terms of the language support and overall .Net framework stuff. I'd be surprised if it was as troublesome as .Net 1.1 to .Net 2.0. Back then there was a shift how the web project was handled, etc. It's not the case from 3.5 to 4

  4. Fajar says:

    Nice! I might consider porting my current work to ASP.NET 4 just for point number 5 and 6.

  5. ronaldwidha says:

    Having control over ID is indeed pretty sweet. However, you can still disable viewstate on asp.net 3.5, just not site-wide I don't think. Remember you'll be working on beta technology (asp.net, .net4 and vs2010 are all still in beta). Watchout for Asp.net 4 beta 2 is out 19th October for MSDN subscriber and general public on 21st.

  6. Fajar says:

    Yes of course. My work is not going live until June 2010, so if .net4 could really make it to final version in Q1 of 2010, I think I can spend a few weeks just messing around. Or maybe work on it for the next iteration. Who knows.

  7. simoness says:

    asp net file browser https://www.gleamtech.com/products/fileultimate/asp-net-file-manager-control FileUltimate is an ASP.NET file manager control which you can add directly to your existing ASP.NET (.aspx) pages. The control renders a user interface similar to "Windows Explorer" within the page and this user interface allows you to view the contents of the predefined root folders and allow complete file management actions within those folders. File management actions can be limited by predefined permissions and quota limits on each folder separately.

  8. Javmes says:

    Lolz...Screenshot from a php website to explain the Asp.NET Feature..heheheheh

  9. ronaldwidha says:

    have you ever heard of "use the best tool for the job" ?