Modify Web Configuration file without restarting asp net worker process (aspnet_wp).

19 10 2008

Modify Web Configuration file without restarting asp net worker process (aspnet_wp).

No one in the world can say that web.config file will remain intact after the deployment. Modifications have to happen to some or the other parameters of the web configuration file like one has to add or remove key value pairs from appsettings section etc…

So what?
As soon as the webs configuration file is saved the aspnet_wp worker process of that particular web application gets restarted and all the current sessions and data are lost.

This can cause tremendous issues to an organization whose application needs to be up for 24*7.

To recover from such kind of scenario Microsoft has already provided a great tweak to handle this.

Following are some steps that need to be followed.
Step 1) Make a separate configuration file lets say for example appsettings.config with the following xml data.


<?xml version="1.0"?>
<appSettings>
  <clear/>
  <add key="Name" value="Dhaval"/>
  <add key="Surname" value="Upadhyaya"/>
</appSettings>

Step 2) Now in the original web.config file make your appSettings section look like below


<appSettings configSource="appsettings.config">
</appSettings>

You are done.

 
Place a debug point on the Application_Start event in global.asax file and check that changing appsettings.config does not restart the worker process.

Advertisements




Choosing storage place for Images

9 10 2008

  

  

Choosing storage place for Images

 

In this article I have jotted down various pros and cons for choosing the best storage place for images used in our web based applications.

 

There are two basic approaches for storing the images that are used in our web application

  1. File System
  2. Database

 

Below are some comparisons between the two:

  

Ease: One can easily configure the path of an image from a directory on the web server containing images while from database one needs to create custom logic for reading Image data (eg .ashx handler for image)

 

 

Flexibility: It is always easy to store a new image file on the web server while in case of database new column needs to be created. 

 

 

Maintenance: Using simple file operations for storing the image on web server is very trivial task while in case of database one might need to create a complex query or business logic.

 

 

Caching: IIS can be easily configured to cache images stored in file system while images in database needs some further complex IIS configuration

 

 

Size: As the web directory in which our application is hosted can be easily scaled in terms of size for storing more images as a when needed while in database the size of database goes on increasing affecting the overall database performance.

 

 

Compatibility: Images are stored on file system with basic file operations while in case of database during migration process to some other database vendor their may be some Data Type compatibility problem

 

 

Performance: File operations are less costly in resource utilization while database operations are more costly in terms of resources.