where is the codes in Global.asax in mvc3?

2019-09-21 05:00发布

问题:

i create a default project in mvc3 and published it on my host ,what about codes in file: Global.asax after publishing there is a one line code in it: where is the codes?

<%@ Application Codebehind="Global.asax.cs" Inherits="MvcApplication1.MvcApplication"  Language="C#" %>

回答1:

The code is in Global.asax.cs. In Visual Studio if you you look next to the Global.asax file in your object explorer, there will be a down arrow. If you click that you should see the Global.asax.cs file. And just like any other file in VS, you can double-click that and it should open up that file containing your code.



回答2:

ASP.NET MVC uses web application mode as default vs web site. A web application is a compiled mode. This means that when you ship all source code is stripped away and compiled into assemblies. So you deploy only assemblies (int the bin folder) and views. So the Global.asax.cs file that you have in design time is simply compiled into the bin/YouAppName.dll assembly and it is referenced from the Global.asax markup file.