日期:2014-05-20  浏览次数:20504 次

[怪]登陆问题~
Login.cs

using   System.Web.Security;
--登陆的确定键
private   void   Button1_Click(object   sender,   System.EventArgs   e)
{
      string   username=TextBox1.Text;
string   password=TextBox2.Text;


NewPublishService.Service1   bs=new   MyNewsPublish.NewPublishService.Service1();
if(bs.IsUserLogin(username,password))
       

{    
FormsAuthentication.RedirectFromLoginPage(TextBox1.Text,false);
Response.Redirect( "loginok.aspx ");
}
else
{
Response.Redirect( "serviceERROR.aspx ");

}

}


Loginok.cs

public   class   loginok   :   System.Web.UI.Page
{
protected   System.Web.UI.WebControls.Label   Label2;
protected   System.Web.UI.WebControls.Label   Label1;

public   string   username
{

get
{return   User.Identity.Name;}
}


跟踪时发现~~Loginok.cs里的username的值是 " "~没有内容~而FormsAuthentication.RedirectFromLoginPage(TextBox1.Text,false)里,TextBox1.Text已经获取我的用户名了~


我以前都是这样执行USERNAME的登陆验证的~这次却不知出了啥问题~

------解决方案--------------------
参考:
http://support.microsoft.com/kb/301240/zh-cn