ASP.NET core fails on with - asp.net-core

I try to do a performance test on my asp.net core 1.0.1 website. I use loader.io to get 4000 client's to load the website but I get an error on asp.net core. If I run the same code in asp.net 4.6 it runs error on same server. Can anybody tell my why I can't handle same load on my asp.net core site like my asp.net 4.6?
Error:
502 - Web server received an invalid response while acting as a
gateway or proxy server.
There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
ASP.NET 4.6: https://thusan.tinytake.com/sf/MTA4Mzg1OF80MzMzNzMz
ASP.NET core: https://thusan.tinytake.com/sf/MTA4Mzg1OV80MzMzNzM0
I'm running both sites from IIS on a Windows 2012 r2.

In ASP.NET 4, IIS hosts the web site in its own process. ASP.NET Core changed this. ASP.NET Core web sites execute as a separate process and IIS uses the ASP.NET Core Module to reverse proxy requests to the ASP.NET Core process. The error you are seeing could be caused by many problems, such as a setup errors or hung requests in the ASP.NET Core process.
If all requests fail, it is probably a setup error. Follow this document to make sure guide you have completed all steps to deploy an ASP.NET Core app to IIS. https://docs.asp.net/en/latest/publishing/iis.html.
If the ASP.NET Core site works for a few requests but fails under stress, checkout some of these recommendations for improving performance. https://github.com/aspnet/IISIntegration/issues/245#issuecomment-242541999

Related

kestrel in asp.net core

let's say you have multiple applications on a server. Is there is 1 kestrel instance handling multiple applications request or will there different kestrel instances handling different asp.net core web applications?
Can anybody provide me any links or a post where i can find out how a request travels from the client to server for ASP.NET core applications. see this SO post without an answer. The Relationship of Kestrel server and Program.cs in ASP.NET Core request processing
Kestrel is a cross-platform web server for ASP.NET Core. Kestrel is the web server that's included and enabled by default in ASP.NET Core project templates. For the http request process, you could check this article:
So, from the above document, we can see that each Asp.net core application will have their own Kestrel server to host the application. And, by default when using Kestrel, ASP.NET Core binds to: http://localhost:5000 and https://localhost:5001, if there have multiple applications, you should set them use different port or endpoint. Reference: Configure endpoints for the ASP.NET Core Kestrel web server.

Can I run .Net 4.6 Application under .Net Core Site on IIS

I inherited a project that is a collection of WCF Services that target .Net Framework 4.6.1. I wrote a front end SPA application that targets .Net Core 2.2 not realizing that the hosting model was such that both the UI (.Net Core) and the API (.Net 4.6.1) need to run under one Site on IIS.
I'm trying to get this to work on my local machine. I created a new Site in IIS -- Site A. I published my .Net Core application to Site A and set it up with an application pool set to "No Manged Code".
I then added an Application to Site A called API and added all my WCF services in that folder. I configured API to use an application pool that targets ".NET CLR 4.0".
I updated the web.config in the root of Site A to include all the necessary bits for WCF.
I'm able to hit Site A and get my SPA UI, but when I do anything that attempts to hit the backend API (including trying to hit it directly -- http://localhost:464646/api/test.svc), I get the following error:
HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure
Is what I'm doing even possible? If so, what changes do I need to make in order to get this to work?

ASP.NET Core 3 Web Is Not Able To Connect ASP.Net Core 3 Web API on same server

I have a web application that has built on ASP.NET CORE 3. This web application uses asp.net core 3 web api. Everything works fine. But problem starts when I move them to the staging server. Web Application was not able to connect web api. They both hosted on same machine but have different port.
For example :
Web Application URL http://52.X.X.X:94/MyWeb
Web API URL http://52.X.X.X:91/MyWebAPI
I get following error
System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I have enabled CORS in web API.
However, If I move Web Api to Port 80 (http://52.X.X.X:80/MyWebApi ) then everything is working.
On my local IIS they both are working.On local IIS they were published on same port ( 94 and 91 respectively)
Can anyone tell what I am missing?
do you have appropriate web.config on server? compare local web.config with server web.config. maybe you missed some part like kestler or something else.
if it's alright, then check your webapi with postman, maybe webapi didn't published correctly.

Running ASP.NET Core within/alongside an existing ASP.NET WebForms project in Visual Studio and IIS Express

I have a large Visual Studio solution with several ASP.NET web sites with a mix of WebForms, MVC and WebAPI. What I'd like to be able to do is add an ASP.NET Core project to this solution to provide MVC, Razor Pages, WebAPI and SPA (Vue.JS in this case) facilities. The plan is to take each WebForms page at a time and convert to the new framework.
I'll target .NET Framework and the Core site will share some assemblies from the WebForms - but no state is shared except a session cookie and any state stored in the database.
I specifically want to be able to serve the new framework from IIS Express on the same port. So for example, an old page such as http://localhost:1234/page1.aspx will be converted to http://localhost:1234/core/page1. However, I'm unable to simply change the Core project to be hosted on IIS Express and change the path to http://localhost:1234/core. I have managed by following instructions to host in IIS but this has several disadvantages for development. I've also tried adding <urlRewrite> configuration to the WebForms site to forward requests to Core running on a different port but I wasn't very successful and I believe POST request are not supported which renders it fairly useless!

.NET Core Hosting Bundle

As far as I understood the Docs, the .NET Core Hosting Bundle installs the .NET Core Runtime, .NET Core Library and the ASP.NET Core Module.
It seems that there's a Bundle for every version of the .NET Core Runtime (2.0.6, 2.0.7, ...).
If I have a self contained deployment of my app, I still need the ASP.NET Core Module. However I don't see that the Module can be downloaded separately without the full bundle. Is there a place where I can download it ?
If not:
What's the point of having a self contained application, if I still need to install the whole .net core sdk/runtime bundle on my IIS Server?
There is no official download of the ASP.NET Core Module for IIS ("ANCM"), though it can be installed by calling the hosting bundle installer with OPT_INSTALL_LTS_REDIST=0 OPT_INSTALL_FTS_REDIST=0 as arguments (at least for 1.0-2.0 installs).
What's the point of having a self contained application, if I still
need to install the whole .net core sdk/runtime bundle on my IIS
Server?
Apart from the installer being able to install only ANCM, do not forget that IIS is not the only hosting option for ASP.NET Core Applications. People may still opt to host it on linux or as a Windows Service. Either being exposed to the public Internet (which is supported from 2.0+) or behind NGINX/Apache/…
It is also very useful to deploy preview, daily or custom builds of any component inside .NET Core / ASP.NET Core if needed.
Check the docs on this topic.
The ASP.NET Core Module is a fork of HttpPlatformHandler which was modified to work with ASP.NET Core's new system and was previously used to host ASP.NET Applications. related GitHub issue
IIS needs it in order to start up your ASP.NET Core application when the first request arrives and to route requests to the ASP.NET Core application.
With .NET Core (and hence ASP.NET Core), ASP.NET Core comes with its own http server (previously this was only possible with Http.sys aka WebListener self-hosting, i.e. commonly used for WCF services). It also redirects a couple of headers to the application, since IIS with ASP.NET Core only acts as reverse proxy.
In other words, ASP.NET Core is hosted outside the IIS process, and ASP.NET Core Module is there to communicate with it and starts the outside process if not already. This also means, that ASP.NET Core applications hosted in IIS are subject to IIS lifetime cycle (i.e. IIS may and will stop your applications when idle - This doesn't happen when you self-host your application or use something like nginx as reverse proxy).
With ASP.NET Core 2.1 preview1 it will also be possible to host ASP.NET Core application in the IIS process (w3wp.exe) for a improve request throughput. For more information on this, read ASP.NET Core 2.1.0-preview1: Improvements to IIS hosting