Domanda

What's the right process to use ASP.NET Web Site Administration Tool? I want to use this tool to configure roles and membership.

Steps that I tried:

  1. Create MVC web application.
  2. Run aspnet_regsql to create related database. The command tool is suggested by error messaage below. Although I realize the Role, Membership table has been created since project creation.
  3. Modify web.config of new webapplication:

    <system.web>
    <roleManager enabled="true" defaultProvider="simple">
    <providers>
        <clear/>
        <add name="simple" type="WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData"/>
    </providers>
    </roleManager>
    
    <membership defaultProvider="simple">
    <providers>
    <clear/>
    <add name="simple" type="WebMatrix.WebData.SimpleMembershipProvider,WebMatrix.WebData"/>
    </providers>
    </membership>
    ...
    ...
    <add name="DefaultConnection" connectionString="Data Source=(localdb)\.\IIS_DB;InitialCatalog=aspnet-DemoWebApplication-20130625124639;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnet-DemoWebApplication-20130625124639.mdf" providerName="System.Data.SqlClient" />
    

Error message seen on the tool page: 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 caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

The following message may help in diagnosing the problem: You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site.

Can you help? Please let me know if you need more information.

I've investigate this issue for hours, found below helpful threads, but still does not fix it completely:

  1. Web Site Administration Tool ERRORS
  2. Web Site Administration Tool Not Working with ASP.NET MVC
È stato utile?

Soluzione 2

It turns out the SimpleMembership come with MVC 4 doesn't work with Web site admin tool. People use WebSecutiry API instead.

To use Web Site Admin Tool with MVC 4/VS 2012, you can either:

  1. Work with MVC 3 application,
  2. Work with MVC 4 application, Basic template With these two options, people don't need to modify web.config, don't need to select providers. It just works.

Remember to build the web application before use web site admin tool.

I was referring to this blog: http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx

Altri suggerimenti

It sounds like the connection string in your Asp.net app is not correct.

You can script those queries in the database directly if you need to.

Check your web.Config file and make sure all of your connections in there are correct. Are you using the simple membership? Or the Asp.net tables?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top