I found the property SuppressFormsAuthenticationRedirect
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 in a breakpoint, inspected Response
in the watch window, and found that it does indeed have the property. So I tried setting it in the immediate 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 this is pretty hacky):
Response.StatusCode = (int)HttpStatusCode.Unauthorized;
((dynamic)Response).SuppressFormsAuthenticationRedirect = true;