Setting Timeout Value For .NET Web Service

2019-01-11 01:03发布

I have a web service written in C# that is living on a SharePoint site. I have modified the web.config with the following code:

<configuration>
  <system.web>
    <httpRuntime executionTimeout="360" />

...

for the IIS Inetpub file, the SP ISAPI web.config file and the SP layouts web.config. I have also modified the machine.config file with the same code and tried to bump any timeouts that I see in IIS.

When I call this web service from a Windows C# application I can step into the web method and start debugging the variable but after a short time (~1 minute, maybe less) the variable values are no longer present because this gets returned:

System.Net.WebException "The request was aborted: The operation has timed out."

I am trying to figure out where the correct timeout values needs to be set and how. I restart IIS after I have made every change but nothing changes to give different results.

Thanks

2条回答
孤傲高冷的网名
2楼-- · 2019-01-11 01:41

Try setting the timeout value in your web service proxy class:

WebReference.ProxyClass myProxy = new WebReference.ProxyClass();
myProxy.Timeout = 100000; //in milliseconds, e.g. 100 seconds
查看更多
爷的心禁止访问
3楼-- · 2019-01-11 01:48

After creating your client specifying the binding and endpoint address, you can assign an OperationTimeout,

client.InnerChannel.OperationTimeout = new TimeSpan(0, 5, 0);
查看更多
登录 后发表回答