Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC controller action is called twice
    text
    copied!<p>On IIS 7 server with my ASP.NET MVC 3 application, I am encountering the following problem: when I have an action taking rather long time to complete (like 30 seconds), it will get fired for the second time after cca 15-20 seconds from the first request. I can see in Fiddler (HTTP sniffer) that the browser is not the culprit - it only sends the request once. However, in IIS log files, I can see the request twice. However, in IIS logs, both requests have the same timestamp (not in my own log files - there the two requests are separated by those 15-20 seconds).</p> <p>Originally, the action was processing an uploaded file, storing it in the database etc..However, even after I changed the action to just call <code>Thread.Sleep(30000)</code>, it is still called twice.</p> <p>It is not caused by some malfunctioning JavaScript or missing-image references which seem to be the common reasons for this behavior as I read through similar problems here on StackOverflow. I cannot replicate this on the development ASP.NET server, only on the IIS server and just on one of two I use.</p> <p>This is the HTML form used to trigger that action</p> <pre><code>@model TMAppServer.Abstract.DataTransferObject.ProjectOverviewData @{ Layout = null; } &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;UploadTestForm&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; @using (Html.BeginForm("UploadFileNew", "Manager", new { targetLanguage = "CS" }, FormMethod.Post, new { enctype = "multipart/form-data" })) { &lt;input id="files" type="file" name="files" /&gt;&lt;text&gt;&lt;input type="submit" id="uploadFile" value="Upload the document..." /&gt;&lt;input type="hidden" name="projectId" id="projectId" value="@(Model.Job.Name)" /&gt; } &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is the controller action:</p> <pre><code>public ActionResult UploadFileNew(string projectId, string targetLanguage, IList&lt;HttpPostedFileBase&gt; files) { foreach (var file in files) { if (null == file) continue; Thread.Sleep(30000); } return RedirectToAction("GetProjectOverview", new { projectId = projectId }); } </code></pre> <p>Thank you for any suggestions.</p> <p><strong>EDIT: Now I found out that this only happens when I access the server via its domain name from the same network (like server.domain.com), it does NOT happen when accessing the server via its IP address or from an outside network.</strong></p> <p>This is what I get in the IIS logs:</p> <pre><code>2011-07-21 01:23:31 W3SVC2 WIN-AD50B4LJ2SU 192.168.1.48 POST /manager/upload-file projectId=3366 80 - 192.168.1.1 HTTP/1.1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:5.0.1)+Gecko/20100101+Firefox/5.0.1 .ASPXAUTH=cookie http://tm.web.com/manager/projects/3366/overview tm.web.com 302 0 0 440 6232309 578 2011-07-21 01:23:31 W3SVC2 WIN-AD50B4LJ2SU 192.168.1.48 GET /manager/projects/3366/overview - 80 - 192.168.1.1 HTTP/1.1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:5.0.1)+Gecko/20100101+Firefox/5.0.1 .ASPXAUTH=cookie http://tm.web.com/manager/projects/3366/overview tm.web.com 200 0 0 30125 769 93 2011-07-21 01:23:31 W3SVC2 WIN-AD50B4LJ2SU 192.168.1.48 POST /manager/upload-file projectId=3366 80 - 192.168.1.1 HTTP/1.1 Mozilla/5.0+(Windows+NT+6.1;+WOW64;+rv:5.0.1)+Gecko/20100101+Firefox/5.0.1 .ASPXAUTH=cookie http://tm.web.com/manager/projects/3366/overview tm.web.com 302 0 64 0 6232309 39406 </code></pre> <p>And these are my routes in Global.asax.cs</p> <pre><code>public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute(null, "manager/upload-file", new { controller = "Manager", action = "UploadFile" }, new { httpMethod = new HttpMethodConstraint("POST") } ); routes.MapRoute(null, "manager/projects/{projectId}/overview", new { controller = "Manager", action = "GetProjectOverview" }, new { httpMethod = new HttpMethodConstraint("GET") } ); routes.MapRoute(null, "manager/{action}", new { controller = "Manager", action = "Main" }, new { httpMethod = new HttpMethodConstraint("GET") } ); routes.MapRoute("Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Manager", action = "ListProjects", id = UrlParameter.Optional } // Parameter defaults ); } </code></pre>
 

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