|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
namespace RIATasks.Web
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LogOut();
}
}
#region ddlUser_SelectedIndexChanged
protected void ddlUser_SelectedIndexChanged(object sender, EventArgs e)
{
int intSelectedUser = Convert.ToInt32(ddlUser.SelectedValue);
if (intSelectedUser > 0)
{
LogUserIntoSite(Convert.ToInt32(ddlUser.SelectedValue));
}
else
{
LogOut();
}
}
#endregion
#region LogUserIn
private void LogUserIntoSite(int intUser)
{
// Log the user into the site
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
intUser.ToString(),
DateTime.Now,
DateTime.Now.AddDays(30),
false,
"Role One",
FormsAuthentication.FormsCookiePath);
// Encrypt the ticket.
string encTicket = FormsAuthentication.Encrypt(ticket);
// Create the cookie.
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
// Show the Silverlight control
silverlightControlHost.Visible = true;
}
#endregion
#region LogOut
protected void LogOut()
{
FormsAuthentication.SignOut();
// Hide the Silverlight control
silverlightControlHost.Visible = false;
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.