为什么没有对asp.net 5.0预览进行身份验证 - web api模板 -

Pas*_*cal 5 c# asp.net visual-studio-2015

我在新的Visual Studio 2015中创建了一个Web项目.

我可以选择asp.net 4.6或5.0预览web api模板.旧4.6有

身份验证,但我想使用新的5.0预览也web http://www.i.

但是这个模板缺乏身份验证,但为什么呢?

Dav*_*d L 2

在 OWIN 世界中,您可以在需要时提供所需的身份验证。这是 ASP.NET 5 世界的新范例。“你只会得到你明确表示需要的东西。如果你不要求,你就不会得到它”。这只是这种心态的另一个例子。

\n

Scott Guthrie 在他最近的帖子中指出了这一点:

\n
\n

ASP.NET 5 引入了一个新的模块化 HTTP 请求管道,\n因此您可以仅添加所需的组件。该管道也不再依赖于 System.Web。通过减少管道中的开销,您的应用可以体验到更好的吞吐量和更优化的 HTTP 堆栈。新管道基于 Katana 项目的许多经验教训,并且还支持 OWIN。

\n

若要自定义在管道中使用哪些组件,请使用 Startup 类中的\nConfigure 方法。配置方法用于指定\n您想要在请求管道中使用\xe2\x80\x9cuse\xe2\x80\x9d 的中间件。ASP.NET 5 已经包含 Katana 项目中的许多中间件的移植版本,例如静态文件、身份验证和诊断的中间件。下图显示了\n您可以在项目管道中添加或删除的一些功能。

\n
\n

您可以非常快速地插入安全性;您只需要指定您将使用的是什么。

\n
public void Configure(IApplicationBuilder app)\n{\n    // Add static files to the request pipeline.\n    app.UseStaticFiles();\n \n    // Add cookie-based authentication to the request pipeline.\n    app.UseIdentity();\n \n    // Add MVC and routing to the request pipeline.\n    app.UseMvc(routes =>\n    {\n    routes.MapRoute(\n        name: "default",\n        template: "{controller}/{action}/{id?}",\n        defaults: new { controller = "Home", action = "Index" });\n \n});\n
Run Code Online (Sandbox Code Playgroud)\n