c# - 使用上传字段时 Azure 上的超时

标签 c# .net azure timeout

我有一个包含一些上传字段的表单。在大多数位置,该表单都可以正常执行。但对于某些地点(到目前为止,我已经在新加坡的两个不同地方亲身经历过),表单在提交时几乎总是超时,甚至文件上传字段也留空。 如果我删除上传字段,该表单也适用于这些位置。

我已按如下方式跟踪请求。 在没有字段的表单上工作正常:

Request URL:http://opentraits.com/bogdan-litescu/communities/new2 Request Method:POST Status Code:302 Found Request Headersview source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3 Accept-Encoding:gzip,deflate,sdch Accept-Language:en-US,en;q=0.8 Cache-Control:max-age=0 Connection:keep-alive Content-Length:1180 Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryijq2AW8yKt0E8wSc Cookie:ASP.NET_SessionId=...... Host:opentraits.com Origin:http://opentraits.com Referer:http://opentraits.com/bogdan-litescu/communities/new2 User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17 Request Payload ------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="Id"

0 ------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="Name"

ewfwefwevv ------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="Website"

------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="About"

------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="IterationEnabled"

false ------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="IterationNextStart"

2013-01-28 ------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="IterationLength"

2 ------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="IterationPause"

0 ------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="IterationTotalPoints"

10 ------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="IterationPointScale"

0,1,2,3 ------WebKitFormBoundaryijq2AW8yKt0E8wSc Content-Disposition: form-data; name="IncentivesEnabled"

false ------WebKitFormBoundaryijq2AW8yKt0E8wSc-- Response Headersview source Cache-Control:private, s-maxage=0 Content-Length:143 Content-Type:text/html; charset=utf-8 Date:Mon, 21 Jan 2013 14:53:20 GMT Location:/bogdan-litescu/ewfwefwevv P3P:CP: NOI ADM DEV COM NAV OUR STP Server:Microsoft-IIS/8.0 Set-Cookie:.ASPXAUTH=BE19A758026293C73831096A1D96D428C08C60C45D20CDEED0F567E563F9EB0EC82B8FFA550D062605A7369EA00E78899E02075D2EFDC7319C71AA0574C3661A4E3F9D606FB731AD1EB8CEC6A41ACDB135692B9CFFA415BBE884E307B3D6F2DEFAC53F3F7B80B5B3671503D83FE22C4A41BDA967F83AF60E158E68B601CEC53CB760E256; expires=Fri, 09-Aug-2013 14:53:18 GMT; path=/; HttpOnly X-AspNet-Version:4.0.30319 X-AspNetMvc-Version:4.0 X-Powered-By:ASP.NET

对于上传字段超时的表单:

Request URL:http://opentraits.com/bogdan-litescu/communities/new Request Headersview source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryUq7yyIv4EnP2hJTA Origin:http://opentraits.com Referer:http://opentraits.com/bogdan-litescu/communities/new User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17 Request Payload ------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="Id"

0 ------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="Name"

wefewfwefw ------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="Icon"; filename="" Content-Type: application/octet-stream

------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="Logo"; filename="" Content-Type: application/octet-stream

------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="Website"

------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="About"

------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="IterationEnabled"

false ------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="IterationNextStart"

2013-01-28 ------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="IterationLength"

2 ------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="IterationPause"

0 ------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="IterationTotalPoints"

10 ------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="IterationPointScale"

0,1,2,3 ------WebKitFormBoundaryUq7yyIv4EnP2hJTA Content-Disposition: form-data; name="IncentivesEnabled"

false ------WebKitFormBoundaryUq7yyIv4EnP2hJTA--

因此,只需将上传字段放在表单上,​​许多请求 header 就不再在帖子中发送。我已经没有调试的想法了。它与 Asp.Net MVC、Azure、互联网提供商有关吗?为什么某些 header 不会仅在某些位置随请求一起发送?

非常感谢任何解决这个问题的帮助!

更新

我已将表单隔离在纯 html 文件中,地址为 http://opentraits.com/test.html 后端只是重定向回 test.html。如果我从我的位置尝试,我会看到一些请求 header 未传递并且请求超时。如果我尝试从其他位置使用远程桌面,它工作正常 - header 都在那里,并且它重定向回 test.html。

更新2 后端是Asp.NET MVC模型。

public class CommunityModel
{
    public int Id { get; set; }

    [Required]
    [StringLength(255, ErrorMessage = "The {0} must be less than {1} characters long.")]
    public string Name { get; set; }

    [StringLength(255, ErrorMessage = "The {0} must be less than {1} characters long.")]
    public string Website { get; set; }

    [StringLength(1000, ErrorMessage = "The {0} must be less than {1} characters long.")]
    public string About { get; set; }

    public HttpPostedFileBase Icon { get; set; }

    public HttpPostedFileBase Logo { get; set; }

    ....................
}

然后在 Controller 中通过简单的重定向进行处理:

[HttpPost]
public ActionResult New2(string entityId, CommunityModel communityModel)
{
    return new RedirectResult("/test.html");
}

最佳答案

尝试设置

context.Response.BufferOutput = false; 

并且不要设置内容长度。

关于c# - 使用上传字段时 Azure 上的超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14441557/

相关文章:

json - Logstash 输出 elasticsearch - 动态生成索引名称

c# - 在 Xamarin MAC 应用程序中检测 Wifi SSID

c# - 从 ViewModel 打开一个窗口窗体

c# - .NET Core 依赖注入(inject),解析泛型接口(interface)

C# "internal"进行单元测试时访问修饰符

azure - 升级到 asp.net core rc2 后发布到 Azure 应用服务崩溃

azure - Azure Web 应用服务 CI/CD 中的文件名太长

c# - 如何获得看起来像没有选项卡的 TabControl 的控件?

c# - Visual Studio : find all references of a specific type

.net - 将 windows server 2008 替换为 linux for asp.net mvc 应用程序