简体   繁体   中英

ASP.NET Core 2.0 IIS Web Hosting

I created an ASP.NET Core 2.0 MVC Web Application and I need help getting it setup to run with IIS on Windows Server 2016.

So far, I have followed and completed all the steps on https://docs.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x up to the section Application configuration . This is the step that I'm stuck at and have not been able to complete the steps below it.

I'm going to post my Startup.cs and Program.cs code as to what I have now. I'm not sure if those two files need modified.

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();
}

The issue that I was having I finally figured it out. It had to do with the account that was setup for me on the Domain that was added to the Security on the SQL Server. Once I provided the correct permissions to that AD account I no longer received the error messages.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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