ASP. NET Role Manager tutorial

Source: Internet
Author: User
Tags stack trace

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=" "          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 have not been enabled.", "Exception Type ":" System.Configuration.Provider.ProviderException "," StackTrace ":" at System.Web.Security.Roles.EnsureEnabled () \ r \ n @ 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 is thrown---\ r \ n at System.Runtime.CompilerServices.TaskAwaiter.Thro Wfornonsuccess (Task Task) \ r \ nT 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 is 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 System.Web.Http.Controllers.AuthenticationFilterResult.d__0.MoveNext () \ r \ n---End of stack trace from previous Location where exception is 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 was 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 would 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!

ASP. NET Role Manager tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.