2

I have tried to host the core project with mdf file in the IIS server. The below webconfig file works fine in the localhost. But when I publish it to IIS, I got a 500-internal server error.

This is the webconfig:

<?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>
Bhuvana
  • 21
  • 2

2 Answers2

0

LocalDB is a database instance provided by the Visual studio. In order to make it work in IIS properly, we should start the Visual Studio and change the application pool identity to the specific account that running the Visual studio. But this is not a common way to publish the database, we should add database immigration to the current project so that we publish the database to the remote database server.
Here is an example of database immigration from localdb to a remote SQL server.
How to transfer ASP.NET MVC Database from LocalDb to SQL Server?
Feel free to let me know if there is anything I can help with.

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22
0

The .mdf files are SQL Server database files. No other application can understand, read, or update those files. So, I have installed the SQL server in my machine and then host the core project in IIS.

Bhuvana
  • 21
  • 2