what is the issue with User.Identity.Name
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 que开发者_如何学JAVAstion, 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");
精彩评论