asp.net登录问题 [英] asp.net Login problem

查看:71
本文介绍了asp.net登录问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在我的网站(asp.net C#)中遇到登录问题.
当我使用loginid和密码登录时,登录成功.

我已经编写了用于在登录时检查和验证用户身份的代码,但是注销后会出现问题.
在单击注销链接时,我会将用户重定向到登录页面或其他任何页面,但是当我按浏览器的后退按钮时,将重新打开同一页面,即注销之前的页面.

请帮帮我.

我为此使用了会话和cookie,但是(会话已过期,cookie被销毁了)
问题仍然存在.

我看到很多网站(asp.net)也有相同的问题,例如160by2.com可以查看此网站.


请对此提供帮助.
致谢.

Hi,

I am facing a problem with login in my website (asp.net C#).
When I login using loginid and password the login is successful.

I have written the code to check and authenticate a user while logging in, but the problem occurs after logout.
On clicking logout link I redirect the user to login page, or whatsoever, but when I press back button of browser then the same page is reopened i.e. page before logout.

Please help me.

I used session and cookies for this but (session is expired and cookies are destroyed)
The problem remains.

I see lots of websites(asp.net) they also have the same problem, like 160by2.com you can check this website.


Please help me regarding this.
Thanks & Regards.

推荐答案

手动滚动ASP.NET安全性是一项非常复杂的任务,而不仅仅是在每个页面中放置一些代码(或超类),如您所知,这种方法非常脆弱.
有用的是,该框架具有用于处理身份验证和授权的良好ASP.NET基础结构:基础知识在这里:
http://www.asp.net/security/tutorials/security- basics-and-asp-net-support-cs [ ^ ],成员资格和角色提供者具有特殊的兴趣. [ [ ^ ]和 [
Hand-rolling ASP.NET security is a pretty complicated task, and isn''t just a matter of putting some code in each page (or a superclass), this methodolgy is pretty brittle, as you have found out.
Helpfully, the framework has a good ASP.NET infrastructure for handling Authentication and Authorisation: The basics are here:
http://www.asp.net/security/tutorials/security-basics-and-asp-net-support-cs[^], the Membership and Role Providers are of special intrest. This[^] and this[^] and this[^] should be enough to get you started :-)


如果您使用表单身份验证
If you are using forms authentication
// Page load event of Logout.aspx
FormsAuthentication.SignOut();
Response.Redirect("Default.aspx");


类似的讨论
此处 [


Similar discussion here[^]


嗨 您可以在 Global.asax 文件中设置以下代码
Hi You can set following code in your Global.asax file
void Session_Start(object sender, EventArgs e)
  {
    // Code that runs when a new session is started
      if (Session["UserID"] == null)
      {
          Response.Redirect("Login.aspx?Message=Please login...");
      }



}


如有任何疑问,请让我知道.

请提供"投票":thumbsup:如果有帮助,请提供"接受答案",如果这是正确的答案.:rose:

谢谢,
Imdadhusen



}


Please do let me know, if you have any doubt.

Please provide "Vote":thumbsup: if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen


这篇关于asp.net登录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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