【问题标题】:ASP.NET Core 2.0 IIS Web HostingASP.NET Core 2.0 IIS 虚拟主机
【发布时间】:2017-10-05 19:40:43
【问题描述】:

我创建了一个 ASP.NET Core 2.0 MVC Web 应用程序,我需要帮助设置它以在 Windows Server 2016 上与 IIS 一起运行。

到目前为止,我已经按照并完成了https://docs.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x 上的所有步骤,直到应用程序配置部分。这是我卡住的步骤,无法完成下面的步骤。

我将发布我现在拥有的 Startup.cs 和 Program.cs 代码。我不确定这两个文件是否需要修改。

Startup.cs

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddDbContext<WinTenDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
        services.AddMvc();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseBrowserLink();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        app.UseStaticFiles();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }
}

Program.cs

public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .Build();
}

【问题讨论】:

  • 你还在纠结什么?为什么您无法完成这些步骤?
  • @KirkLarkin,我不确定还需要完成什么。如何将 Visual Studio 中的项目发布到 IIS?是否需要修改 Startup.cs 和 Program.cs 文件?
  • 您不需要对这些文件中的任何一个进行任何更改。您链接的发布指南中的步骤应该是您所需要的。 Stack Overflow 是针对特定问题/问题的,所以我鼓励你添加更多关于你在哪里挣扎的信息。
  • @KirkLarkin,当我使用 IIS 选项使用 Visual Studio 发布时,这是我得到的错误。我收到 65 个其他错误,例如 "C:\Users\jdoe\source\repos\WinTenUpgradeSchedule\WinTenUpgradeSchedule\obj\Release\netcoreapp2.0\PubTmp\Out\wwwroot\lib\bootstrap\dist\fonts\glyphicons- halflings-regular.woff" 到 "C:\inetpub\wwwroot\WinTenUpgradeSchedule\wwwroot\lib\bootstrap\dist\fonts\glyphicons-halflings-regular.woff"。拒绝访问路径“C:\inetpub\wwwroot\WinTenUpgradeSchedule\wwwroot\lib\bootstrap\dist\fonts”
  • 您是否尝试过以管理员身份运行 Visual Studio?您可能无权写信给C:\inetpub\wwwroot...

标签: c# asp.net-core-2.0 iis-10


【解决方案1】:

我遇到的问题终于弄明白了。它与在域上为我设置的帐户有关,该域已添加到 SQL Server 上的安全性中。一旦我为该 AD 帐户提供了正确的权限,我就不再收到错误消息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多