繁体   English   中英

ASP.NET Core 2.0 IIS Web托管

[英]ASP.NET Core 2.0 IIS Web Hosting

我创建了一个ASP.NET Core 2.0 MVC Web应用程序,我需要帮助使其安装才能与Windows Server 2016上的IIS一起运行。

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

我将发布有关现有内容的Startup.cs和Program.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();
}

我遇到的问题终于解决了。 这与在SQL Server上添加到“安全性”的域上为我设置的帐户有关。 为该AD帐户提供正确的权限后,我将不再收到错误消息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM