Skip to main content

Asp.Net 4.0: An Overview-Part-III

This is the last post in the series which will explore the following new features of ASP.Net 4.0

  •  Performance Monitoring for Individual Applications in a Single Worker Process

  • Web.config File Refactoring

  • Permanently Redirecting a Page

  • Expanding the Range of Allowable URLs


Performance Monitoring for Individual Applications in a Single Worker Process

It is a common practice to host multiple ASP.NET applications in a single worker process, In order to increase the number of Web sites that can be hosted on a single server.

This practice results in difficulties for server administrators to identify an individual application that is experiencing problems.

ASP.NET 4 introduces new resource-monitoring functionality introduced by the CLR. To enable this functionality, following XML configuration snippet is added to the aspnet.config configuration file.(This file is located in the directory where the .NET Framework is installed )

<?xml version="1.0" encoding="UTF-8" ?>

<configuration>

<runtime>

   <appDomainResourceMonitoring enabled="true"/>

</runtime>

</configuration>

When the appDomainResourceMonitoring feature has been enabled, two new performance counters are available in the "ASP.NET Applications" performance category: Managed Processor Time and Managed Memory Used. With ASP.NET 4, administrators can now view into the resource consumption of individual applications running in a single worker process.

Web.config File Refactoring


In .the NET Framework 4, the major configuration elements have been moved to the machine.config file, and applications now inherit these settings. This allows the Web.config file in ASP.NET 4 applications either to be empty or to contain just the following lines, which specify for Visual Studio what version of the framework the application is targeting:

<?xml version="1.0"?>

<configuration>

<system.web>

<compilation targetFramework="4.0" />

</system.web>

</configuration> 

Permanently Redirecting a Page

 In Web applications pages and other content are moved around over time, which generally to stale links in search engines. To avoid this developers generally use Response.Redirect method to forward a request to the new URL.

What’s wrong with this approach?

The Redirect method issues an HTTP 302 Found (temporary redirect) response, which results in an extra HTTP round trip when users attempt to access the old URLs.

 What ASP.NET 4.0 offers

 ASP.NET 4 adds a new RedirectPermanent helper method that makes it easy to issue HTTP 301 (Moved Permanently) responses, as in the following example:

 RedirectPermanent ("/newpath/foroldcontent.aspx");

 What purpose does it serve?

 Search engines and other user agents that recognize permanent redirects will store the new URL that is associated with the content. It eliminates the unnecessary round trip made by the browser for temporary redirects.

 Expanding the Range of Allowable URLs

 

What is the Constraint in URL Length?

Prior to ASP.Net 4.0, URL path lengths could only be up to 260 characters. Seems like it’s enough for most of the URLs, but trust me and team mates who had a nightmarish experience when the URL length went way ahead of this limit, while implementing URL encryption for Proctor Management (and the only option that we had to follow was to change the encryption algorithm). There is a separate post for this, which can be read here.

 What does ASP.Net 4.0 Offer?

In ASP.NET 4, provides the option to increase (or decrease) the URL length limit as appropriate for the applications, using two new httpRuntime configuration attributes.

 The following example shows these new attributes.

<httpRuntime maxRequestPathLength="260" maxQueryStringLength="2048" />

 To allow longer or shorter paths (the portion of the URL that does not include protocol, server name, and query string), modify the maxRequestPathLength attribute.

To allow longer or shorter query strings, modify the value of the maxQueryStringLength attribute.

 Extending Allowable URLs

Prior to 4.0, ASP.Net the URL character checks were limited to a fixed set of characters

When ASP.NET finds an invalid character in the path portion of a URL, it rejects the request and issues an HTTP 400 error.

ASP.NET 4 also enables the developers to configure the characters that are used by the URL character check.The set of valid characters can be customized by  using the new requestPathInvalidChars attribute of the httpRuntime configuration element, as shown in the following example:

 <httpRuntime requestPathInvalidChars="&lt;,&gt;,*,%,&amp;,:,\,?" />

 By default, the requestPathInvalidChars attribute defines eight characters as invalid. (In the string that is assigned to requestPathInvalidChars by default, the less than (<), greater than (>), and ampersand (&) characters are encoded, because the Web.config file is an XML file

Note ASP.NET 4 always rejects URL paths that contain characters in the ASCII range of 0x00 to 0x1F.

This post concludes the series started for exploring Server Side enhancements in the ASP.Net 4.0.

This series is not exhaustive and a lot of other new features have been left out, that can be read from MSDN.

Hope this series was helpful,

Till Next we connect…..

Happy Learning!

Comments

Popular posts from this blog

WCF-REST Services-Part-II

HOW REST is implemented in WCF Part-I of the series explored the REST conceptually and this post will explore how REST is implemented in WCF. For REST implementation in WCF, 2 new attributes namely WebGetAttribute and WebInvokeAttribute are introduced in WCF along with a URI template mechanism that enables you to declare the URI and verb to which each method is going to respond. The infrastructure comes in the form of a binding ( WebHttpBinding ) and a behavior ( WebHttpBehavior ) that provide the correct networking stack for using REST. Also, there is some hosting infrastructure help from a custom Service¬Host ( WebServiceHost ) and a ServiceHostFactory ( WebServiceHostFactory ). How WCF Routes messages WCF routes network messages to methods on instances of the classes defined as implementations of the service. Default behavior ( Dispatching ) for WCF is to do this routing based on the concept of action. For this dispatching to work, an action needs to be present in ev

SOLID principles -Code Samples and Free Ebook

I planned to write code samples for SOLID principle implementations, however I am a firm believer of " NOT RE-INVENTING THE WHEEL ", when all you need is use the wheels and make a new CAR. Going by the ideology, I have found an excellent  SOLID principles FREE -Ebook ( covering all aspects of SOLID design principles, with Code sample). This book is an excellent visual aid to remember these principles, as it uses Motivational posters for explaining SOLID design principles. One additional advantage to the above mentioned book is the Code-Refactoring ebook . Both of these books can be downloaded from this EBOOK download Link Both of these books can be downloaded form here. Hope this book proves useful... Till next we connect.... Happy Learning..