部署Mvc网站到本地IIS上-SQL Server DB 相关错误

晚上部署Mvc网站到local的IIS上面时,问题一个接一个的冒出来了。(Windows 8 操作系统)

>> HTTP Error 500.19 - Internal Server Error
配置错误: 不能在此路径中使用此配置节。如果在父级别上锁定了该节,便会出现这种情况。锁定是默认设置的(overrideModeDefault="Deny"),或者是通过包含 overrideMode="Deny" 或旧有的 allowOverride="false" 的位置标记明确设置的。

Solution: 从打开windows 功能那,Internet信息服务->万维网服务->应用程序开发功能->ASP.NET 4.5 选上。

>> Sql Server 数据库访问失败。

Debug模式下,我用的是Code First 的方式,程序自己创建的数据库,在C:UsersYoyo目录下的这个数据库文件,开始担心的是IIS不能访问,于是把数据库放在App_Data目录下,并修改web.config里的连接字符串,重新发布。事实上我现在还不确定,这个是否解决了问题。(自我鄙视一下)

>>继续 Sql Server 数据库访问失败。(这次我截图了)(怀疑其实是上一个问题并未解决)

发生了本地数据库运行时错误。 Cannot create an automatic instance.

打开Windows事件日志,看到了这样的错误信息:“Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.”

Solution:

在C:WindowsSystem32inetsrvconfig目录下,修改applicationHost.config文件,如下
<add name="ASP.NET v4.0" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated">
  <processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</add>

Reference link: Using LocalDB with Full IIS, Part 1: User Profile

完毕!

原文地址:https://www.cnblogs.com/yoyohappy/p/3593028.html