Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET MVC和httpRuntime执行超时_Asp.net_Asp.net Mvc_Configuration_Timeout_Httpruntime - Fatal编程技术网

ASP.NET MVC和httpRuntime执行超时

ASP.NET MVC和httpRuntime执行超时,asp.net,asp.net-mvc,configuration,timeout,httpruntime,Asp.net,Asp.net Mvc,Configuration,Timeout,Httpruntime,我想为ASP.NET MVC应用程序的一个子部分增加httpRuntimeexecutionTimeout 在常规Web应用程序中,您可以使用: <configuration> <location path="UploadPage.aspx"> <httpRuntime executionTimeout="600"/> </location> </configuration> 然而,在ASP.NET MVC中确实没

我想为ASP.NET MVC应用程序的一个子部分增加
httpRuntime
executionTimeout

在常规Web应用程序中,您可以使用:

<configuration>
  <location path="UploadPage.aspx">
    <httpRuntime executionTimeout="600"/>
  </location>
</configuration>

然而,在ASP.NET MVC中确实没有“文件夹”的概念,那么我该怎么做呢


让我们假设ASP.NET MVC路径是带有ImagesController和Upload操作的
/Images/Upload

您可以将整个MVC路径(控制器和操作)包含在标记的path属性中。像这样的方法应该会奏效:

<location path="Images/Upload">
    <system.web>
        <httpRuntime executionTimeout="600" />
    </system.web>
</location>

有效!只需确保路径中不包含~/即可

详细信息另一种方式-只需在操作代码中设置
ScriptTimeout

public ActionResult NoTimeout()
{
    HttpContext.Server.ScriptTimeout = 60 * 10; // Ten minutes..
    System.Threading.Thread.Sleep(1000 * 60 * 5); // Five minutes..
    return Content("NoTimeout complete", "text/plain"); // This will return..
}

如果操作在默认控制器中,那么home/upload不起作用,只需输入操作名称即可。

看看AsyncController,如果您使用它,您将有可能在操作方法上设置AsyncTimeout属性,因此您将能够超时请求

帮助我的链接:

我注意到您特别想增加上传页面的超时时间。我在一个名为plupload的“分块”上传程序上取得了一些成功。可以设置一个相对简单的MVC操作来接收上传的块,并在接收到每个块时追加它。对于小数据块,您不需要增加超时时间。当然,可能存在一些浏览器限制,但是


我认为Server.ScriptTimeout的方式不起作用。我清楚地记得我尝试过,但没有让它工作。啊,这是我们在返回web.config版本之前检查到测试层并工作的内容,boss:)似乎在使用~/时,ASP.NET将它映射到一个物理路径。使用“控制器/动作”时不会发生这种情况;它是从应用程序根目录映射的。是的,别问我为什么-我甚至在反射器里挖了个洞想弄清楚,但是在配置之后会很痛苦。这种技术对我不起作用。我需要改为在web.config中设置executionTimeout。我仍然无法让它正常工作。。。澄清一下:路径是相对于网站的根目录还是应用程序?此外,如果url中传递了任何值,这会失败吗?(例如:Images/Upload/1)这是相对于网站的根目录而言的,但我认为你可能会因为url上的附加值而运气不佳。ASP.NET严格解释路径,不允许使用通配符。2个想法:(a)使用QueryString。(b)创建一个实际的Images/Upload文件夹,并在其中放置一个web.config。将path=”“设置为应用于整个文件夹。不确定ASP.NET是否能正确解释MVC应用程序,但它肯定适用于普通ASP.NET应用程序。请注意,如果调试模式为executionTimeout可选Int32属性,则此操作将被忽略或完成。指定在ASP.NET自动关闭请求之前允许执行的最大秒数。仅当编译元素中的debug属性为False时,此超时才适用。因此,如果debug属性为True,则不必将该属性设置为大值,以避免在调试时关闭应用程序。这一点很好。这是一个大难题,因为在调试模式下一切都很好。然后你去部署,它因为一个未知的原因爆炸,错误消息传递很差。这不会像OP所希望的那样增加超时。运行时将在异步超时发生之前超时。