开发者

what is the issue with User.Identity.Name

开发者 https://www.devze.com 2023-03-08 03:03 出处:网络
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:

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");
0

精彩评论

暂无评论...
验证码 换一张
取 消