Optimizing ASP.NET 2.0/3.5 Before Going Live ASP.NET

The following are some tweaks that should be made to web.config before you go live on your production server,if you are using the ASP.NET 2.0/3.5 Member ship provider.

1.Add the applicationname attribute in Profile provider.If you do not add a specific name here, Profile provider will use a GUID. So, on your local machine you will have one GUID and on the production server you will have another GUID.If you copy your local database to the production server, you won’t be able to reuse the records available in your local database, and ASP.NET will create a new application on the production server (see Example).

Add a fixed application name in the Profile provider configuration section so that when you move a prepopulated database from the development server to production, the application ID does not change.

<profile enabled="true">
<clear />
<add name="..." type="System.Web.Profile.SqlProfileProvider"
connectionStringName="..." applicationName="YourApplicationName"

2. Turn off auto profile save.Profile provider will automatically save the profile whenever a page request completes,even if you have already saved the profile or you don’t want it to save anything.So, this might result in an unnecessary UPDATE on your database which is a significant performance penalty. So, turn off automatic save and do it explicitly from your code using Profile.Save( );(see Example ).

Turning off automatic save in Profile provider configuration

<profile enabled="true" automaticSaveEnabled="false" >

Configure Role Manager to use cookies.Role Manager always queries the database to get the user roles, which has a significant performance penalty. You can avoid this by letting Role Manager cache role information on cookies.However,this will work only for users that don’t have many assigned roles that exceed Cookie’s 2 KB limit.It’s unlikely you would have many roles with a kilobyte of storage after encryption. So, you can safely store role info on a cookie and save one database roundtrip on every request to. aspx and . asmx whenever you check for a user’s role. The cookie is encrypted using TripleConfigure the role manager to use Cookie to store the user’s roles instead of doing a database lookup on every request.

<roleManager enabled="true" cacheRolesInCookie="true" >

These small changes in web.config will protect you from significant scalability problems when site traffic increases, such as 50 to 100 requests per second per server.These changes will save 2 to 3 database calls per request, and you will save about 100 to 300 database calls per second on such a load, which puts much less stress on your database server and lets you grow more on the same hardware.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

ASP.NET Topics