- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我似乎找不到这个看似简单的问题的答案。
使用第一个或后者有什么区别?为什么我要使用第一个?
在 MSDNAA 上,我发现以下有关 Formsauthentication.setCookie() 的内容:
Creates an authentication ticket for the supplied user name and adds it to the cookies collection of the response, or to the URL if you are using cookieless authentication.
关于 session :
ASP.NET session state enables you to store and retrieve values for a user as the user navigates the different ASP.NET pages that make up a Web application. HTTP is a stateless protocol, meaning that your Web server treats each HTTP request for a page as an independent request; by default, the server retains no knowledge of variable values used during previous requests. As a result, building Web applications that need to maintain some cross-request state information (applications that implement shopping carts, data scrolling, and so on) can be a challenge. ASP.NET session state identifies requests received from the same browser during a limited period of time as a session, and provides the ability to persist variable values for the duration of that session.
我特别感兴趣的是,当我使用 session cookie 检查用户是否正确登录时,为什么要使用 formsauthentication.SetAuthCookie。例如:
if(Session["LoggedIn"] != null) {
...Do something here that only logged in users are allowed to do...
}
最佳答案
看来我在 asp.net 网站上找到了答案:
关于cookies - Formsauthentication.SetAuthCookie 和 Session 的区别用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14156995/
问题一: setAuthCookie 是否比 FormsAuthentication.Encrypt(ticketVariable) 更不安全? 我的意思是,如果有人试图通过修改用户名来修改 setA
在一个配置了 FormsAuthentication 的应用程序中,当用户在没有授权 cookie 或过时的 cookie 的情况下访问 protected 页面时,ASP.NET 发出 HTTP 4
我的 Formsauthentication 和我的 ajax 调用有问题。我喜欢 Formsauthenticaction 适用于普通 asp.net 网站的方式。 但是我的 asp.net 网站中
所以我有一个登录页面,我在其中设置了自己的 cookie 和 FormsAuthenticationTicket。但是,当我最终选择登录后将用户重定向到新主页时,它拒绝了。它只是无缘无故地重定向回登录
第一季度我读过,在设置身份验证 cookie 的超时时,我们应该记住,cookie 持续的时间越长,cookie 被盗用和滥用的可能性就越大。 A) 但是假设我们通过为整个应用程序启用 SSL 来保护
我有一个 asp.net 应用程序,我正在使用 FormsAuthantication。当用户关闭页面时,位于 Global.asax Session_End 中的代码被执行:FormsAuthant
标题应该说明了一切。 这是设置cookie的代码: // snip - some other code to create custom ticket var httpCookie = new Htt
我以为要等好几年,没想到一小时内就通关了。 最佳答案 根据Explained: Forms Authentication in ASP.NET 2.0 , "默认值为 30 分钟":
我很难弄清楚这一点。我正在使用表单例份验证。当用户登录并检查记住我时,我希望用户保持登录状态 24 小时。问题是,无论我做什么,用户都会在 30 分钟后自动注销。我们用户选择记住我,我设置了一个持久
我的 ASP.NET MVC Web 应用程序允许管理员更改自己或其他用户的用户名。 用户通过调用 FormsAuthentication.SetAuthCookie(userName [string
升级到 .Net 4.5 后,我现在收到“System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile 已过时”
所以,我在 Controller 中有代码: FormsAuthentication.SetAuthCookie("hello", true);throw new Exception("" + Use
如果我调用 FormsAuthentication.SetAuthCookie("john", true),用户名是否存储在 cookie 中? 我想知道的是,如果用户 session 超时然后用户再
我是 ASP.Net 的新手。请解释我需要添加的内容。我在登录前单击此页面,通过“FormsAuthentication.RedirectToLoginPage();”将用户带到登录页面。但是在 Pa
我遇到以下问题:重新发布 ASP.NET Web 应用程序会导致(如预期的那样) session 重置,我保留了额外的用户信息(访问尝试会导致 NullReferenceException)。 为了避
在 ASP.NET MVC3 Controller 操作中,我想注销用户并返回 401 状态代码。代码很简单: public ActionResult Index() { FormsAuthenti
在 SignOut() 调用重定向到“...login.aspx?ReturnUrl=%2fmydomainname%2flogout.aspx”之后使用此方法,这样用户就无法再次登录,因为成功登录会
我目前在 ASP.Net 身份验证方面遇到了一个奇怪的问题。考虑以下两行: MembershipCreateStatus ct = new MembershipCreateStatus(); Memb
我正在开发一个带有安全部分的网站,即名为“PIP”的文件夹。 登录部分工作正常,但当我点击注销时,用户仍然是已知的,如果他/她接触安全部分,则不会被重定向到登录页面。 这是我的 web.config:
您好,我正在对我的 ASP.Net MVC2 项目进行一些单元测试。我正在使用最小起订量框架。在我的 LogOnController 中, [HttpPost] public ActionResult
我是一名优秀的程序员,十分优秀!