无法连接到数据库上的ASP.NET Web站点管理工具 [英] Could not connect to database on ASP.NET Web Site Administration Tool

查看:141
本文介绍了无法连接到数据库上的ASP.NET Web站点管理工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是使用ASP.NET网站管理工具正确的流程?我想用这个工具来配置角色和成员。

步骤,我试图:


  1. 创建MVC Web应用程序。

  2. 运行aspnet_regsql建立相关的数据库。该命令工具是由下面的错误messaage建议。虽然我认识的作用,成员表已经自创建项目创建的。

  3. 修改新的web应用的web.config文件:

     <&的System.Web GT;
    < roleManager启用=真正的defaultProvider =简单>
    <供应商>
        <清/>
        <添加名称=简单类型=WebMatrix.WebData.SimpleRoleProvider,WebMatrix.WebData/>
    < /供应商>
    < / roleManager><会员defaultProvider =简单>
    <供应商>
    <清/>
    <添加名称=简单类型=WebMatrix.WebData.SimpleMembershipProvider,WebMatrix.WebData/>
    < /供应商>
    < /会员>
    ...
    ...
    <添加名称=DefaultConnection的connectionString =数据源=(的LocalDB)\\ \\ IIS_DB; InitialCatalog = ASPNET-DemoWebApplication-20130625124639;集成安全性= SSPI; AttachDBFilename = | DataDirectory目录| ASPNET-DemoWebApplication-20130625124639.mdf的providerName = System.Data.SqlClient的/>


见过的工具页上的错误信息:
没有您选择的数据存储问题。这可以通过一个无效的服务器的名称或凭证,或经许可不足引起的。它也可以通过不使能角色管理器功能而引起的。点击下面的按钮被重定向到一个页面,您可以选择一个新的数据存储。

下面的消息可能会有助于诊断问题:你必须调用WebSecurity.InitializeDatabaseConnection的方法,你所说的WebSecurity类的任何其他方法之前。此调用应放置在一个_AppStart.cshtml文件在您的网站的根目录。

你能帮忙吗?请让我知道如果你需要更多的信息。

我已经研究这个问题了几个小时,发现下面有帮助的线程,但仍不能完全解决这个问题:


  1. 网站管理工具错误

  2. Web网站管理工具不可与ASP.NET MVC
  3. 工作

解决方案

原来,SimpleMembership配备了MVC 4不与网站管理员工具的工作。人们使用WebSecutiry API来代替。

要使用Web站点管理工具与MVC 4 / VS 2012年,您可以:


  1. 与MVC 3应用程序正常工作,

  2. 与MVC 4应用工作,基本模板
    有了这两个选项,人们并不需要修改web.config文件,也不需要来选择供应商。这只是工作。

记住要建立使用前网站管理工具的Web应用程序。

我指的是这个博客:<一href=\"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\" rel=\"nofollow\">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

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

解决方案

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

这篇关于无法连接到数据库上的ASP.NET Web站点管理工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆