Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery GETs as well as POSTs with IE
    primarykey
    data
    text
    <p>We're using jQuery.ajax() methods to request server data on a number of pages on our MVC 3 web site. These requests are always marked with the 'POST' ajax parameter type and are typically invoked on page load or perhaps on a timer, that is to say, they are not a result of a user action (e.g. a mouse-click).</p> <p>When we look at the (Elmah) error log we see a number of entries as follows:</p> <blockquote> <p>A public action method 'GetMessageStats' was not found on controller 'Inbox.WebUI.Areas.Application.Controllers.StatusController'.</p> </blockquote> <p>The controller action is marked with the [HttpPost] e.g.</p> <pre><code>[HttpPost] public JsonResult GetMessageStats() { MessageStatsViewModel model = new MessageStatsViewModel { TotalNoMessages = MailDB.GetMessageCount(), MessagesInQueue = MailDB.GetQueueLength() }; return Json(model); } </code></pre> <p>and here is the invoking client script:</p> <pre><code>$(function() { var $totalMessages = $("#total-messages"), $queuedMessages = $("#queued-messages"); function getStats() { $.ajax({ type: "POST", url: "/Application/Status/GetMessageStats", dataType: "json", cache: false, success: function (data) { $totalMessages.text(data.TotalNoMessages); $queuedMessages.text(data.MessagesInQueue); setTimeout(function() { getStats(); }, 15000); }, error: function (xmlHttpRequest, errorMessage, exception) { throw errorMessage; } }); } getStats(); }); </code></pre> <p>On investigation it appears that some browsers (IE7/IE8, but maybe others) seem to issue a GET request in addition to the required POST request. It is noted that the user interface responds and behaves correctly under these browsers so the POST request is being serviced.</p> <p>Elmah is reporting the user agent as:</p> <p><strong>Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)</strong></p> <p>Has anyone else seen this problem? If so, have you found a way to avoid it?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload