休息-FUL基本身份验证的ASP.NET MVC [英] Rest-ful Basic Authentication with ASP.NET MVC

查看:124
本文介绍了休息-FUL基本身份验证的ASP.NET MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道这是如何工作的,我使用了.NET成员资格提供程序,只是想拉一个XML列表。我还使用了.NET MVC SDK。因此,这里的问题,当我添加[WebApiEnabled]我的控制器顶部我可以成功地拉XML / JSON。但是,当我添加[授权]我控制器顶部我无法登录。作为一个例子卷曲-i -u管理员:通-H接受:应用程序/ XML的http://本地主机%3Axxxx /书籍

Anyone know how this works, I'm using the .net membership provider and just want to pull an xml list. I'm also using the .net mvc sdk. So here's the problem when I add the [WebApiEnabled] at the top of my controller I can successfully pull xml/json. But when I add [Authenticate] to the top of my controller I cannot login. As an example curl -i -u "admin:pass" -H "Accept: application/xml" http://localhost%3Axxxx/Book

在此先感谢您的帮助。

推荐答案

我想我会在这里添加此的人(像我)谁是不太能够环绕答案这里提供的笔者自己的头。这里有一个博客帖子我只是描述了如何使用可以使用方式与 [授权]同一个 [CustomBasicAuthorize] 属性做到这一点属性随MVC:<一href=\"http://cacheandquery.com/blog/2011/03/customizing-asp-net-mvc-basic-authentication/\">http://cacheandquery.com/blog/2011/03/customizing-asp-net-mvc-basic-authentication/

I thought I'd add this here for anyone (like me) who isn't quite able to wrap their head around the answer the author provided here. Here's a blog post I just did describing how to accomplish this with a [CustomBasicAuthorize] attribute that can be used the same way as the [Authorize] attribute that comes with MVC: http://cacheandquery.com/blog/2011/03/customizing-asp-net-mvc-basic-authentication/

这篇关于休息-FUL基本身份验证的ASP.NET MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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