Yuo
Yuo

Reputation: 31

How do I use Global.asax files in ASP.NET applications?

How do I use a Global.asax file in my ASP.NET code?

Is there some kind of include statement, sort of like <script type="text/javascript" src='xxx.js'></script>?

Upvotes: 2

Views: 2310

Answers (2)

Chains
Chains

Reputation: 13167

It's a file. It goes in your application folder (the same folder your asp.net files go in.)

You'll use Global.asax for asp.NET, and Global.asa for classic ASP.

Right-click your project folder, add new item, pick global.asax from the options, and you're there.

(Which is to say, you don't have to make a reference to it in your .aspx pages like you do for javascript or css, etc. The events that global.asax handles are global (hence the name...), not page-specific.)

Upvotes: 2

kprobst
kprobst

Reputation: 16651

You mean global.asax right? Just add it to your project. The code you put in there will be picked up by the ASP runtime and executed as expected.

Upvotes: 4

Related Questions