【问题标题】:How to host the core project with IIS using mdf file如何使用 mdf 文件通过 IIS 托管核心项目
【发布时间】:2020-06-23 07:17:55
【问题描述】:

我尝试在 IIS 服务器中使用 mdf 文件托管核心项目。下面的 webconfig 文件在 localhost 中运行良好。但是当我将它发布到 IIS 时,出现 500-internal server error。

这是网络配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
   <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.entit, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="FileManagerConnection" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|App_Data\FileManager.mdf;Integrated Security=True;Connect Timeout=30" />
  </connectionStrings>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824"></requestLimits>
      </requestFiltering>
    </security>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" arguments="%LAUNCHER_ARGS%">
      <environmentVariables />
    </aspNetCore>
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

【问题讨论】:

  • 错误页面到底说了什么?

标签: asp.net-core iis mdf


【解决方案1】:

LocalDB 是 Visual Studio 提供的数据库实例。为了让它在 IIS 中正常工作,我们应该启动 Visual Studio 并将应用程序池标识更改为运行 Visual Studio 的特定帐户。但这不是常用的数据库发布方式,我们应该在当前项目中添加数据库迁移,以便我们将数据库发布到远程数据库服务器。
下面是从localdb 到远程 SQL 服务器的数据库迁移示例。
How to transfer ASP.NET MVC Database from LocalDb to SQL Server?
如果有什么可以帮助的,请随时告诉我。

【讨论】:

    【解决方案2】:

    .mdf 文件是 SQL Server 数据库文件。没有其他应用程序可以理解、读取或更新这些文件。所以,我已经在我的机器上安装了 SQL 服务器,然后在 IIS 中托管了核心项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-16
      • 1970-01-01
      • 1970-01-01
      • 2021-05-19
      • 2018-04-03
      相关资源
      最近更新 更多