Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Cannot debug in Visual Studio after changing the port number?

$
0
0

I added the line `.UseUrls("http://*:5000")` to enable clients from other hosts accessing the web api.

        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .UseUrls("http://*:5000") // Added
                .Build();

            host.Run();
        }

However, using browser to access `localhost:5000/api/Test` got the error of `HTTP/1.1 400 Bad Request`? Should the `.UseUrls()` be only compiled for production?

<pre>
HTTP/1.1 400 Bad Request
Date: Mon, 08 Aug 2016 21:42:30 GMT
Content-Length: 0
Server: Kestrel
</pre>

The following messages are copied from Visual studio Output window when testing.

> Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:5000/api/Test

> Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware:Error: 'MS-ASPNETCORE-TOKEN' does not match the expected pairing token '9bca37f2-7eda-4517-9f8f-60b6cc05cf01', request rejected.

> Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 8.5976ms 400


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>