Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add global.asax file to ASP.NET MVC4 project?

In my project the Global.asax file is removed. I want add a global.asax file to my projet.
But in Add New Item dialog the Global.asax not exist.

like image 572
Samiey Mehdi Avatar asked Jan 25 '14 05:01

Samiey Mehdi


People also ask

How do I add a global asax file?

How to add global. asax file: Select Website >>Add New Item (or Project >> Add New Item if you're using the Visual Studio web project model) and choose the Global Application Class template. After you have added the global.

Where do I put global asax?

The Global. asax, also known as the ASP.NET application file, is located in the root directory of an ASP.NET application.

Where is global asax in ASP.NET core?

There is no global. asax file in . NET Core and most of the things that we were doing in global.


2 Answers

Just in case you may have missed the item even though it may actually be there for you I'll post this answer.

In Visual Studio 2013

  1. Open Solution Explorer.
  2. Right-click on the project.
  3. Add New Item.
  4. VB or C#
  5. Web.
  6. General.
  7. Global Application Class.
like image 199
Michael Socha Avatar answered Sep 18 '22 22:09

Michael Socha


  1. Create an empty new project.
  2. Go to that folder and copy the Global.asax file.
  3. Go to your project and in solution explorer paste it on root.
  4. Open Global.asax file and change namespace match to your namespace.
  5. In solution explorer right click on Global.asax and pick View Markup and change inherits match to your namespace.
like image 42
Samiey Mehdi Avatar answered Sep 18 '22 22:09

Samiey Mehdi