I found the SuppressFormsAuthenticationRedirect property on this post , but when I tried to use it:
Response.StatusCode = (int)HttpStatusCode.Unauthorized; Response.SuppressFormsAuthenticationRedirect = true;
I get a build error:
Error 53 'System.Web.HttpResponseBase' does not contain a definition for 'SuppressFormsAuthenticationRedirect' and no extension method 'SuppressFormsAuthenticationRedirect' accepting a first argument of type 'System.Web.HttpResponseBase' could be found (are you missing a using directive or an assembly reference?) Controllers\ErrorController.cs 39 26 Roving
So, I threw a breakpoint, checked Response in the clock window and found that it really has a property. So I tried to set it soon with Response.SuppressFormsAuthenticationRedirect = true , which did not cause an error, and it worked as expected. So why is this a build error? I did this, just for fun, and found that it worked as expected (but these are pretty hacks):
Response.StatusCode = (int)HttpStatusCode.Unauthorized; ((dynamic)Response).SuppressFormsAuthenticationRedirect = true;
source share