kestrel-http-server

HttpRequest not aborted (cancelled) on browser abort in ASP.NET Core MVC

断了今生、忘了曾经 提交于 2019-11-30 08:41:20
I wrote the following MVC Controller to test cancellation functionality: class MyController : Controller { [HttpGet("api/CancelTest")] async Task<IActionResult> Get() { await Task.Delay(1000); CancellationToken token = HttpContext.RequestAborted; bool cancelled = token.IsCancellationRequested; logger.LogDebug(cancelled.ToString()); return Ok(); } } Say, I want to cancel the request, so the value ' true ' is logged in the controller action above. This is possible server-side if the server implements the IHttpRequestLifetimeFeature. Luckily Kestrel does, and this can be accomplished the

Can I set listen URLs in appsettings.json in ASP.net Core 2.0 Preview?

风格不统一 提交于 2019-11-30 06:59:38
I'm creating an ASP.net Core 2.0 app to run on the .net Core 2.0 runtime, both currently in their Preview versions. However, I cannot figure out how to have Kestrel use something other than the default http://localhost:5000 listen URL. Most documentation that I could Google talks about a server.urls setting, which seems to have been changed even in 1.0-preview to just be urls , however neither works (turning on Debug logging has Kestrel telling me that no listen endpoints are configured). A lot of documentation also talks about a hosting.json and that I can't use the default appsettings.json.

ASP .NET Core read environment variables

元气小坏坏 提交于 2019-11-30 02:39:56
Running my ASP.NET Core-app using dnx I was able to set environment variables from the command line and then run it like this: set ASPNET_ENV = Production dnx web Using the same approach in 1.0: set ASPNETCORE_ENVIRONMENT = Production dotnet run does not work - the app does not seem to be able to read environment variables. Console.WriteLine(Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")); returns null What am I missing? Your problem is spaces around = . This will work: Console.WriteLine(Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT ")); Or remove spaces (better, see

How to get a Console output in ASP.NET Core with IIS Express

本秂侑毒 提交于 2019-11-30 01:13:51
问题 ASP.Net Core documentation here has a nice console logging output like in the picture below with colors for various LogLevels. I have now created an application in Visual Studio and I see that it now runs behind IIS Express and I don't see the console anymore. I remember when I did run beta, then it did pop up Kestrel directly with this nice Console output. Is it possible to get this nice window now? P.S. It's a bit strange that the documentation still contains these images that you cannot

ASP.NET 5 Kestrel connect within LAN

不打扰是莪最后的温柔 提交于 2019-11-29 11:35:42
I would like to connect to my Kestrel server with ASP.NET 5 application hosted on it from another PC in the same network. Is it possible? I can ping my computer from cmd, but I get 'Connection timed out' when I try to connect from a web browser (I type this: "http://{my_kestrel_ip}:5000/"). In your project folder you should have a file called hosting.ini . In that file by default you should have something like this: server=Kestrel server.urls=http://localhost:5000 You need to make the HTTP server listen on your public IP address as well as localhost. To do that, you can add an additional

Why does aspnet core start on port 80 from within Docker?

无人久伴 提交于 2019-11-29 04:44:02
问题 TL;DR: Why does an aspnet core app run on port 80 from within a Docker image, but 5000 outside a docker image. Elaborate I went through the aspnet core / docker tutorial found here: https://docs.microsoft.com/en-us/dotnet/core/docker/building-net-docker-images Half way through the page, I start the application with the following as prescribed: dotnet run Among other things, this prints this: Now Listening on: http://localhost:5000 Great. That is what I expected. The next thing in the tutorial

Can I set listen URLs in appsettings.json in ASP.net Core 2.0 Preview?

送分小仙女□ 提交于 2019-11-29 02:52:18
问题 I'm creating an ASP.net Core 2.0 app to run on the .net Core 2.0 runtime, both currently in their Preview versions. However, I cannot figure out how to have Kestrel use something other than the default http://localhost:5000 listen URL. Most documentation that I could Google talks about a server.urls setting, which seems to have been changed even in 1.0-preview to just be urls , however neither works (turning on Debug logging has Kestrel telling me that no listen endpoints are configured). A

How to watch for file changes “dotnet watch” with Visual Studio ASP.NET Core

三世轮回 提交于 2019-11-29 01:23:24
I am using Visual Studio with ASP.NET Core and run the web site using just F5 or Ctrl+F5 (not using command line directly). I would like to use the "dotnet watch" functionality to make sure all changes are picked up on the fly to avoid starting the server again. It seems that with command line you would use "dotnet watch run" for this, but Visual Studio uses launchSettings.json and does it behind the scenes if I understand it correctly. How can I wire up "dotnet watch" there? Open launchSettings.json and add this to profiles . "Watch": { "executablePath": "C:\\Program Files\\dotnet\\dotnet.exe

Is it possible to run ASP.NET 5 site directly on Kestrel in Azure WebApps?

柔情痞子 提交于 2019-11-28 23:59:05
I have checked that in the web response the server is IIS when I deploy ASP.NET5 to azure web app, so I guess the IIS platform handler is used to redirect it to Kestrel. So I am wondering if it is possible to run directly on Kestrel, and what benefits/drawbacks will that have (probably regardless if it's in Azure or not). I suppose it will be a bit faster since IIS will be excluded from the pipline, but it should not be too much overhead I suppose... Maxime Rouiller On Azure Web App, you cannot bypass IIS. But in the general case, you can definitely run Kestrel directly. It is after all just

ASP .NET Core read environment variables

≯℡__Kan透↙ 提交于 2019-11-28 23:34:08
问题 Running my ASP.NET Core-app using dnx I was able to set environment variables from the command line and then run it like this: set ASPNET_ENV = Production dnx web Using the same approach in 1.0: set ASPNETCORE_ENVIRONMENT = Production dotnet run does not work - the app does not seem to be able to read environment variables. Console.WriteLine(Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")); returns null What am I missing? 回答1: Your problem is spaces around = . This will work: