2016-02-19 104 views
0

我有一个位于Azure API Management后面的Azure Web服务。这意味着API管理层使用SSL与我的服务进行对话,并提供客户端认证。我遇到了这种设置中的一个常见问题,其中POST大于49152导致错误413 RequestEntityTooLarge。有许多引用UploadReadAheadSize设置的文档,但是我在Web.config中设置此值的所有尝试都会导致内部服务器错误。这里是我如何设定值:在Azure Web服务中配置UploadReadAheadSize的正确方法是什么?

<system.webServer> 
<serverRuntime uploadReadAheadSize="1048576" /> 

理想我想用更大的东西,但我只是试图让事情先工作。使用此设置进行部署时,所有后续请求都会因内部服务器错误而失败。我在诊断日志中找不到任何内容来指出发生故障的原因。

寻找任何指向何处/如何设置此值的指针。谢谢!

回答

0

终于明白了这一点。请注意,理想情况下,因为我只使用cert auth,所以我应该能够将sslFlags设置为“required”。我尝试过,但无法使用Azure API Management正常工作。我一直从IIS获得403.7错误。现在我将它设置为“协商”并增加uploadReadAheadSize的值,如下所述:

public class WebRole : RoleEntryPoint 
{ 
    public override bool OnStart() 
    { 
     try 
     { 
      using (ServerManager server = new ServerManager()) 
      { 
       string siteName = $"{RoleEnvironment.CurrentRoleInstance.Id}_Web"; 
       Configuration config = server.GetApplicationHostConfiguration(); 
       ConfigurationSection accessSection = config.GetSection("system.webServer/security/access", siteName); 
       accessSection["sslFlags"] = @"Ssl,SslNegotiateCert"; 
       ConfigurationSection runtimeSection = config.GetSection("system.webServer/serverRuntime", siteName); 
       runtimeSection["uploadReadAheadSize"] = 5242880; 
       server.CommitChanges(); 
      } 
     } 
     catch (Exception e) 
     { 
      Trace.TraceError(e.Message); 
      throw; 
     } 

     return base.OnStart(); 
    } 
} 
相关问题