27

I have created a C#-> Asp.Net Empty Web Application (Framework 4.0). I want to add few line of code in Global.asax on Application_Error section. But unfortuantely global.asax file is missing. How can i add that file? My visual studio version is 2012

Selva
  • 431
  • 2
  • 7
  • 13

3 Answers3

50

You can add a new file to the project of type Global Application Class

File -> New -> File -> Global Application Class

Alternately, you can create a new temporary project, which should generate a Global.asax file. Then just copy/paste that into your project.

trnelson
  • 2,715
  • 2
  • 24
  • 40
  • 1
    I just followed File -> New -> File -> Global Application Class and it created Global1.asax file then i have choosed "Moved Global1.asax to my project" option in file menu. But still i am not getting glboal1.asax.cs file? – Selva Oct 23 '14 at 19:43
  • @Selva did you already have a Global.asax file? Your question is worded in such a way that it seems that's what you need. Or do you just need the .cs file? – trnelson Oct 23 '14 at 19:50
  • 1
    Hmmmm! The Global.asax seems to be already on your project. I would close Visual Studio and reopen it. When adding Global.asax, it should shows at Global.asax, not Global1.asax. – Auguste Oct 23 '14 at 20:04
  • 3
    I noticed in VS2015 that you will not see the Global Application Class option if you already have a global.asax when choosing 'Add New Item > C# > Web'. I had the aspx w/o the .cs. I had to first delete the aspx, then re-add to get the .cs – puddleglum Mar 30 '17 at 16:29
11

You can also add it from project i.e. right click the project and add new item there you can find or search for Global Application Class template and add it.It's done.

Rakeshkumar Das
  • 135
  • 1
  • 5
0

Goto File->New->Project->web->Asp.Net Web Application->select Web form-click Ok. Now you are done; you see the Global Application file when you select web forms while creating a new project. Try this and let me know.

Jeroen Heier
  • 3,520
  • 15
  • 31
  • 32
shakeeb
  • 61
  • 1
  • 1