Asp.net MVC 身份验证 身份验证如何工作
也许我的问题很疯狂。
1)ASP.net MVC是无状态的,所以这里不涉及会话。
身份验证模块如何工作,您是否有任何文章可以指导我了解身份验证基础知识。
认证信息存储在哪些地方。
【MVC新手】
May be my question is crazy.
1) ASP.net MVC is stateless, so there is no session involved in here.
How does the authentication module work and do you have any articles which you can point me to understand the Authentication basics.
What are the authentication information stored in.
[Novice MVC]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
网络是无状态的。 ASP.NET 和 ASP.NET MVC 都有创建应用程序状态的机制。 MVC 的拥护者喜欢它为开发人员提供了比 Web 窗体更多的控制方式来管理状态以及请求如何影响托管状态。 Web 窗体使用
ViewState
封装状态,这不是 MVC 的一部分。 MVC 模式允许您在更精细的级别上控制每个操作(包括管理应用程序状态)。这可能是您了解到 MVC 是无状态的想法的地方。顺便说一下,您应该倾向于使用
TempDataDictionary
而不是HttpSessionState
来存储状态相关数据,因为 TempDataProvider 的默认实现是的包装器>HttpSessionState
)。模式有点不同,但可以在 http://www.gregshackles.com/2010/07/asp-net-mvc-do-you-know-where-your-tempdata-is/ASP.NET(和 MVC)身份验证通常通过利用表单身份验证。它可以在您的
web.config
中进行配置。 ASP.NET 身份验证配置。如果您的客户端浏览器支持 cookie,则默认行为是将您的身份验证票证存储在 cookie 中。
The web is stateless. Both ASP.NET and ASP.NET MVC have mechanisms for creating an application state. Advocates of MVC like that it provides the developer with more control over how state is managed and how requests affect the managed state than Web Forms. Web Forms encapsulates state with
ViewState
which is not part of MVC. The MVC pattern allows you to control every action (including managing the application state) on a much more granular level. This is probably where you got the idea that MVC is stateless.As a side note, you should favor using the
TempDataDictionary
overHttpSessionState
for storing state-related data, because the default implementation the TempDataProvider is a wrapper of theHttpSessionState
). The pattern is a little different but a good article can be found at http://www.gregshackles.com/2010/07/asp-net-mvc-do-you-know-where-your-tempdata-is/ASP.NET (and MVC) authentication usually works by leveraging Forms Authentication. It can be configured in your
web.config
. ASP.NET Authentication Configuration.If your client's browser supports cookies, the default behavior is for your authentication ticket to be stored in a cookie.
谁告诉你 ASP.net MVC 是无状态的?无论如何,身份验证信息通常存储在加密的 cookie 中。在这方面它与网络表单完全相同。
关于 ASP.NET MVC的更新
,请参阅此处以了解更多信息以帮助您入门: http://www.asp.net/mvc
对于 ASP.NET 表单身份验证,请参阅 MSDN
Who told you ASP.net MVC was stateless? In any case, authentication info is usually stored in an encrypted cookie. It's exactly the same as webforms in this regard.
UPDATE
Regarding ASP.NET MVC, see here for plenty to get you started: http://www.asp.net/mvc
For ASP.NET forms authentication, see MSDN
从技术上讲,如果您在每个请求中都发送 HTTP 标头授权,那么您可能会变成无状态。
Technically, you could go stateless if you sent HTTP header authorization with every request.