How reliable is HttpStatusCodeResult.StatusDescription?

Consider the following controller action, many examples of which exist on the Internet:

public ActionResult Fail()
{
    return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "My helpful message");
}

Now we will call this action through Ajax and display the results on the page;

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script type="text/javascript">
            var xmlhttp = new XMLHttpRequest();

            xmlhttp.onreadystatechange = function () {
                if (xmlhttp.readyState == 4) {
                    document.body.innerHTML = xmlhttp.response;
                }
            }

            xmlhttp.open("POST", "/log/fail", true);
            xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlhttp.send();

        </script>
    </head>
    <body>
    </body>
</html>

When I open this page in a Chrome or Firefox browser on my Windows 10 device, I get a full error report that displays my useful message.

However, when I open this page on an iOS device (tested with iPad Air, iPhone 5S), this message is not found anywhere in the response received.

, HttpStatusCodeResult.StatusDescription, , new HttpStatusCodeResult(), , , , , (HttpStatusCode.OK). ?

, AngularJs, , jQuery ;

AngularJS

$http.post('/log/fail')
    .then(function (response) {
        // successful
    }, function (response) {
        document.body.innerHTML = response.statusText; // 'Bad Request' in iOS
    });

JQuery

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
        <script type="text/javascript">
            $.ajax({ url: '/log/fail', method:'POST' }).error(function (response) {
                document.body.innerHTML = response.statusText; // 'Bad request' in iOS
            });
        </script>
    </head>
    <body>
    </body>
</html>
+4
1

, ( , IIS).

, .

, , , .

+1

All Articles