为什么没有对asp.net 5.0预览的身份验证-Web API模板- [英] Why is there no authentication for the asp.net 5.0 preview - web api template -

查看:48
本文介绍了为什么没有对asp.net 5.0预览的身份验证-Web API模板-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have created a web project in the new Visual Studio 2015.

我可以选择asp.net 4.6或5.0预览Web API模板.旧版4.6具有

I can choose asp.net 4.6 or 5.0 preview web api template. The old 4.6 has

身份验证,但我想同时使用新的5.0预览版Web API.

authentication but I want to use the new 5.0 preview also web api.

但是此模板缺少身份验证,但是为什么呢?

But this template lacks the authentication, but why?

推荐答案

在OWIN世界中,您可以在需要时提供所需的身份验证.他是ASP.NET 5世界的新范例."仅向您提供您明确要求的内容.如果您不要求它,您就不会得到它".这只是这种心态的另一个例子.

In the OWIN world you provide the Authentication you need when you need it. his is the new paradigm of the ASP.NET 5 world. "You are only provided what you explicitly say you need. If you don't ask for it, you don't get it". This is just another example of that mindset.

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

Scott Guthrie calls this out in his recent post:

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

ASP.NET 5 introduces a new HTTP request pipeline that is modular so you can add only the components that you need. The pipeline is also no longer dependent on System.Web. By reducing the overhead in the pipeline, your app can experience better throughput and a more tuned HTTP stack. The new pipeline is based on many of the learnings from the Katana project and also supports OWIN.

要自定义管道中使用的组件,请使用在您的启动类中配置方法.使用配置方法指定您要在请求中使用"哪个中间件管道.ASP.NET 5已经包含了许多Katana项目中的中间件,例如静态文件的中间件,身份验证和诊断.下图显示了一些您可以在项目管道中添加或删除的功能.

To customize which components are used in the pipeline, use the Configure method in your Startup class. The Configure method is used to specify which middleware you want to "use" in your request pipeline. ASP.NET 5 already includes ported versions of many of the middleware from the Katana project, like middleware for static files, authentication and diagnostics. The following image shows some of the features you can add or remove to the pipeline for your project.

您可以非常快速地插入安全保护;您只需要指定将要使用的内容即可.

You can plug in your security very quickly; you just need to specify what it is that you'll be using.

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

这篇关于为什么没有对asp.net 5.0预览的身份验证-Web API模板-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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