加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

entity-framework – 在MVC 5项目上使用ASP.NET Identity但httpc

发布时间:2020-12-16 07:35:14 所属栏目:asp.Net 来源:网络整理
导读:我有一个使用ASP.NET身份(Invidual用户帐户)的MVC 5项目.作为数据库ORM,我正在使用实体框架6和IoC由Ninject处理. 解决方案结构如下 MVC项目 – 有我的控制器,视图和ninject设置.对于Ninject,我从nuget获得了Ninject.MVC3. 数据项目 —有我的DataContext(Iden
我有一个使用ASP.NET身份(Invidual用户帐户)的MVC 5项目.作为数据库ORM,我正在使用实体框架6和IoC由Ninject处理.

解决方案结构如下

> MVC项目
– 有我的控制器,视图和ninject设置.对于Ninject,我从nuget获得了Ninject.MVC3.
>数据项目
—有我的DataContext(IdentityDbContext)和我的ApplicationUser(IdentityUser).我的
数据服务和所有存储库
>核心项目
– 拥有我的所有实体和接口

[授权]属性工作正常,我必须登录才能访问注释动作,但是当我设置[授权(角色=“管理员”)]我得到

Could not find stored procedure ‘dbo.aspnet_CheckSchemaVersion’.

我创建了我的CustomAuthorize attibute,它基本上是Authorize的副本,并注意到了
受保护的虚拟bool中的httpcontext AuthorizeCore(HttpContextBase httpContext)User.ProviderName是“AspNetSqlRoleProvider”.

所以我在我的web.config中添加了Rolemanages clear.这导致了

Configuration Error Description: An error occurred during the
processing of a configuration file required to service this request.
Please review the specific error details below and modify your
configuration file appropriately.

Parser Error Message: Default Role Provider could not be found.

Source Error:

Line 53: –> Line 54: Line 55: Line
56: Line 57:

Source File:
…myprojectWebUIweb.config
Line: 55

那么这笔交易是什么?如何设置默认角色提供程序以使用ASP.NET标识?

解决方法

所以在我发布问题之后我就找到了答案.我不得不补充一下

 <system.webServer>
    <modules>
...
      <remove name="RoleManager" />
    </modules>
  </system.webServer>

这样做了.但是还有一个问题是为什么?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读