We have a ASP.net core 2.0 application running in .Net Framework V4.7.1 hosted in IIS using Kestrel.
The application works fine on most machines, however on when running on my machine it is really slow. I have stripped down the application to a single controller returning a string, with all but the MVC and logging middleware removed. It appears that on about the 5th get request, there is a hang of about 30 seconds before the controller action is hit. The application is not restarted, it's just hanging.
Has anyone had a similar problem? Thanks
Maybe just a browser issue (in my case Vivaldi) but I experienced a similar "hanging" problem with ASP.net core 3.1 - a couple of requests work, then I change the URL to hit some other APIs, and it hangs (eventually giving a "connection was reset" error).
Turns out that it was trying to hit http://localhost:(port) but with my SSL port, which just makes it hang. The issue was masked by the browser's URL bar, which doesn't show the protocol (http/https):
You can type https:// at the start to fix it.
Or change your browser settings to make it more obvious what's going on, e.g. Vivaldi:
I had the same problem.The CreateWebHostBuilder method in Program class look liked this:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseKestrel()
.UseStartup<Startup>();
then I realized the problem is with .UseKestrel().The Kestrel documentation said CreateDefaultBuilder calls UseKestrel behind the scenes.so, I removed this extension method and the problems gone!.
Related
I have tried everything. I configured Windows Server 2019 according to Microsoft documentation and I successfully deployed a .NET 5 web application to the IIS.
I can get to the login page. I can even get to the forgot password page and they show themselves fine. However when I try to do any action (send the forgot password link or login to the page) I get a "Bad Request" from the server. I haven't found a way to explain why.
I have tried several, and I mean several things found Googling around but nothing helps. This include disabling https within the .NET Core application, trying to get a detailed error page using the app.UseDeveloperExceptionPage(); instruction inside Startup, etc etc but nothing works. I always receive this page trying to execute any action:
If someone could help or point me into the right direction, I will really, REALLY appreciate it.
Thank you
PD: In case it has anything to do with the problem, the error, at least the two that I can reproduce (because I can't even log in), happens, I think (maybe don't) when redirecting to another page in Microsoft Identity.
EDIT: code was asked by one of you. Thank you.
As you see, there's nothing specific in the forgot password screen for my application. This is scaffold code from Microsoft Identity. I even edited it and just let one line of code inside it, which is the default return code anyway as follow:
public async Task<IActionResult> OnPostAsync()
{
return RedirectToPage("./ForgotPasswordConfirmation");
}
As you can see, there's nothing special with that code. Here's the html that calls it, again, is a scaffold of Microsoft Identity with little to no changes (by little, I mean, maybe some CSS and a new value of view data):
But then again, forgot password page actually shows and seems well in the front end, but immediately I try to enter my email and click enter in this page, (also, just a scaffold of Microsoft Identity):
Nothing happens. I receive the bad request. There's NO magic nor custom code here. Something silly is going on.
EDIT II: YES, locally it works perfectly. The strange behavior happens only when deployed to IIS.
EDIT III: I coded and enabled logging in my .NET Core APP and wrote that to a file, and I think I finally got, at least the error (not the reason yet):
But why?? Cookies are enabled in the server browser without avail, same issue. Someone has a better idea than disabling anti forgery rules to login and forgot password pages?
Thank you
For some reason, when I deployed the first version of my app into IIS, I thought it was a good idea to just browse it from the IIS link. Of course, in a new mounted Windows Server 2019, IE is still the default browser. I connected directly to the IP of my web app via VPN, but used Chrome this time. Guess what? All problems disappeared. Yes, it's a bad idea to try to use a modern framework like .NET Core Identity with IE.
I am setting up an ASP.NET WebApi application running on the Azure web application environment. Most of my controllers and endpoints work fine, but there are about 10 routes that return 500 errors "An error has occured". It's not random. It's the same routes every time and I can find no pattern (not all the HTTP methods, from different controllers where other routes in that same controller work fine, and so forth)
When these errors occur, no error logging gets triggered as far as I can tell in the app. (I am using Raygun.IO if that matters). I tried adding a global.asax file with following lines in the Application_Error function:
Exception ex = Server.GetLastError();
new RaygunClient().SendInBackground(null, ex);
but as far as I can see, it doesn't get triggered when these 500 errors occur. The only thing I have found in the Azure server logs is the following warning in the Failed Requests log:
However, I don't see any errors in the trace previous to that point. I'm also not finding any other errors in any of my Azure logs that I can relate to these failing routes.
It's .NET 4.6 (tried 4.5.1 and 4.5.2 with no difference) WebApi using an OWIN startup class. Also tried updating all my packages to no effect.
Check to be sure you don't have routes that conflict. When a URI matches two or more controller actions, and thus Web API can't pick one, you will get a 500 error.
If you have a consistent repro, then you can use remote debugging to attach to your web app and debug it (https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-troubleshoot-visual-studio/). If you can repro it through the browser, you can also turn the custom errors page off so that it shows the stack trace through the browser (<customErrors mode="off"/> under <server.web>).
Also, you can enable better diagnostic logs using the web app settings. Information on how to do so is here: https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/ under the section "Enabling diagnostic logs".
Also, as Brent said, URL conflicts can cause some nasty errors which aren't immediately obvious.
I figured out what was going on. There were actual errors occurring (mostly SQL related), but the way that we had configured the functions and error logging in those functions, the actual errors were being swallowed up and lost, overriding the error logging behavior of Raygun. I went through and ripped out the Try/Catch blocks we were using for error trapping and logging and the real errors finally emerged into the Raygun dashboard.
I have a self-hosted OWIN application that embeds a System.Windows.Controls.WebBrowser control in a WPF view. This browser connects to a specific site which then communicates to my application via POSTs to 127.0.0.1:8002. The architecture is not under my control so not open to change.
The site is loaded happily and runs fine. The localhost communications only works if I have Fiddler running. If I take out Fiddler, I get an error.
I can do the post directly to the application using PostMan without Fiddler - no problems here.
I'm guessing normally everything is in-process and causing problems but Fiddler forces it to be out-of-process and invokes some marshaling magic that fixes the problem. Just a guess. I've tried running the OWIN service in a different thread; didn't help.
I've seen a similar (working) sample application, but it used Awesomium running in a separate process. This is not an option, we must run a specific version of IE.
Any thoughts on how to get OWIN to talk to the browser control?
The problem was solved by initialising OWIN with a wider range of URLs. Initially, I was just doing this:
StartOptions options = new StartOptions();
options.Urls.Add(String.Format("http://localhost:{0}", port));
WebApp.Start<ServiceStartup>(options);
When I added further URLs, the problem goes away. I'm guessing that Fiddler is changing the URLs on the way through.
StartOptions options = new StartOptions();
options.Urls.Add(String.Format("http://localhost:{0}", port));
options.Urls.Add(String.Format("http://127.0.0.1:{0}", port));
options.Urls.Add(string.Format("http://{0}:{1}", Environment.MachineName, port));
WebApp.Start<ServiceStartup>(options);
This is probably the same question as:
HTTP Traffic monitoring issue when using MonoTouch, HttpClient and Charles Proxy
But I thought I would ask it from a Windows Azure Mobile Services Client perspective. When I configure my iOS device to point at either fiddler (on my windows box) or charles (on my mac) I can see all traffic from a browser or from an Xamarin app that uses WebRequest. However if I use either Microsoft.WindowsAzure.MobileServices.MobileServiceClient (which uses HttpClient) or HttpClient directly the traffic does not show up.
I tried looking at:
http://fiddlerbook.com/fiddler/help/hookup.asp#Q-DOTNET
For some suggestions but I don't know enough about the implementation of HttpClient in Xamarin.IOS to know if they are appropriate. i.e. I couldn't seem to be able to use GlobalProxySelection as advised in:
GlobalProxySelection.Select = new WebProxy("127.0.0.1", 8888);
and I don't think the app.config suggestion of using:
<defaultProxy>
<proxy bypassonlocal="false" usesystemdefault="true" />
</defaultProxy>
is appropriate for an Xamarin app. A good starting point for me would be to understand what HttpClient is doing differently to WebRequest in order to track the problem down but hopefully someone can just tell me what I need to do to fix this.
Thanks
F
NOTE: I am not using a local address so that doesn't come into it.
NOTE: This can easily be tested by running http://docs.xamarin.com/samples/HttpClient/ on an iOS device configured to use fiddler/charles as a proxy and watching as the HttpClient traffic doesn't appear.
It's the same question and the answer should also be identical. IOW you need to set the proxy or use an HttpClient handler that supports CFNetwork.
I have my site hosted on IIS hosting. Site has feature that needs calling WCF service and then return result. The issue is that site is processing calling to WCF service another web site calling is freezing and not return content fast (this is just static content). I setup two chrome instances with different imacros' scripts, which one is calling page that requests wcf service and another one page is just static content. So here I can just see that when first page that requests wcf services freezes, another one page also freezes and when first is released the second is too.
Do I need reconfigure something in my Web.Config or do should I do something else to get possible to get static content immediately.
I think that there are two seperate problems here:
Why does the page that uses the WCF service freeze
Why does the static content page freeze
On the page that calls the WCF service a common problem is that the WCF client is not closed. By default there are 10 WCF connections with a timeout of 1 min. The first 10 calls go fine (say they execute i 2 secs), then the 11th call comes, there are no free wcf connections it must therefore wait 58 secs for a connection to timeout and become available.
On why your static page freezes. It could be that your client only allows one connection to the site, the request for the static page is not sent untill the request for the page with the wcf services is complete.
You should check the IIS logs to see how must time IIS is reporting that the request is taking.
I would say that this is a threading issue. This MSDN KB article has some suggestions on how to tune your ASP.NET threading behavior:
http://support.microsoft.com/kb/821268
From article - ...you can tune the following parameters in your Machine.config file to best fit your situation:
maxWorkerThreads
minWorkerThreads
maxIoThreads
minFreeThreads
minLocalRequestFreeThreads
maxconnection
executionTimeout
To successfully resolve these problems, do the following:
Limit the number of ASP.NET requests that can execute at the same time to approximately 12 per CPU.
Permit Web service callbacks to freely use threads in the ThreadPool.
Select an appropriate value for the maxconnections parameter. Base your selection on the number of IP addresses and AppDomains that are used.
etc...
Consider such scenario: when you make a request to IIS your app changes, deletes or creates some file outside of App_Data folder. This often tends to be a log file which is mistakenly was put at bin folder of the app. The file system changes lead to AppDomain reloading by IIS as it thinks that app was changed, hence the experienced delay. This may or may not apply to your issue, but it is a common mistake in ASP.NET apps.
Well, maybe there is no problem...
It may be just the browser's same domain simultaneous requests limit.
Until the browser not finished the request to the first page (the WCF page), it won't send the request to the second page (the static).
Try this:
Use different browsers for each page (for example chrome/firefox).
Or open the second page in chrome in incognito window (Ctrl + Shift + N).
Or try to access each page from different computer.
You could try to use AppFabric and see what is wrong with your WCF services http://msdn.microsoft.com/en-us/windowsserver/ee695849