【发布时间】:2010-06-14 15:58:08
【问题描述】:
将我的应用程序转移到 Windows 身份验证时遇到实际问题。
sql 错误消息与在 aspnetdb.mdf 文件中创建的问题有关。
我想知道是连接字符串有问题还是 web.config 的其他元素有问题
我在 IIS 中设置了 Windows 身份验证。
web.config:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|ASPNETDB.MDF;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="orderbaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\orderbase.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="windows">
</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="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear />
<add connectionStringName="ApplicationServices" applicationName="/"
name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
<add applicationName="/" name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
还有 sql 错误:
无法打开物理文件 “C:\inetpub\wwwroot\Ordering\App_Data\ASPNETDB_log.ldf”。 操作系统错误 5:“5(未能 检索此错误的文本。原因: 15105)"。遇到创建文件 操作系统错误 5(未能 检索此错误的文本。原因: 15105),而试图打开或 创建物理文件 'C:\inetpub\wwwroot\Ordering\App_Data\ASPNETDB_log.ldf'。 无法打开新数据库 'C:\INETPUB\WWWROOT\ORDERING\APP_DATA\ASPNETDB.MDF'。 CREATE DATABASE 已中止。一次尝试 附加一个自动命名的数据库 文件 C:\inetpub\wwwroot\Ordering\App_Data\ASPNETDB.MDF 失败的。同名数据库 存在,或指定的文件不能 已打开,或者它位于 UNC 共享上。 文件激活失败。物理的 文件名 "C:\inetpub\wwwroot\Ordering\App_Data\ASPNETDB_log.ldf" 可能不正确。
【问题讨论】:
标签: asp.net-mvc windows authentication