简体   繁体   中英

MVC .Net web app - Combine web.config and global.asax - or deploy without web.config

I have a MVC .NET application. I thought I could deploy just web.config in the root folder. And of course also all the sub directories like VIEWS, etc. Oops. As soon as I copied the global.asax, it worked.

Is it possible to combine the web.config and the global.asax ? Then I can only have a web.config in the root directory.

Or, set up IIS differently ? I am using IIS 7.5

Is there ea way ?

Thanks

I'm not sure why you want to do that, but here is some explanation with the hope it will help you in your decision:

web.config and the global.asax are completely two different things and have completely different rolls in ASP.Net applications.

web.config , as the name suggests, provides the necessary configurations for the application. It is required for the application to run.

global.asax provides events to control the application (eg application_start , application_end , session_start , etc). It is not strictly required, so you don't have to include it unless you need the functionality. MVC projects tend to have some code in global.asax , but it does not need to be that way. Depending on you application's needs, you may be able to move all the code in global.asax to somewhere else and then remove the file completely.

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