Where is global.asax.cs in Visual Studio 2010

naveen picture naveen · May 19, 2011 · Viewed 32.5k times · Source

I don't have a Global Application class code-behind any more inside my installed templates. All I have is Global.asax. I find more comfortable working with Global.asax.cs.

  1. Why am I not seeing it anymore?
  2. How to re-create Global.asax.cs?

Answer

Darin Dimitrov picture Darin Dimitrov · May 19, 2011

That's because you created a Web Site instead of a Web Application. I would recommend you using a precomipled Web Application model but if you need to use a Web Site you could do the following:

~/Global.asax:

<%@ Application CodeFile="Global.asax.cs" Inherits="AppName.MyApplication" Language="C#" %>

~/Global.asax.cs:

namespace AppName
{
    public partial class MyApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
        }
    }
}

Now reopen your site in VS.