用于iPhone应用程序的ASP.NET MVC身份验证

时间:2021-05-21 03:36:22

This is for an ASP.NET MVC application. For browser based access on my normal controllers, I'm using standard forms authentication and auth cookies.

这适用于ASP.NET MVC应用程序。对于普通控制器上基于浏览器的访问,我使用标准表单身份验证和身份验证cookie。

My question is how I do the same for an iPhone application. I have a set of RESTful controllers that the iPhone application uses directly, but I'm not sure how to go about authentication...

我的问题是我如何为iPhone应用程序做同样的事情。我有一套iPhone应用程序直接使用的RESTful控制器,但我不确定如何进行身份验证......

I was thinking of having a special Login method that returns the auth cookie. Then I can use the standard Authentication attribute on the ASP.NET MVC side, but I'm not sure how to handle this on the iPhone side? Can I store this cookie and have it automatically sent with every request?

我想有一个特殊的Login方法返回auth cookie。然后我可以在ASP.NET MVC端使用标准的Authentication属性,但我不确定如何在iPhone端处理这个问题?我可以存储此cookie并随每次请求自动发送吗?

Perhaps there's a better approach altogether?

也许有一个更好的方法?

1 个解决方案

#1


1  

If it is RESTful you can use an NSURLConnection and send your server the appropriate HTTP headers the API requires.

如果它是RESTful,您可以使用NSURLConnection并向服务器发送API所需的相应HTTP头。

http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

#1


1  

If it is RESTful you can use an NSURLConnection and send your server the appropriate HTTP headers the API requires.

如果它是RESTful,您可以使用NSURLConnection并向服务器发送API所需的相应HTTP头。

http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html