As you can see this is a question from a non web developer. I would like to have an ASPX page which, under certain circumstances, can generate a 401 error from code. Ideally
One additional comment.
If a portion of the page has already been written to the output buffer then it is important that you clear any buffered content or the page may not appear correctly.
This is quite likely in a templated environment. e.g. Master pages...
Response.ClearContent();
Response.StatusCode = 401;
Response.End();