User.IsInRole()MVC中的C#类工作 [英] User.IsInRole() work in MVC C# class

查看:123
本文介绍了User.IsInRole()MVC中的C#类工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

    If(User.IsInRole("member"))
    {

    }

但无法得到它在C#中的MVC类工作。请注意,我不是在一个控制器,我能够得到的工作使用。我在想什么?在code甚至不承认是用户。

but not able to get it to work in C# MVC class. Note that I am not using it in a controller which I am able to get working. What am I missing? The code does not even recognize what User is.

我觉得这可能是一个命名空间,但我已经使用了 .Mvc 命名空间以及其他。

I think it may be a namespace but I have used the .Mvc namespace as well as other..

感谢您提前

推荐答案

使用 HttpContext.Current.User 而不是

这篇关于User.IsInRole()MVC中的C#类工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆