If you want to have signin as different user functionality like sharepoint in your asp.net application, following workaround you might be looking for.
After setting your web.config file's
<authentication mode="Windows" />
and in IIS after remove anonymous authentication and enable windows authentication, have following code snippet where you want to have this functionality
In your aspx page
<div>You are logged in as <br /> <%=User.Identity.Name%> <br /><br />
<asp:LinkButton ID="lnkSignOut" runat="server" Text="Sign in as different user" onclick="lnkSignOut_Click"></asp:LinkButton>
In your code behind file
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
Session["logOutRequested"] = false; //Initialize value. This will be set to true when user will click on sign in as differnet user
}
}
protected void lnkSignOut_Click(object sender, EventArgs e)
{
if (null != Session["logOutRequested"] && !Convert.ToBoolean(Session["logOutRequested"])) // Check if user is clicking link first time
{
Session["logOutRequested"] = true; //Set value that user want to sign in as differnet user
Response.StatusCode = 401;
Response.StatusDescription = "Unauthorized";
Response.End();
}
else
{
Session["logOutRequested"] = false; //Initialize value again after user is authenticated with differnet or same user again.
}
}
Hope this workaround will help.
In case if above workaround is not working, you may try following one
www.roelvanlisdonk.nl/?p=825