Mystery of Global.asax in ASP.NET MVC application

I was doing the deployment of the multiple ASP.NET MVC websites and I was stump with new finding

One website which I had just published has Global.ascx

image

and other didn’t

image

If you compare, if doesn’t have ‘Global.asax’, but had ‘PrecompiledApp.config’. This seems to be mystery for me. What role does ‘Global.asax’ play in MVC application, as there is no code behind (‘Global.asax.cs’) published with it

Plus, more mystical, what’s ‘PrecompiledApp.config’ and where it comes from?

I was suspecting, you don’t need ‘Global.asax’, unless you have written code in it. Most of us do write event binding code in ‘Global.asax.cs’. This code behind files bakes into dll, and I was right! I got the answer, after goggling and found this

Another mystery of  ‘PrecompiledApp.config’ came from precompiled setting in Visual Studio Publish wizard.

SNAGHTML61bc725

If you select this, it will precompile all aspx, ascx, asax into dll, and you don’t need those files here. But, what Visual Studio put aspx and ascx file in publish folder, even through you chose precompiled option,  so if you want to do quick fix for HTML CSS change on any page, you can instead of deploying entire website for this small change.

‘PrecompiledApp.config’, which says, whether this website is updateable or not. If you change HTML CSS, it would be tracked by ASP.NET worker process and would be reflect on the site. But, without this file, MVC app would work, but HTML CSS in aspx, ascx won’t be track and get reflect on website

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s