The web application I am testing checks HTTP Status Codes on AJAX responses to determine if there is an error. Even when I know there should be an error (for example a 401 authorization error when no user is logged in) I am always getting a 200 OK response using the code (and many variations of the code) below.
Code: Select all
// Create the web request
HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create("https://www.ourUAT.com");
httpReq.AllowAutoRedirect = false;
// Get the response
HttpWebResponse httpRes = (HttpWebResponse)httpReq.GetResponse();
// Report the results to ranorex report
Report.Info("httpReq = " + httpReq.ToString());
Report.Info("httpRes.StatusCode = " + httpRes.StatusCode.ToString());
// Close the response.
httpRes.Close();
I've seen other posts here about problems around waiting for AJAX calls to return and am wondering if this is a similar issue. As an example of what happens in the app, I've upload a picture showing the responses when trying to access the site without being logged in. The user is redirected to login page so there are some successful responses but what I am really interested in is the final 401 response.I suspect the response I am getting from the code is an initial success indicating that the site responded and it is not waiting for the AJAX calls to determine the true status.
Is there any way to get the final (or even all) status codes in the whole request stream? (I've tried some Streamreader code and that ended up giving me a single success response as well).
Any help or advice would be appreciated.
Todd
You do not have the required permissions to view the files attached to this post.