我发布时无法运行MVC核心项目

时间:2018-06-12 23:04:31

标签: asp.net-mvc

我用SQL Server数据库创建了一个MVC核心项目(VS 2017)。我的项目在我的真实主机SQL Server的本地IIS中正常工作。但是当我将项目发布到真正的主机时,该项目不起作用。此外,我在真实主机中测试了一个简单的项目(带有数据库),它可以正常工作。我想连接字符串有问题。我该怎么做才能解决这个问题?我会很乐意为你提供帮助。 这是我的一些代码:

DataContext.cs

public class DataContext : IdentityDbContext<ApplicationUser>
{
    private static bool _Created = false;
    public DataContext()
    {
        if (!_Created)
        {
            _Created = true;
            Database.EnsureCreated();
        }
    }


    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {

        optionsBuilder.UseSqlServer("server = sheva.sepantahost.com;Persist Security Info = False; User ID = hbyby11847; Password = N*w23K+nd5; Initial Catalog = hbyby11847_sheva;  ");

    }

的Web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath=".\News_SourceIran.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

my project solution

1 个答案:

答案 0 :(得分:0)

应用程序将使用IIS网站正在使用的应用程序池的标识连接到数据库。在IIS管理器中,查看正在使用的帐户,并在该数据库中为该帐户授予适当的权限。

该例外还应包括尝试连接时使用的帐户。

相关问题