【发布时间】:2013-04-17 21:21:19
【问题描述】:
美好的一天!
我正在尝试从我的 .NET 4.0 (Visual Studio 2010) ASP.NET Web 应用程序中获取本地成员数据库设置。
我这样做:
1) 文件->新建->项目->“ASP.NET Web应用程序”
2) 编译应用程序。
3) 打开“ASP.NET 配置工具”,点击“安全”选项卡。
我明白了:
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: Could not load type 'WebApplication3.Global'.
这是我的 web.config 文件:
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="WebApplication3" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="WebApplication3"/>
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="WebApplication3" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="WebApplication3" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
我有点期待它开箱即用。我根据其他一些 stackoverflow 帖子(启用 roleManager 等)对 web.config 进行了一些更改。
我的 App_Data 目录中也没有 .mdf 文件。如果我尝试添加一个,我会得到:
我只想为我的身份验证信息使用专用的本地数据库。
有什么想法吗?
【问题讨论】:
-
你安装了SQLEXPRESS吗?
-
The following message may help in diagnosing the problem: Could not load type 'WebApplication3.Global'.听起来可能是加载 global.asax 文件时出现问题? -
RE: Petar - 不,我没有安装 SQLEXPRESS。需要运行吗?这是否意味着我也必须在生产服务器上运行它?我认为您可以只使用一个本地 MDF 来读取/写入数据。我正在寻找管理身份验证(登录控制等)的最简单方法,这看起来可能符合要求。
-
IIRC,你需要 SQLEXPRESS 来运行 mdf 文件。
-
您需要安装某种数据访问技术。它不必是 Sql Server Express。如果你只想要一个本地数据库,一个更好的选择可能是 Sql Server LocalDB(它仍然说 express,但它不是真的)msdn.microsoft.com/en-us/library/hh510202.aspx
标签: asp.net