将图像从iOS上传到IIS后Web服务时出现500错误

时间:2016-07-25 22:07:24

标签: asp.net web-services iis iis-8 windows2012

我正在尝试从.NET网站上传文件到IIS 8服务器。当我从桌面上传时,一切正常,webservice返回成功。当我尝试通过iPhone iOS上传图像时,我发生了500内部服务器错误。有没有办法从日志中检测到确切的内部异常,因为我找不到任何特定的东西,只有500个用于webservice all。我可以选择放入console.log()并从客户端获取信息,但它无助于我发现问题。我不能像往常一样调试它,因为我通过手机浏览网站。

1 个答案:

答案 0 :(得分:1)

在IIS中打开 Failed Request Tracing ,您可以像这样使用GUI或PowerShell:

 $siteName = "name of your web site"

 Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing

 Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.applicationHost/sites/site[@name=`'$siteName`']/traceFailedRequestsLogging" -name "enabled" -value "True"

 Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName"  -filter "system.webServer/tracing/traceFailedRequests" -name "." -value @{path='*'}
 Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName"  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/traceAreas" -name "." -value @{provider='ASPNET';areas='Infrastructure,Module,Page,AppServices';verbosity='Verbose'}
 Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName"  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/failureDefinitions" -name "statusCodes" -value "500"
 Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName"  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/traceAreas" -name "." -value @{provider='WWW Server';areas='Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,WebSocket';verbosity='Verbose'}

之后运行失败的请求并检查C:\inetpub\logs\FailedReqLogFiles\

下的日志文件

将文件复制到工作站并在IE中打开它们会更容易