简体   繁体   中英

How can I configure my assembly in the Global.asax app start?

So 'hopefully' this should be an easy question for someone in the know...

I want to create a custom configuration for an assembly in the Global.asax app-start which will persist over all requests to the server.

For example how AutoMapper or Unity is configured on app start and persists for the live time of the application.

How is this data persisted in memory/application?

Thanks in advance...

You can use HttpContext.Application[] which is HttpApplicationState collection, it will persist the data between all of the requests to your application and during its lifetime.

protected void Application_Start()
{
   HttpContext.Application["global_data"] = "some data...";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM