Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

asp.net mvc - What is the new Startup.cs file for in Visual Studio 2013 projects?

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.

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

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

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

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.

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.

For more details:

OWIN

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

Global.asax

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...