Friday, July 25, 2008

Login Redirection

Try this:
in Login.aspx page
public static void RequestLogin()
{
string OriginalUrl = HttpContext.Current.Request.RawUrl;
string LoginPageUrl = "~/login.aspx";
HttpContext.Current.Response.Redirect(_String.Format("{0}?ReturnUrl={1}", LoginPageUrl, OriginalUrl));
}

protected void Login1_LoggedIn(object sender, EventArgs e)
{
TextBox TextBox1 = (TextBox)Login1.FindControl("UserName");
//MembershipUser user = Membership.GetUser(TextBox1.Text);
MembershipUser user = Membership.GetUser(Login1.UserName);
if (Request.QueryString["ReturnUrl"] != null)
{
Response.Redirect(Request.QueryString["ReturnUrl"].ToString());
}
else
{
//-- check if login user in Admin role
if (Roles.IsUserInRole(TextBox1.Text, "Admin"))
{
Response.Redirect("~/Admin/Default.aspx");

}
//-- check if login user in User role
else if (Roles.IsUserInRole(TextBox1.Text, "User"))
{
Response.Redirect("~/User/Default.aspx");
}
}
}

Good Luck

Logout

Try this code:
protected void lnkbLogout_Click(object sender, EventArgs e)
{
FormsAuthentication.SignOut(); Session.Abandon(); HttpContext.Current.Response.Redirect("Login.aspx", true);
}

//--- another way

protected void LoginStatus1_LoggedOut(object sender, EventArgs e)
{
//FormsAuthentication.SignOut();
//Roles.DeleteCookie();
//Session.Clear();
}

Make Icon of website in URL

Hi
visit these websites
http://www.html-kit.com/favicon/
http://www.alperguc.com/blog/html-tags/how-to-add-favicon-and-create-favicon-online/
http://www.tjitjing.com/blog/2006/10/how-to-create-favicon-in-visual-studio.html

Good Luck