Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
701 views
in Technique[技术] by (71.8m points)

asp.net mvc - MVC 6 with vNext: Do we still need the Global.asax?

I'm developing an application using MVC6. I noticed that the Global.asax file disappeared by default there is startup.cs file that calls the config. My question is how do I grab the Application_Start event method ?

Do I still need the Global.asax ? Why has it been removed by default ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Global.asax is only present when there is a reason to hook into it. The default MVC6 project has no hooks into it, therefore it doesn't provide one. Just add new item, global.asax

I should also suggest, that I would avoid creating a global.asax unless you need absolutely need it. People tend to reach for Application_Start or Session_Start first when there are probably better places to do what you need to do. Consider creating an OWIN module, or consider adding your own Startup module.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...