Reputation: 49
I've got a page to submit data into a database and I want to either re-direct them to a different page if they arent logged in OR disable the submit button at the bottom. I'm doing this in my page load event of the page to be denied access.
I've researched and found this in many spots but what exactly am I placing into Session["???"] I'm using the login/register feature provided by asp.net Web Forms
protected void Page_Load(object sender, EventArgs e)
{
if (Session[] == null)
{
Response.Redirect("~/Default.aspx");
}
}
Upvotes: 0
Views: 88
Reputation: 77926
You want to check if the user who made that page requested is authenticated or not. You can do that by checking User
property of Request
object like Request.User.IsAuthenticated
If(!Request.User.IsAuthenticated)
Response.Redirect("~/Default.aspx");
Upvotes: 1
Reputation: 2736
You can use HttpContext.Current.User.Identity.IsAuthenticated
to check if there is authenticated user or not
Upvotes: 1