MVC4: UserIsInRole - Unable to connect to SQL Server database

◇◆丶佛笑我妖孽 提交于 2019-11-28 18:54:39

Adding this:

[InitializeSimpleMembership]

To the top of the HomeController fixes the issue.

Explanation on the attribute:

http://blogs.msdn.com/b/rickandy/archive/2012/08/15/initializesimplemembership-attribute-and-simplemembership-exceptions.aspx

EvilDevil

For my use case, adding the following line in the web.config file fixed it!

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

I found that using UserManager.IsInRole(User.Identity.GetUserId(), "Admin") solved the problem for me. Cheers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!