Joel
Joel

Reputation: 8938

IIS Express/Kestrel hangs on OPTIONS request

I have a .NET Core 2.0 project, targeting the full .NET Framework:

<TargetFramework>net461</TargetFramework>
...
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />

Running on Windows 10, on localhost, using Visual Studio Community 2017 (15.7.4) with IIS Express (10.0.14358.1000).

Quite often an ajax request will get stuck on the OPTIONS request (see picture), blocking all subsequent requests (they also get stuck on OPTIONS (pending)).

This can happen on the first request, or in the middle of a debugging session that was fine up until then.

The only solution then is to stop debugging the project in VS, stop IIS Express and build the project again, then starting the debugger again.

I do not know how to debug this, or how to find out what is causing it. Is it VS, Kestrel, IIS Express, etc?

This is what it looks like in Chrome: enter image description here

This is what Program.cs looks like if that is of any help:

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

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

EDIT

These are request/response headers for a typical OPTIONS request (this one worked fine)

Request Headers

OPTIONS /api/items/2450 HTTP/1.1
Host: localhost:65164
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: http://localhost:5002
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Access-Control-Request-Headers: authorization,cache-control,pragma
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7,fr;q=0.6,it;q=0.5,la;q=0.4

Response Headers

HTTP/1.1 204 No Content
Server: Kestrel
Access-Control-Allow-Headers: authorization,cache-control,pragma
Access-Control-Allow-Origin: *
X-SourceFiles: =?UTF-8?B?QzpcRGV2ZWxvcG1lbnRcTm90aWZpZWRcc3JjXE5vdGlmaWVkLkFwaS5BZG1pblxhcGlcYWRtaW5cc291cmNlc1xhcnRpY2xlc1wyNDUw?=
X-Powered-By: ASP.NET
Date: Wed, 11 Jul 2018 12:47:55 GMT

Upvotes: 5

Views: 660

Answers (0)

Related Questions