各位同仁:
我在使用MS介绍其智能客户端时所涉及的两个通用的库 AppStart和AppUpdate进行客户端程序更新,当更新网站在windows2003,XP系统的IIS上均能成功使用,但是在windows server 2008 r2操作系统的IIS7.0 上却不能使用,报错:“System.Net.WebException: 远程服务器返回错误: (405) 不允许的方法”,经过调试,发现报错信息如下:
在 System.Net.WebException 中第一次偶然出现的“System.dll”类型的异常
Error accessing Url http://10.164.1.65/FZLD_Server/UpdateVersion.xml
在 System.Net.WebException 中第一次偶然出现的“AppUpdater.dll”类型的异常
System.Net.WebException: 远程服务器返回错误: (405) 不允许的方法。
在 System.Net.HttpWebRequest.GetResponse()
在 Microsoft.Samples.AppUpdater.WebFileLoader.UpdateFile(String url, String filePath) 位置 D:\Work\Project\FZLaborDispatch\AppUpdater\WebFileLoader.cs:行号 109
在 Microsoft.Samples.AppUpdater.ServerManifest.Load(String url) 位置 D:\Work\Project\FZLaborDispatch\AppUpdater\ServerManifest.cs:行号 50
在 Microsoft.Samples.AppUpdater.AppUpdater.CheckForUpdates() 位置 D:\Work\Project\FZLaborDispatch\AppUpdater\AppUpdater.cs:行号 277
在 Microsoft.Samples.AppUpdater.ServerPoller.RunThread() 位置 D:\Work\Project\FZLaborDispatch\AppUpdater\ServerPoller.cs:行号 125跟踪到代码中,发现在UpdateFile()函数中报错,现将代码公布如下:
public static void UpdateFile(string url, string filePath)
{
HttpWebResponse Response;
//Retrieve the File
HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);
Request.Headers.Add("Translate: f");
Request.Credentials = CredentialCache.DefaultCredentials; //Set up the last modfied time header
if (File.Exists(filePath))
Request.IfModifiedSince = LastModFromDisk(filePath); try
{
Response = (HttpWebResponse)Request.GetResponse();
}
catch(WebException e)
{
if (e.Response == null)
{
Debug.WriteLine("Error accessing Url " + url);
throw;
} HttpWebResponse errorResponse = (HttpWebResponse)e.Response;
//if the file has not been modified
if (errorResponse.StatusCode == HttpStatusCode.NotModified)
{
e.Response.Close();
return;
}
else
{
e.Response.Close();
Debug.WriteLine("Error accessing Url " + url);
throw;
}
}
Stream respStream = null; try
{
respStream = Response.GetResponseStream();
CopyStreamToDisk(respStream,filePath); DateTime d = System.Convert.ToDateTime(Response.GetResponseHeader("Last-Modified"));
File.SetLastWriteTime(filePath,d);
}
catch (Exception)
{
Debug.WriteLine("APPMANAGER: Error writing to: " + filePath);
throw;
}
finally
{
if (respStream != null)
respStream.Close();
if (Response != null)
Response.Close();
}
}
故障应该发生在Response = (HttpWebResponse)Request.GetResponse();行
请教大家有没有碰到类似的问题。使用的IIS7.0,开始怀疑是权限未配置,但是排查后发现不是权限问题。会是什么原因呢?请大家不吝赐教。
我在使用MS介绍其智能客户端时所涉及的两个通用的库 AppStart和AppUpdate进行客户端程序更新,当更新网站在windows2003,XP系统的IIS上均能成功使用,但是在windows server 2008 r2操作系统的IIS7.0 上却不能使用,报错:“System.Net.WebException: 远程服务器返回错误: (405) 不允许的方法”,经过调试,发现报错信息如下:
在 System.Net.WebException 中第一次偶然出现的“System.dll”类型的异常
Error accessing Url http://10.164.1.65/FZLD_Server/UpdateVersion.xml
在 System.Net.WebException 中第一次偶然出现的“AppUpdater.dll”类型的异常
System.Net.WebException: 远程服务器返回错误: (405) 不允许的方法。
在 System.Net.HttpWebRequest.GetResponse()
在 Microsoft.Samples.AppUpdater.WebFileLoader.UpdateFile(String url, String filePath) 位置 D:\Work\Project\FZLaborDispatch\AppUpdater\WebFileLoader.cs:行号 109
在 Microsoft.Samples.AppUpdater.ServerManifest.Load(String url) 位置 D:\Work\Project\FZLaborDispatch\AppUpdater\ServerManifest.cs:行号 50
在 Microsoft.Samples.AppUpdater.AppUpdater.CheckForUpdates() 位置 D:\Work\Project\FZLaborDispatch\AppUpdater\AppUpdater.cs:行号 277
在 Microsoft.Samples.AppUpdater.ServerPoller.RunThread() 位置 D:\Work\Project\FZLaborDispatch\AppUpdater\ServerPoller.cs:行号 125跟踪到代码中,发现在UpdateFile()函数中报错,现将代码公布如下:
public static void UpdateFile(string url, string filePath)
{
HttpWebResponse Response;
//Retrieve the File
HttpWebRequest Request = (HttpWebRequest)HttpWebRequest.Create(url);
Request.Headers.Add("Translate: f");
Request.Credentials = CredentialCache.DefaultCredentials; //Set up the last modfied time header
if (File.Exists(filePath))
Request.IfModifiedSince = LastModFromDisk(filePath); try
{
Response = (HttpWebResponse)Request.GetResponse();
}
catch(WebException e)
{
if (e.Response == null)
{
Debug.WriteLine("Error accessing Url " + url);
throw;
} HttpWebResponse errorResponse = (HttpWebResponse)e.Response;
//if the file has not been modified
if (errorResponse.StatusCode == HttpStatusCode.NotModified)
{
e.Response.Close();
return;
}
else
{
e.Response.Close();
Debug.WriteLine("Error accessing Url " + url);
throw;
}
}
Stream respStream = null; try
{
respStream = Response.GetResponseStream();
CopyStreamToDisk(respStream,filePath); DateTime d = System.Convert.ToDateTime(Response.GetResponseHeader("Last-Modified"));
File.SetLastWriteTime(filePath,d);
}
catch (Exception)
{
Debug.WriteLine("APPMANAGER: Error writing to: " + filePath);
throw;
}
finally
{
if (respStream != null)
respStream.Close();
if (Response != null)
Response.Close();
}
}
故障应该发生在Response = (HttpWebResponse)Request.GetResponse();行
请教大家有没有碰到类似的问题。使用的IIS7.0,开始怀疑是权限未配置,但是排查后发现不是权限问题。会是什么原因呢?请大家不吝赐教。
好像是这个原因,但是我的url是http://10.164.1.65/FZLD_Server/UpdateVersion.xml,请问*.xml的程序映射的可执行文件是什么?谢谢
http://www.cnblogs.com/tearer/archive/2012/10/24/2737823.htmlIIS7.5 伪静态 脚本映射 配置方法
http://technet.microsoft.com/zh-cn/library/cc771240
你好,我在设置 处理程序映射-》添加脚本映射 设置*.xml的脚本映射,但是不知道可执行程序选择什么,从网上搜索没看到,第一次接触这个,感觉7.0比5.1复杂多了
谢谢大家。
MIME类型:text/xml
http://10.164.1.65/FZLD_Server/UpdateVersion.xml
在浏览器中如果能访问,HttpWebRequest也应该能够直接访问的,采用GET方法应该是可以的,服务器默认设置就可以,无需特殊设置
急死我了,谢谢大家
{
string s;
int iExecThread; // Because you passed your original delegate in the asyncState parameter
// of the Begin call, you can get it back here to complete the call.
MethodDelegate dlgt = (MethodDelegate)ar.AsyncState; // Complete the call.
s = dlgt.EndInvoke(out iExecThread, ar);
//MessageBox.Show(String.Format("The delegate call returned the string: {0}, and the number {1}", s, iExecThread.ToString())); //Console.WriteLine(string.Format ("The delegate call returned the string: "{0}", and the number {1}", s,iExecThread.ToString() ) );
}