Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Api Core hangs when start it on IIS Express in Visual Studio 2017?

I just updated Visual Studio to final version of 2017.
I'm working on a WebApi core project.

VS2017-WebApi

Whenever I start it with IIS Express, Google Chrome comes up and stay on loading in the following page without any responses

VS2017-WebApi-Chrome

What's wrong with it?
The problem on github

like image 336
Mohammad Dayyan Avatar asked Mar 13 '17 07:03

Mohammad Dayyan


People also ask

How do I run .NET core Web API in IIS Express?

Enable IIS on Server From your Windows Server , Open Server Manager, then IIS, then Manage and select 'Add Roles and Features', then go to features, then see if the Web IIS checkbox is enabled, if not, then proceed with installing it.

How do I enable IIS Express in Visual Studio 2017?

Select the ASP.NET Core project in Visual Studio Solution Explorer and click the Properties icon, or press Alt+Enter, or right-click and choose Properties. Select the Debug tab. In the Properties pane, next to Profile, For IIS Express, select IIS Express from the dropdown.

How do I use Visual Studio with IIS Express?

Configure IIS express on visual studioSelect the web application project and open properties -> select the web tab -> under server's select IIS express-> Specify the project URL. Now open the project folder and . vs folder (Hidden) -> Config -> applicationhost.


1 Answers

Enabling IISExpress on WebApi Core:

1. Enabling the IISIntegration components:
Install Microsoft.AspNetCore.Server.IISIntegration package.

2. Edit Program.cs in root of project:

 var host = new WebHostBuilder()
    .UseKestrel()
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseIISIntegration() // Add this line
    .UseStartup<Startup>()
    .Build();
like image 81
Smilefounder Avatar answered Sep 23 '22 18:09

Smilefounder