Use PreApplicationStartMethodAttribute and cattribute

Source: Internet
Author: User

Use PreApplicationStartMethodAttribute and cattribute

The first time I saw this thing in my company's framework, I was quite depressed at the beginning. I had nothing in Application_Start of the framework, and I found the PreApplicationStartMethodAttribute through some clues.

Here is a simple record.

 

1. Role

Specify a function to be executed before the site's Application_Start.

2. Usage

[Assembly: PreApplicationStartMethod (typeof (SomeClassLib. Initializer), "Initialize")]

It is generally stored in AssemblyInfo. cs.

You can register multiple instances.

3. Purpose

It allows us to do something out of web. config, such as registering custom IHttpModule, registering BuildProvider.

4. Note

The sequence of the application startup methods defined by the Assembly cannot be guaranteed. Therefore, each registration start method should write the code for separate operation, and should not depend on the side effects of other registration start methods. (From MSDN)

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.