c# - How to return more specific HTTP code (like 401.X) -


here article extended http codes:

iis 7.0, iis 7.5, , iis 8.0 define several http status codes indicate more specific cause of 401 error. following specific http status codes displayed in client browser not displayed in iis log:

  • 401.1 - logon failed.
  • 401.2 - logon failed due server configuration.
  • 401.3 - unauthorized due acl on resource.
  • 401.4 - authorization failed filter.
  • 401.5 - authorization failed isapi/cgi application.

i need custom extended http codes these:

  • 401.10 - user not found
  • 401.11 - user password mismatch
  • 401.12 - user account locked
  • 401.13 - user account expired
  • ...

how return these extended 401 error codes .net mvc application?

in action method set status codes manually:

response.statuscode = 401; response.substatuscode = 10; 

additionally, can use httpstatuscode enumeration in system.net:

response.statuscode = (int)httpstatuscode.unauthorized; 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -