使用HttpWebRequest时,WebResponse是将文件上载到SharePoint时未编译的aspx页面

时间:2012-01-16 14:57:18

标签: sharepoint upload httpwebrequest wss webresponse

这很奇怪。多年来,将一些代码上传到SharePoint的代码一直在我的开发机上运行。它刚刚停止工作!没有异常被抛出,但WebResponse中有一个奇怪的响应字符串。这是代码:

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(absoluteUrl);

            if (this._authenticationService == null)
            {
                // Windows authentication
                request.Credentials = _credentials;
            }
            else
            {
                // Forms authentication
                request.CookieContainer = this._authenticationService.CookieContainer;
            }

            request.Method = "PUT";
            byte[] buffer = new byte[4 * 1024];
            using (Stream stream = request.GetRequestStream())
            {
                using (FileStream fs = File.OpenRead(localFilePath))
                {
                    for (int i = fs.Read(buffer, 0, buffer.Length); i > 0; i = fs.Read(buffer, 0, buffer.Length))
                    {
                        stream.Write(buffer, 0, i);
                    }
                }
            }
            WebResponse response = request.GetResponse();
            response.Close();

如果我添加一些代码来检查这样的实际响应:

StreamReader responseReader = new StreamReader(response.GetResponseStream());

responseReader.ReadToEnd();

该代码的输出是这个,看似未编译的aspx页面!!!!:

<%@ Assembly Name = \“Microsoft.SharePoint.ApplicationPages,Version = 12.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c \”%> <%@ Page Language = \“C#\”Inherits = \“Microsoft.SharePoint.ApplicationPages.ErrorPage \”MasterPageFile = \“〜/ _layouts / simple.master \”%> <%@ Import Namespace = \“Microsoft.SharePoint.ApplicationPages \”%> <%@ Register Tagprefix = \“SharePoint \”Namespace = \“Microsoft.SharePoint.WebControls \”Assembly = \“Microsoft.SharePoint,Version = 12.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c \”%> <%@ Register Tagprefix = \“Utilities \”Namespace = \“Microsoft.SharePoint.Utilities \”Assembly = \“Microsoft.SharePoint,Version = 12.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c \”%> <%@ Import Namespace = \“Microsoft.SharePoint \”%> \ r \ n<%@ Register Tagprefix = \“SharePoint \”Namespace = \“Microsoft.SharePoint.WebControls \”Assembly = \“Microsoft.SharePoint ,Version = 12.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c \“%> <%@ Register Tagprefix = \“Utilities \”Namespace = \“Microsoft.SharePoint.U tills \“Assembly = \”Microsoft.SharePoint,Version = 12.0.0.0,Culture = neutral,PublicKeyToken = 71e9bce111e9429c \“%><%@ Import Namespace = \”Microsoft.SharePoint \“%> \ r \ n \ r \ n \ t \“EncodeMethod ='HtmlEncode'/> \ r \ n \ r \ n \ r \ n \ t \”EncodeMethod ='HtmlEncode'/> \ r \ n \ r \ n \ r \ n \ n \ t \ r \ n \ t \ r \ n \ r \ n \ r \ n \ r \ n \ t \ r \ n \ t \ r \ n \ t \ r \ n \ n \ t \ t \ r \ n \ n \ t \ r \ n \ t

\ r \ n \ t \ t<%\ r \ n \ t \ t \ tif(IsAdministrationSite)\ r \ n \ t \ t \ t {%> \ r \ n \ t \ t \ t \ t \“EncodeMethod = \”NoEncode \“runat = \”server \“> \“EncodeMethod ='HtmlEncode'/> \ r \ n \ t \ t<%}否则{%> \ r \ n \ t \ t \ t \ t \ t \”EncodeMethod = \“NoEncode \”runat = \ “服务器\”

  

\“EncodeMethod ='HtmlEncode'/> \ r \ n \ t \ t<%}%> \ r \ n \ t \ t \ r \ n \ t \ r \ n \ n \ n \ t \ r \ n \ r \ n \ r \ n \ t var gearPage = document.getElementById('GearPage'); \ r \ n \ t if(null!= gearPage)\ r \ n \ t {\ r \ n \ t \ t gearPage.parentNode.removeChild(gearPage); \ r \ n \ t \ t document.title = \“'EncodeMethod ='HtmlEncode'/> \”; \ r \ n \ t} \ r \ n \ r \ ñ

发生了什么事???!

1 个答案:

答案 0 :(得分:0)

好的,我已经陷入困境并重新安装并重新安装了带有SP2的WSS和最新的累积更新包,并重新连接到现有服务器场并且已经解决了这个问题!