Delay in Page Load ASP.NET - asp.net-mvc-4

I have an Web application(ASP.NET MVC5) hosted in the web server 1 which access the REST Service(WebAPI) hosted in the web server 2.
In my Web application, on click on the tab, call to the webAPI is made and it retrieves the data from SQL table(I m using EF5) which has 10 records.
I m experiencing considerable delay in the response for the first time and when i click the consecutive tabs, the response is faster like anything.
When I close the browser and opens the URL again immediately, the response time improves
When I open the URL after an hour or so , the response time is again high.
I could notice similar behaviour when i test the web service individually.
P.S : I m using bundling and minification as well. I m using Windows authentication and ASP.NET impersonation

Related

Click on ASP .Net Core Identity Log In button leads to 400 error

I'm writing simple asp .net core 2.2 MVC app with individual authorization (ASP Identity) hosted on IIS 10. If user navigates to Login page, stays idle for 20+ minutes (which is IIS default timeout to terminate app pool) and click on log in button - browser gets a 400 response and shows blank page. If user updates (F5) login page before click to log in - everything works fine.
IIS pool settings all default, but pipeline is changed to No Managed Code.
APS Identity Code default too (only registration modified a little).
Can anyone suggest how to resolve this idle login case?
I tried to disable AntiForgery Token Validation but it doesn't help.
I resolved the issue. On my app pool settings loadUserProfile was set to False by default. After I changed it to True everything started to work fine.
Don't know why it cause problems in False state though.
I resolved this issue by removing the [ValidateAntiForgeryToken] from the method(for which pag in MVC application.

Using JMeter with ASP .NET MVC 4 web app returns 500 status error when logging into web app. Why?

I'm using JMeter to load test my web app. I created two HTTP Requests, one visit login page and the other, log into my account. The visit login page HTTP request works fine and returns 302 Found status. JMeter displays the login page and there 0% errors on that page.
However, when I try to login into my account using the POST Data I retrieved from Firebug POST, it doesn't work and returns a 500 status error.
I am having difficulty getting the logging into my account feature to work. I have tried to send a POST request with the following:
1) __RequestVerificationToken
2) languageDropDown (My web app requires it)
3) UserName
4) Password
but I am still getting the error.
I followed this tutorial as it's the only one on ASP.NET MVC web apps...
http://build-failed.blogspot.pt/2012/07/load-testing-aspnet-mvc-part-3-jmeter.html
But I didn't do the feedback form data because I don't need it. Just grab the general concepts and regular expression from that webpage and tried it on my app but it fails.
Why? How do I fix it?
Is it because I have cookies to store session and only unique users can login my web app at one time? I did add a cookie manager though.
BTW, this is on a deployed web application (not localhost).
Some photos, I blocked out all sensitive information (sorry) and some of the token's (Just in case?)
Are you sure you have static authentication token? May it dynamic?
Look at second video that deals with token at 5:37 min to understand how to extract dynamic authentication token.
Exept HTTP Cookie manager, try to add HTTP Cache manager

Silverlight ClientHttp Stack / windows authentication / and RIA services issue (I'm guessing it's a cookie thing)

I was investigating how to get status code 500 error messages to give me more information when these occur and happened upon the MSDN post about using the ClientHttp stack.. Which was all just so magical seeming until the application got deployed on the staging servers and it seems to completely fail now with authentication
I'm guessing this is due to the whole cookie issue as it relates to the ClientHttp stack...
I'm using RIA services and when the application starts it runs 3 or 4 RIA WCF service calls preloading data in the background and now with the new ClientHttpStack an authentication dialog pops up pretty much every single time a request is made. We're using Windows Authentication so before it would just make you authenticate in order to access the page serving the XAP file... But now you login with Win Auth and then all the subsequent calls repetitively ask for your credentials...
I'm assuming the only way I can fix this is by doing this
http://msdn.microsoft.com/en-us/library/dd920298(v=vs.95).aspx
And then possibly adding an endpoint behavior onto the DomainClient so that before requests are handled it tacks on the cookies...
I've tried doing this for a bit now and I'm not really succeeding... When I run the app in FF or Chrome it still pops up with a whole bunch of login boxes. So I'm just curious if I'm barking up the wrong tree or if I should continue trying to figure out where I'm not quite propagating the cookies through
If you are using the ClientHttp stack, you'll need a place to store your cookie client side, said a HttpCookieContainer. It's just a wcf behaviour to be inserted in the ClientHttp stack. Please, have a look at this post from Kile McClellan and see if it helps you.

Classic ASP, ServerXMLHTTP authenticates on old server, not on new one

I'm working with a classic ASP website on a Windows 2003 server. The site requires authentication (configured to use Basic authentication). One page uses ServerXMLHTTP to request data from another page on the same website (same protocol [HTTPS], same host name), using the Open method with the arguments Method, URL, Async, UserName, Password. It's been working correctly for years. When the page that makes the server-side call is requested, the log shows one request, with no user name, for the back-end page that returns a 401 status, and then another request, that includes the user name, that returns a 200. These are followed by the request for the front-end page, with a 200 status.
I've copied the site to a Windows 2008 R2 64-bit server, with apparently the same authentication configuration in IIS. But now no data is received from the back-end page. The log shows TWO consecutive requests for the back-end page with no user name, and BOTH return a 401, and then the request for the front-end page, with a 500 status.
What could the problem be? I've seen discussions of proxycfg, but we aren't using a proxy. I've seen discussions of also setting credentials using Base64, but (a) we don't do that on the old server and (b) I tried it anyway, and it didn't make any difference.
Follow the steps outlined here :- https://stackoverflow.com/a/10762360/1579037
then, check that you can create object instances of the same XML components on the 64 bit server ?

ASP.NET WebAPI fails from MVC4 controller

I'm new to ASP.NET Web API and I'm struggling with a very strange problem.
I have some code which calls a RESTful service and it executes fine from a console project, but I can't get it to run from an MVC4 project running under .NET 4.0
The code to call the service is very simple:
internal string Test()
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://testserver");
var task = client.GetAsync("/someUri")
var response = task.Result;
response.EnsureSuccessStatusCode();
return response.Content.ReadAsStringAsync().Result;
}
}
As mentioned, called from a console project it works as expected and I get a response in milliseconds, however if I call the method from an action in my MVC4 controller after a few seconds I get a message stating that:
"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 repond".
Weirdly, when debugging the MVC4 version, the task status always shows as WaitingForActivation.
Running fiddler doesn't show any request being made from the MVC4 version, but again does for the Console version.
After a fairly serious bit of googling I can't find anyone else who seems to have had this problem, so I'm guessing that I've fundamentally misunderstood something, but at the moment I'm not sure what!
Updated 16:55 BST, 11/09/2012
To make things even weirder, I've just created a new MVC4 site and I can call the method without any problems! I'm now trying to compare the sites, however one was an existing site that was upgraded to MVC4 and the other is a new blank site, so spotting the relevant difference could be tricky.
Updated 16:44 BST, 14/09/2012
This is now looking like some infrastructure / networking issue.
I upgraded the project to VS2012 with .NET 4.5 so that I could use async/await to try the suggested implementations to avoid a deadlock. This didn't change anything so I went back to square 1.
I created a new solution with a new MVC4 project, a new services library and a unit test project to run the service library outside of MVC.
In the service library I created one method to call a public "what's my IP" service, and another to call a company service that's exposed publicly but only responds properly to company IP addresses.
For some background, I connect in to the company LAN via a VPN.
When disconnected from the VPN, in both unit tests and MVC, the IP service responds HTTP 200, the company service responds HTTP 404 as expected.
When connected to the VPN, unit tests both respond HTTP 200, MVC both timeout.
Next I ran MS Soap Tool locally and used that to proxy calls to the company services. All calls (whether from unit tests or MVC) show a request and response, but the unit test registers the response whilst the MVC controller does not.
My only other thought is that it could be something to do with the size of the reply? All the "successes" have very small replies other than the unit test calling the company service?
The Microsoft recommended way to upgrade an MVC3 to MVC4 site is to start with a completely new MVC4 site a migrate your views, controllers & code over. So I think that your upgrade steps may be part of your issue, since you were able to get it to work in the new MVC4 site you created. If you need to manually upgrade your existing site, I would follow the steps outlined in Upgrading ASP.NET MVC 3 Project to ASP.NET MVC 4