Visual Studio 2013 项目中的新 Startup.cs 文件是什么? [英] What is the new Startup.cs file for in Visual Studio 2013 projects?

查看:46
本文介绍了Visual Studio 2013 项目中的新 Startup.cs 文件是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了 Visual Studio 2013,创建了一个 MVC Web 应用程序项目,并注意到项目模板中有一个名为 Startup.cs 的新文件.

I have just installed Visual Studio 2013, created an MVC Web Application project and noticed a new file in the project template called Startup.cs.

这是什么,它与 Global.asax.cs 有什么不同,是否有关于如何使用它的最佳最佳实践?

What is this, how is this different from Global.asax.cs and are there any good best practices on what to use this for?

推荐答案

每个 OWIN 应用程序都有一个启动类,您可以在其中指定应用程序管道的组件.

Every OWIN application has a startup class where you specify components for the application pipeline.

如果您开始一个新的 Visual Studio 项目,您将在其中看到 OWIN 的片段.OWIN 是一个规范,它定义了框架和服务器协作的 API.OWIN 的重点是解耦服务器和应用程序.例如,ASP.NET Identity 使用 OWIN 安全,SignalR 自托管使用 OWIN 托管等,示例均使用 OWIN,因此它们都需要有一个启动类,在Startup.cs"文件中定义.

If you start a new Visual Studio project, you'll see pieces of OWIN in it. OWIN is a specification that defines an API for framework and servers to cooperation. The point of OWIN is to decouple server and application. For example, ASP.NET Identity uses OWIN security, SignalR self hosting uses OWIN hosting, and etc., the examples all use OWIN, therefore they all need to have a startup class, that is defined in "Startup.cs" file.

ASP.NET 应用程序文件 Global.asax 是一个可选文件,包含用于响应的代码到由 ASP.NET 或 HttpModules 引发的应用程序级事件.

The Global.asax, the ASP.NET application file, is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules.

欲知更多详情:

OWIN

http://www.asp.net/aspnet/overview/owin-and-katana

Global.asax

http://msdn.microsoft.com/en-us/图书馆/1xaas8a2(v=vs.71).aspx

您可以在以下文章中找到更多关于为什么 OWIN 的想法:

You can find more ideas about why OWIN in the following article:

http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana

这篇关于Visual Studio 2013 项目中的新 Startup.cs 文件是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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