简体   繁体   English

如何从MVC中的SQL Server完整版中获取角色?

[英]How to get roles from SQL Server full version in MVC?

I am trying to get user role using @if (User.IsInRole("intern")) , but the problem is that I am doing this directly on SQL Server 2012 Full Version and this is throwing me following exception: 我正在尝试使用@if (User.IsInRole("intern"))来获得用户角色,但问题是我直接在SQL Server 2012完整版上执行了此操作,这引发了以下异常:

The user instance login flag is not supported on this version of SQL Server. The connection will be closed.

I know that database creation from code is only supported in SQL Server Express editions and I also don't have User Instance attribute in my connection string. 我知道仅在SQL Server Express版本中支持从代码创建数据库,而且我的连接字符串中也没有User Instance属性。

How to get roles on full SQL Server version? 如何在完整的SQL Server版本上获得角色? Will this work on my production? 这对我的作品有用吗?

Try editing your machine.config and then your appSettings : 尝试编辑您的machine.config ,然后编辑appSettings

Machine.config : Machine.config

<configuration>
    ....
    <system.web>
        ...
        <membership>
            <providers>
                <clear/>
            </providers>
        </membership>
        <roleManager enabled="false" />
    </system.web>
</configuration>

appSettings : appSettings

<appSettings> 
    <add key="enableSimpleMembership" value="false" /> 
</appSettings>

follow this chat for more. 按照此聊天了解更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM