Slow DotNetCore 2.0 MVC after publish to IIS - performance

I have a Web Site that consumes two MVC web service. The entire project, both services and the web site were developed with dotnetCore 2.0 MVC and Angular
I am using VSCode for development. When I run in the VS Code debugger - (I guess that is Kestral?) Everything is great. The Web Site (AngularJS) calls to Service A, Service A makes a bunch of calls to Service B and everything is very snappy an responsive.
OK. Now I do "dotnet publish" and move the output to be hosted in IIS. Everything works the calls all execute successfully. However, the calls from Service A to service B take several seconds each. Where in the DEV server they take just a few milliseconds on the PROD Server the same call takes several seconds.
If I call from the web site to the Service B the response is as expected - very snappy.
So, to summarize
- Service A calling Service B on a DEV server with VSCODE debugger running is very fast
- Service A calling Service B on a PROD server with a Published version of the project running behind IIS very slow
- Calling AJAX directly to service B is working great even on the Published IIS version.
Anyone have any idea what could be causing this. Or even where I could start to debug the problem?
Thanks in advance.

Related

DotTrace on Remoting Proxy

I have a WebAPI project running on local machine that is calling server side codes via remote proxy (local machine) on service layer. The profiler was able to trace the hotspot but up to service layer only and the hotspot is all pointing to methods calling server side methods.
How can I let the profiler trace the bottlenecks in server side codes?
Things to note:
1. Controller and service layer = .Net4.5
2. Server Side = .Net 3.5
3. Remote Proxy is using local web service.
Things I did
1. Profile the whole project
2. Profile the web service
3. Run the remote agent locally
You can run multiple dotTrace standalone at the same time. One dotTrace for each side (WebAPI and server). If you attach to the server side process, you will be able to find the hotspots
What server do you use to host the server-side code? If it is IIS or IIS Express, you need to profile it from the corresponding section of dotTrace Home.
Anyway, you can start profiling from ".NET Process" section of dotTrace Home - in this mode any managed application that is started after clicking Run will be profiled (you just need to select the right application in profiling controller and get a snapshot). See this page for details: https://www.jetbrains.com/help/profiler/Profiling_Guidelines__dotNET_Process.html

Azure Cloud Service 503 error outside of instance

I have three mvc 3 web applications in a single web role on Azure Cloud Services. All of a sudden this morning both the single instance in production and in staging give "HTTP Error 503. The service is unavailable." when navigated to in a browser.
I rebooted the production instance but nothing changed. Then I deployed a remote desktop enabled version to the staging instance and logged in. However, strangely when I navigate to the web applications in a browser inside the remoted staging instance everything works.
Looking at IIS server logs it seems there are some issues starting the roles (warning level about the appPoolId being incorrect) but obviously the roles are starting as they are accessible from inside the staging server.
The World Wide Web Publishing service is also running and even after restarting this service the web application is not accessible externally.
Does anyone have an explaination for why the sites are accessible locally but not remotely that would help me debug this issue?
I found out where the issue came from, the bindings that were configured in IIS7 did not include bindings for the actual [abc].cloudapp.net host headers.
I assume that for some reason since some time last night or this weekend the requests seem to come with those headers instead of the original headers for the website. This is really strange but adding these bindings fixed both the staging and production instances and they were available again after this change.

EasyNetQ with asp.net web api as subscriber

I have to implement a asp.net web api which acts as a subscriber to rabbitMQ. The windows service is going to publish message to the web api services. There will be more than one instance of web api running on production enviornment. I am not sure how to open up the subscriber channel on web api and keep it open untill the IIS restarts. There will be one publisher and several consumer.
Can anyone please guide with some sample code to start with?
Any help will hugely appreciated
Generally RabbitMQ subscriptions don't work well with IIS hosted applications because you have no control over when the application is running. IIS will recycle, stop and start the app as it sees fit.
If you must do it, open the connection to RabbitMQ and start subscribing when the application starts, in Global.asax.cs for example, and make sure to dispose of everything properly when it closes.
You are far better off building a windows service for the subscription and either writing to a shared store that the IIS hosted web service can access, or alternatively self-hosting the API inside the windows service.

WebApi Deployed to Azure - Controllers Don't Work (500 Error)

I have a WebApi project that wraps the Dynamics CRM Online web service and provides a REST api. I have a simple controller that gets some contacts from CRM and returns them to the caller.
Everything works fine when I run it in the local emulator. However, when I deploy the project to Azure, I can reach the home page, but the controllers all return http 500 errors. Why would this happen? And how can I troubleshoot to get more details?
UPDATE
The issue is with the absence of Microsoft.IdentityModel.dll on the Server 2012 instance running the web role in Azure. I found this by opening web role instance in RDP, installing Fiddler, and making the request from Fiddler to the local IIS server. It responded with the detailed error.
Now my issue is figuring out how to enable IdentityModel on a Windows Azure Web Role. You're supposed to be able to add it via the Server 2012 Add Roles and Features wizard, but it's totally locked down on the Web Role. You can't check any boxes that aren't already checked. Is this even possible?
The issue is giving the Web Role access to Windows Identity Foundation when it's inherently not there. Marc Schweigert provides clear steps to do this here:
http://blogs.msdn.com/b/devkeydet/archive/2013/01/27/crm-online-amp-windows-azure-configuring-single-sign-on-sso.aspx
Go to the 23:00 mark of the video and you'll see the 4 necessary steps:
Reference Microsoft.IdentityModel.dll (need WIF SDK installed)
a. Set copy local = true
Create RegisterWIFGAC.cmd in your web role project
Create Startup Task in ServiceDefinition.csdef that invokes RegisterWIFGAC.cmd
Add GacUtil to the project (used in the startup task) to put Microsoft.IdentityModel.dll in the GAC every time the web role starts).

Web service in an ASP.NET MVC application

I have an ASP.NET MVC application in a solution, and inside the same solution there is another webservice project. I need to debug a particular WebGet method inside that service using a url in my localhost. Am able to reach the web service where it is hosted using the actual url to that service. But if I have to debug it, how can I reach that method when running in localhost?
You need to use IIS Express How to: Specify the Web Server for Web Projects in Visual Studio. Using IIS express you can debug and run both projects in your solution at the same time.
IIS Express for Developers

Resources