Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

User name is blank in Login Page

subhasamsubhasam Posts: 11Member
Hi all,

Iam using form authentication in my web app. After user login i want to redirect depends on user info.
My problem is :

User.Identity.name is blank in login page but its working fine in other page.

Forms Authentication in web.config file



private

void btnlogin_Click(object sender, System.EventArgs e)
{ if(checking User credentials)


{ Id=somevalue;
FormsAuthentication.SetAuthCookie(Id.ToString(),false);

Response.Write(User.Identity.Name.ToString());

//Response.Write(Context.User.Identity.Name.ToString());

}
}

Thanks in advance

Comments

  • iwilld0itiwilld0it Posts: 1,134Member
    Well believe in this code ID.ToString() is going to be the eventual value of User.Context.Name, so can at that point redirect based on ID.ToString

    : Hi all,
    :
    : Iam using form authentication in my web app. After user login i want to redirect depends on user info.
    : My problem is :
    :
    : User.Identity.name is blank in login page but its working fine in other page.
    :
    : Forms Authentication in web.config file
    :
    :
    :
    : private
    :
    : void btnlogin_Click(object sender, System.EventArgs e)
    : { if(checking User credentials)
    :
    :
    : { Id=somevalue;
    : FormsAuthentication.SetAuthCookie(Id.ToString(),false);
    :
    : Response.Write(User.Identity.Name.ToString());
    :
    : //Response.Write(Context.User.Identity.Name.ToString());
    :
    : }
    : }
    :
    : Thanks in advance
    :

  • subhasamsubhasam Posts: 11Member
    Hi ,

    Thanks . But whether its possible to use User.Identity.... in Login Page?
    I no in Asp.net 2.0 U can do it with membership..
    Iam using asp.net 1.1 , so i want to no in that...



    : Well believe in this code ID.ToString() is going to be the eventual value of User.Context.Name, so can at that point redirect based on ID.ToString
    :
    : : Hi all,
    : :
    : : Iam using form authentication in my web app. After user login i want to redirect depends on user info.
    : : My problem is :
    : :
    : : User.Identity.name is blank in login page but its working fine in other page.
    : :
    : : Forms Authentication in web.config file
    : :
    : :
    : :
    : : private
    : :
    : : void btnlogin_Click(object sender, System.EventArgs e)
    : : { if(checking User credentials)
    : :
    : :
    : : { Id=somevalue;
    : : FormsAuthentication.SetAuthCookie(Id.ToString(),false);
    : :
    : : Response.Write(User.Identity.Name.ToString());
    : :
    : : //Response.Write(Context.User.Identity.Name.ToString());
    : :
    : : }
    : : }
    : :
    : : Thanks in advance
    : :
    :
    :

  • sapnasapna Posts: 3Member
    Hi ,

    I want ome ecurity in asp.

    In which i want any asp page could't open directly






    : Hi ,
    :
    : Thanks . But whether its possible to use User.Identity.... in Login Page?
    : I no in Asp.net 2.0 U can do it with membership..
    : Iam using asp.net 1.1 , so i want to no in that...
    :
    :
    :
    : : Well believe in this code ID.ToString() is going to be the eventual value of User.Context.Name, so can at that point redirect based on ID.ToString
    : :
    : : : Hi all,
    : : :
    : : : Iam using form authentication in my web app. After user login i want to redirect depends on user info.
    : : : My problem is :
    : : :
    : : : User.Identity.name is blank in login page but its working fine in other page.
    : : :
    : : : Forms Authentication in web.config file
    : : :
    : : :
    : : :
    : : : private
    : : :
    : : : void btnlogin_Click(object sender, System.EventArgs e)
    : : : { if(checking User credentials)
    : : :
    : : :
    : : : { Id=somevalue;
    : : : FormsAuthentication.SetAuthCookie(Id.ToString(),false);
    : : :
    : : : Response.Write(User.Identity.Name.ToString());
    : : :
    : : : //Response.Write(Context.User.Identity.Name.ToString());
    : : :
    : : : }
    : : : }
    : : :
    : : : Thanks in advance
    : : :
    : :
    : :
    :
    :

Sign In or Register to comment.