bmanmike39
asked on
How would I make a static class in ASP.NET webforms that redirects the User to a specific page if member is not active? (c#)
I can't figure out how to turn the following code into a static class for use in all my pages.
This is the code in my class:
Can't figure out how to get the user.Identity.Name to work.
var valDRecord = oe.account_profiles.Where(y => y.membership_number == User.Identity.Name).First();
if (valDRecord.active == false)
{
Response.Redirect("profileUpdate.aspx");
}
This is the code in my class:
Can't figure out how to get the user.Identity.Name to work.
public class notActive
{
public static void redirect()
{
AMEMEntities2 h = new AMEMEntities2();
var valDRecord = h.account_profiles.Where(y => y.membership_number == User.Identity.Name).First();
if (valDRecord.active == false)
{
HttpContext.Current.Response.Redirect("profileUpdate.aspx");
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
Just what I was looking for.
Just what I was looking for.
Is the value coming back as blank? What authentication are you working with? If you are using Forms Authentication, you would need a different approach.