Asp.net Role manager tutorial

It is very useful in .net we can user framework provided role manager, and easily configure in Web.Config.

However, I find when I fullfil such configure:

    <roleManager defaultProvider="QQmgsSqlProvider"
          enabled="true"
          cacheRolesInCookie="true"
          cookieName=".ASPROLES"
          cookieTimeout="30"
          cookiePath="/"
          cookieRequireSSL="true"
          cookieSlidingExpiration="true"
          cookieProtection="All" >
      <providers>
        <add
          name="QQmgsSqlProvider"
          type="System.Web.Security.SqlRoleProvider"
          connectionStringName="TwitterDbContext"
          applicationName="Twitter" />
      </providers>
    </roleManager>

  

When I send the Http request, I find the error:

{
  "Message": "An error has occurred.",
  "ExceptionMessage": "The Role Manager feature has not been enabled.",
  "ExceptionType": "System.Configuration.Provider.ProviderException",
  "StackTrace": " at System.Web.Security.Roles.EnsureEnabled()\r\n at Twitter.App.Controllers.APIControllers.PingController.Get() in C:\\Users\\Administrator\\Downloads\\Twitter-master\\Twitter-master\\QQmgs.App\\Controllers\\APIControllers\\PingController.cs:line 19\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.AuthenticationFilterResult.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"
}

  

So, after my investigation, I find there‘s one more thing I should do.

"It looks like your membership database is missing some required procedures required for the membership system.

You need to run VS command prompt and type this command "aspnet_regsql.exe" and link it to your database. This command will populate your database with all required database objects for the membership system."

refer to: https://forums.asp.net/t/2048614.aspx?Could+not+find+stored+procedure+dbo+aspnet_CheckSchemaVersion+

After I follow the instruction below, I find in my database there‘s some new tables like: "aspnet_Roles, aspnet_Membership".

Then I resend the Http request to test, succeeded !

时间: 2024-08-07 16:58:37

Asp.net Role manager tutorial的相关文章

JSON Web Token in ASP.NET Web API 2 using Owin

In the previous post Decouple OWIN Authorization Server from Resource Server we saw how we can separate the Authorization Server and the Resource Server by unifying the "decryptionKey" and "validationKey" key values in machineKey node

【ASP.NET Identity系列教程(二)】运用ASP.NET Identity

注:本文是[ASP.NET Identity系列教程]的第二篇.本系列教程详细.完整.深入地介绍了微软的ASP.NET Identity技术,描述了如何运用ASP.NET Identity实现应用程序的用户管理,以及实现应用程序的认证与授权等相关技术,译者希望本系列教程能成为掌握ASP.NET Identity技术的一份完整而有价值的资料.读者若是能够按照文章的描述,一边阅读.一边实践.一边理解,定能有意想不到的巨大收获!希望本系列博文能够得到广大园友的高度推荐. 14 Applying ASP

asp.net的10个提升性能或扩展性的秘密(一) 转自网络

简介 Asp.net有很多值得你挖掘的“秘密”,当你发现了它们,将会给你网站的性能和可扩展性带来巨大提升!例如,对于Membership以及Profile提供程序有一些秘密的瓶颈,它们很容易被解决,从而使认证和授权更加快速.另外,asp.net的http管线可以为每一个请求作处理,防止执行了某些不必要的代码而遭受攻击.不只是这些,asp.net工作进程能够突破默认限制,从而完全发挥它的威力.在浏览器端(不是在服务器端)的页面分段输出缓存能显著减少由于请求访问所需要占用的大量下载时间.在需要的用户

ASP.Net网站管理工具配置

笔者想使用ASP.NET Web 应用程序管理工具来添加身份验证. 点击项目->asp.net配置打开了ASP.Net网站管理工具页面: 然后点击security选项卡,出现如下问题: There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be

Oracle DCL(Data Control Language)数据控制语言(权限privilege,角色role,用户user介绍)

1.如何控制用户访问 1.身份验证,认证:Authentication 2.授权:Authorization 3.审计:Audit 2.权限 数据库安全: -系统安全 -数据安全 系统权限:数据库中执行一个特定操作 对象权限:操纵数据库的对象的内容 可用的系统权限有100多个 数据库管理员有高层次的系统权限,可以完成 -创建一个新用户 -删除用户 -删除表 -备份表 3.创建用户 DBA使用CREATE USER语句创建用户 CREATE USER user identified BY pass

DevExpress v15.1:ASP.NET WebForms功能增强(三)

下载最新版DevExpress ASP.NET Controls v15.1.5 ASP.NET HTML Editor 占位符(邮件合并) 占位符允许最终用户创建文本模板,这些占位符可以被替换为所需的值(从数据库). 标签检查器(文档结构路径导航)和所选的标签属性编辑器 新的标签检查器允许最终用户浏览一个标签层次结构.删除标签,并使用标签属性编辑器自定义标签属性. 内容元素过滤 DevExpress HTML Editor现在允许您过滤内容元素,您可以指定标签.属性和样式属性的过滤规则. 增强

[转]ASP.NET Web API对OData的支持

http://www.cnblogs.com/shanyou/archive/2013/06/11/3131583.html 在SOA的世界中,最重要的一个概念就是契约(contract).在云计算的世界中,有关通信的最重要的概念也是契约.XML具有强大对数据的描述能力,Atom格式和AtomPub都建立在XML之上,在Google和微软的推动下,也已经成为标准.但是,Atom/AtomPub和ODBC/OLEDB这样的真正数据交互协议相比较,还有着根本上的欠缺:缺乏数据类型的具体描述,降低了交

ASP.NET Web API对OData的支持

小分享:我有几张阿里云优惠券,用券购买或者升级阿里云相应产品最多可以优惠五折!领券地址:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=ohmepe03 在SOA的世界中,最重要的一个概念就是契约(contract).在云计算的世界中,有关通信的最重要的概念也是契约.XML具有强大对数据的描述能力,Atom格式和AtomPub都建立在XML之上,在Google和微软的推动下,也已经成为标准.但是

Asp.net 面向接口可扩展框架之业务规则引擎扩展模块

随着面向接口可扩展框架的继续开发,有些功能开发出现了"瓶颈",有太多的东西要写死才好做.但写死的代码扩展性是非常的不好,迷茫中寻找出入... 进而想到我以前开发的好几个项目,都已有一定的可配置能力,想想怎么把这些地方的代码抽象提取出来.进而想到"业务规则引擎",网上找了几个都不太入"眼",就抽时间再造个"轮子" 业务规则引擎在很多成熟的工作流引擎中都有相应的模块,是工作流的核心之一.但是除了工作流很多业务都需要业务规则引擎,所