What namespace is it from, cause it shows me that User doesnt exist in the current context!
Here are my list of namespaces. Which one should i add:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Web.Configuration;
using System.Web.Security;
Another question, is that the way to check that the person who logged in is an administrator?
if (Roles.IsUserInRole(User.Identity.Name, "Administrators"))
{
If you are in a code library rather than the web page itself you need:
HttpContext.Current.User
You need the following namespace:
using System.Security.Principal;
The easiest way to check for roles is:
User.IsInRole("Administractor");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With