快要疯了,请高手指点比较急!开发环境为vs2012
1.我用的是windows身份验证 代码如下,登陆页的.cs代码如下 protected void Sub_Click( object sender, EventArgs e)
{
if (TextBox_Name.Text == string.Empty || TextBox_Pwd.Text == string.Empty)
{
Response.Write("<script>alert('You don't enter username or password, please input it!');</script>");
return;
} string ldapPath = "LDAP://" + GetDomainName();
string domainAndUsername = Environment.UserDomainName + "\\" + TextBox_Name.Text;
DirectoryEntry entry = new DirectoryEntry(ldapPath, domainAndUsername, TextBox_Pwd.Text); DirectorySearcher search = new DirectorySearcher(entry); try
{
SearchResult result = search.FindOne();
// Response.Write("<script>alert('login successful');</script>");
Session["UserID"] = TextBox_Name.Text.Trim();
Response.Redirect("index.aspx"); }
catch (Exception ex)
{
Response.Write("<script>alert('login failed, please confirm username and password!');</script>");
Response.Write("<script>document.location=document.location;</script>");
} }登陆后访问其它页时发现:(其它页Page_load()中1.Request.IsAuthenticated返回的一直是false,并且HttpContext.Current.User.Identity.Name也为空,取不到用户名。2.改用Session["UserID"] == null方法确定是否用户通过验证发现这个方法在IE上是正常的,但是在sougo上是不正常的。另在sougo发现,当第一次访问该网页的时候不登陆是不能直接进入其它页的,当第一次登陆成功退出以后再进入的时候就不需要登陆页面就可以直接访问其它页。然后在vs2012中clean solution后 再次访问就的通过登陆后才能进入其它页,就是登陆成功退出后一直需要clean solution后才能正常)请高手指点,或推荐相关的参考资料!
1.我用的是windows身份验证 代码如下,登陆页的.cs代码如下 protected void Sub_Click( object sender, EventArgs e)
{
if (TextBox_Name.Text == string.Empty || TextBox_Pwd.Text == string.Empty)
{
Response.Write("<script>alert('You don't enter username or password, please input it!');</script>");
return;
} string ldapPath = "LDAP://" + GetDomainName();
string domainAndUsername = Environment.UserDomainName + "\\" + TextBox_Name.Text;
DirectoryEntry entry = new DirectoryEntry(ldapPath, domainAndUsername, TextBox_Pwd.Text); DirectorySearcher search = new DirectorySearcher(entry); try
{
SearchResult result = search.FindOne();
// Response.Write("<script>alert('login successful');</script>");
Session["UserID"] = TextBox_Name.Text.Trim();
Response.Redirect("index.aspx"); }
catch (Exception ex)
{
Response.Write("<script>alert('login failed, please confirm username and password!');</script>");
Response.Write("<script>document.location=document.location;</script>");
} }登陆后访问其它页时发现:(其它页Page_load()中1.Request.IsAuthenticated返回的一直是false,并且HttpContext.Current.User.Identity.Name也为空,取不到用户名。2.改用Session["UserID"] == null方法确定是否用户通过验证发现这个方法在IE上是正常的,但是在sougo上是不正常的。另在sougo发现,当第一次访问该网页的时候不登陆是不能直接进入其它页的,当第一次登陆成功退出以后再进入的时候就不需要登陆页面就可以直接访问其它页。然后在vs2012中clean solution后 再次访问就的通过登陆后才能进入其它页,就是登陆成功退出后一直需要clean solution后才能正常)请高手指点,或推荐相关的参考资料!
解决方案 »
- 有人用过Spacebuilder吗?
- 每次一上传新程序到web后,.net就把网站上用户session信息都给清空了,有没有办法不让.net重启啊!
- dropdownlist如何同时绑定2个表
- 一个关于javascript的问题?
- 关于批量生成新闻的问题
- 请问..ASP.NET如何实现调色盘功能
- 能在Internet上架设SharePoint网站吗?
- 请问怎么处理页面的提交数组啊,比如同时删除多条选中(checkbox)的记录?谢谢!在线结贴
- 查询过程中有两个以上的SELECT语句怎么做?
- 如何把一个DATAGRID和一个DATATABLE绑定起来?
- 点击网站下级链接出现“没有足够的权限对Access数据库进行操作”
- 关于服务器的备份问题
你确认登录成功后,并没有对于该用户的Authenticate做任何设置。我认为,应该有类似于HttpContext.Current.IsAuthencitae = true, HttpContext.Current.User = new User{}之类的代码。代码细节可能不是这样,但大致思路是这样。2.你退出后能够不经登录就能进入其他页,可能的原因有,sesssion没有清理干净,或者sAuthencitae没有设置为false,或者有cookie什么的。