I am testing my HTTP 301 redirects (constantly moving) for an ASP.NET MVC web application.
I created a test page with the following code:
try { var req = (HttpWebRequest) WebRequest.Create(url); resp = (HttpWebResponse) req.GetResponse(); return Json(new {statusCode = (int) resp.StatusCode}); } catch (Exception exc) { return Json(new { statusCode = (int)HttpStatusCode.InternalServerError }); } finally { if (resp != null) resp.Close(); }
But the problem is that the status code is HTTP 200 (OK), because it reads the last response (like a redirected page).
The url will get into my redirect controller, which returns this:
return RedirectToRoutePermanent("SomeRoute", new { id = someId });
And this is what I want to capture, not the 200 page that it is being redirected to.
How can I do it?
RPM1984
source share