2

Simple question this time, is there a way in ASP.NET to set a decimal value HTTP Status Code instead of the common int status code?

Example, I would like to set a "403.4 SSL required" instead of just a 403...

Thanks :)


** EDIT

The comments below pointed me in the right direction, I just needed to set the Response.SubStatusCode.

3 Answers 3

4

By the standard HTTP only defines 3 digit numeric result codes. What you are seeing is IIS specific, it is the sub-status code which can be set and read from the HttpResponse.SubStatusCode property.

From MSDN:

The SubStatusCode property is only supported with the integrated pipeline mode in IIS 7.0 and at least the .NET Framework version 3.0. When you set the SubStatusCode property, the status is logged on IIS 7.0 if failed-request tracing is configured. Independent of whether tracing is configured, the code is never sent as part of the final response to the request. For more information, see Troubleshooting Failed Requests Using Failed Request Tracing in IIS 7.0.

Sign up to request clarification or add additional context in comments.

1 Comment

HttpResponse.SubStatusCode is not available in .Net Core 2.2.
0

There is no such thing as a decimal HTTP Status Code.

Whatever you're trying to accomplish isn't by using HTTP status codes.

2 Comments

en.wikipedia.org/wiki/HTTP_403 has a full list of status codes that have a decimal value. Is that platform specific (like only valid in IIS)?
Didn't know about that but it must be platform specific, for sure. As @Matthew said RFC 2616 section 6.1.1 says it must be a "3-digit integer result code."
0

No. RFC 2616 section 6.1.1 says it must be a "3-digit integer result code."

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.