MVC 6 vNext:我们还需要在Global.asax? [英] MVC 6 with vNext: Do we still need the Global.asax?

查看:96
本文介绍了MVC 6 vNext:我们还需要在Global.asax?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用MVC6的应用程序。
我注意到,在默认情况下消失的Global.asax 文件有是调用配置 startup.cs 文件。我的问题是我怎么抢的Application_Start 事件的方法?

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 ?

我还需要在的Global.asax
为什么会被默认删除?

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

推荐答案

Global.asax中只有present时,有一个理由去连接它。默认MVC6项目没有挂钩到它,因此它不会提供一个。只需添加新的项目,Global.asax中

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

我也建议,我会避免创建Global.asax的,除非你需要绝对需要它。人们往往当有可能会更好地做你需要做什么来达到的Application_Start或在session_start第一。考虑创建一个OWIN模块,或考虑加入自己的启动模块。

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.

这篇关于MVC 6 vNext:我们还需要在Global.asax?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆