Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.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/9/ruby-on-rails-3/4.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
Sharepoint Webclient 401未经授权的问题处理时间超过5分钟_Sharepoint_Handler_Webclient - Fatal编程技术网

Sharepoint Webclient 401未经授权的问题处理时间超过5分钟

Sharepoint Webclient 401未经授权的问题处理时间超过5分钟,sharepoint,handler,webclient,Sharepoint,Handler,Webclient,我有HttpHandler(abc.ashx),我调用它来处理(批量上传)excel文件。此处理需要一定的时间,这与excel中的行数成比例。 最重要的是,我在Sharepoint中有一个事件处理程序,它使用WebClient使用下面的代码对此处理程序进行售后服务调用 注意:我使用Sharepoint的提升权限生成一个标识令牌,并使用该令牌进行模拟以进行服务调用。net我使用系统帐户的标识进行售后服务呼叫 WindowsIdentity identity = null;

我有HttpHandler(abc.ashx),我调用它来处理(批量上传)excel文件。此处理需要一定的时间,这与excel中的行数成比例。 最重要的是,我在Sharepoint中有一个事件处理程序,它使用WebClient使用下面的代码对此处理程序进行售后服务调用

注意:我使用Sharepoint的提升权限生成一个标识令牌,并使用该令牌进行模拟以进行服务调用。net我使用系统帐户的标识进行售后服务呼叫

        WindowsIdentity identity = null;
        // Get an identity token using delegate activity of Elevated Privelleges of Sharepoint
        SPHelper.ElevatedActivity(properties.Web.Site.Url, properties.Web.ServerRelativeUrl, web =>
        {
            identity = WindowsIdentity.GetCurrent();
        });

        //Impersonates the identity of System Account user, as received in token in the line above
        using (identity.Impersonate())
        {
            // create a web client object which only increases the timeout of the web client call
            var webClient = (new CustomWebClient());
            webClient.Credentials = CredentialCache.DefaultNetworkCredentials;
            webClient.UseDefaultCredentials = true;
            //url of the httphandler as deployed in sharepoint, and the parameters that needs to be passed
            string handlerUrl =
                string.Format(
                    properties.Web.Url.Trim('/') + "/_layouts/Handlers/abc.ashx?Table=BulkUpload&Region={0}&UserId={1}&BatchId={2}&FileUrl={3}",
                    region, userValue.User.LoginName, batchId, fileUrl);

        }
        // execute the web service call using the webclient object
        webClient.DownloadString(handlerUrl));
本质上,此代码是在ItemAdded和ItemUpdated事件的事件处理程序中编写的

问题出在webClient中,它似乎在经过5分钟的处理后出现了一个错误“system.net.webexception:远程服务器返回了一个错误:(401)unauthorized”。因此,如果要处理的excel工作表中的行数小于某个数字(1700),则处理将在5分钟内进行,并且一切正常,没有任何错误。但是,如果它的时间超过这个时间,那么处理将花费5分钟以上的时间,并且由于上面指定的错误而失败

奇怪的行为是,它似乎是超时问题,但错误消息指示授权问题,这没有意义,因为如果存在授权问题,即使处理时间少于5分钟,它也不应该工作

我们已尝试查找任何在5分钟内超时的配置,但找不到任何配置

在此问题上的任何帮助或建议都将不胜感激

更新:我现在尝试使用HttpWebRequest来实现这一点,并尝试了一系列可能导致此超时/问题的设置。但是仍然遇到同样的问题,在处理5分钟后,我得到“system.net.webexception:远程服务器返回错误:(401)unauthorized”。下面是我尝试过的代码

HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(handlerUrl);
                    httpWebRequest.Credentials = CredentialCache.DefaultCredentials;
                    httpWebRequest.UseDefaultCredentials = true;
                    httpWebRequest.Timeout = 600000;
                    httpWebRequest.ReadWriteTimeout = 600000;
                    httpWebRequest.ServicePoint.ConnectionLeaseTimeout = 600000;
                    httpWebRequest.ServicePoint.MaxIdleTime = 600000;
                    httpWebRequest.ContentType = "application/json; charset=utf-8";
                    httpWebRequest.ContentLength = 0;
                    httpWebRequest.Method = WebRequestMethods.Http.Get;
                    BulkUploadProcessorResponse response = null;
                    var httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    using (Stream stream = httpWebResponse.GetResponseStream())
                    {
                        using (StreamReader sr = new StreamReader(stream))
                        {
                            response =
                                JsonHelper.JsonDeserialize<BulkUploadProcessorResponse>(sr.ReadToEnd());
                        }
                    }
HttpWebRequest HttpWebRequest=(HttpWebRequest)WebRequest.Create(handlerUrl);
httpWebRequest.Credentials=CredentialCache.DefaultCredentials;
httpWebRequest.UseDefaultCredentials=true;
httpWebRequest.Timeout=600000;
httpWebRequest.ReadWriteTimeout=600000;
httpWebRequest.ServicePoint.ConnectionLeaseTimeout=600000;
httpWebRequest.ServicePoint.MaxIdleTime=600000;
httpWebRequest.ContentType=“application/json;charset=utf-8”;
httpWebRequest.ContentLength=0;
httpWebRequest.Method=WebRequestMethods.Http.Get;
BulkUploadProcessorResponse响应=null;
var httpWebResponse=(httpWebResponse)httpWebRequest.GetResponse();
使用(Stream-Stream=httpWebResponse.GetResponseStream())
{
使用(StreamReader sr=新StreamReader(stream))
{
回应=
JsonHelper.JsonDeserialize(sr.ReadToEnd());
}
}