Reasons why asp.net does not need to restart IIS to modify the configuration file

Source: Internet
Author: User

As we all know, in asp.net, If we modify the configuration file, we only need to save it and then immediately respond to the program. We do not need to restart IIS. You can even directly replace the files in the application without stopping IIS, including the compiled dll files. All you need to do is replace the files you have changed. So how does. net do it?

This is due to the. net application domain mechanism. The application domain is a metaunit smaller than the process, that is, a process can contain multiple application domains. Each domain is independent and does not share memory. That is to say, various static variables are not shared among different domains.

With the application domain, it is easy to do things. When we change the configuration file or replace a core dll, then. net Monitoring System will report what we do, so the process processing asp.net will re-create an application domain for the modified application, this new domain will reflect all the changes. If a Request comes in, the new domain will be used for processing, and the original domain will be destroyed.

In fact, each application domain is not a dll file configured in each virtual directory. For 2.0, 3.0, 3.5, C: \ WINDOWS \ Microsoft. NET \ Framework \ v2.0.50727 \ Temporary ASP.. NET Files directory, so we can directly replace Files such as dll.

We can perform a simple test on creating application domains. Add the following processing code to the Application_BeginRequest event in the global file to name the application domain of each request to the trace file. To make it clear, we use the wran method.

Context. Trace. Warn ("MyCatolog", "Domain Name:" + AppDomain. CurrentDomain. FriendlyName );

Finally, do not forget to set Trace in the configuration file.

<Trace enabled = "true" pageOutput = "true" requestLimit = "44" traceMode = "SortByTime" mostRecent = "true"/>

Now we can access our page.

Trace:

Then let's change the configuration file, for example, change requestLimit to 10, save the file, and access it again, as shown in figure

We can see that the domain name has changed, that is, this is a new application domain.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.