0
在開發服務器和遠程Web服務器(IIS 6.0)中都使用ASP.NET MVC 2託管的My Silvlight 4應用程序在通過Internet Explorer 8使用時工作正常。但是,當我嘗試瀏覽Google Chrome(版本5.0.375.70)時,它會拋出「遠程服務器返回未找到」錯誤。引起該問題的代碼如下:Silverlight 4,Google Chrome和HttpWebRequest問題
public class MyWebClient
{
private HttpWebRequest _request;
private Uri _uri;
private AsyncOperation _asyncOp;
public MyWebClient(Uri uri)
{
_uri = uri;
}
public void Start(XElement data)
{
_asyncOp = AsyncOperationManager.CreateOperation(null);
_data = data;
_request = (HttpWebRequest)WebRequest.Create(_uri);
_request.Method = "POST";
_request.BeginGetRequestStream(new AsyncCallback(BeginRequest), null);
}
private void BeginRequest(IAsyncResult result)
{
Stream stream = _request.EndGetRequestStream(result);
using (StreamWriter writer = new StreamWriter(stream))
{
writer.Write(((XElement)_data).ToString());
}
stream.Close();
_request.BeginGetResponse(new AsyncCallback(BeginResponse), null);
}
private void BeginResponse(IAsyncResult result)
{
HttpWebResponse response = (HttpWebResponse)_request.EndGetResponse(result);
if (response != null)
{
//process returned data
...
}
}
...
}
總之,上面的代碼發送一些XML數據到web服務器(到ASP.NET MVC控制器)和回來一個處理的數據。它在我使用Internet Explorer 8時有效。有人可以解釋Google Chrome的問題嗎?
你看IIS日誌以檢查URI和參數是否正確來自Chrome? IE具有良好的HTML編碼參數習慣。我不知道Chrome是否做到這一點(Firefox不)。 – Timores 2010-06-14 11:10:08
我檢查了日誌文件: Chrome:2010-06-15 01:45:39 W3SVC1452470319 10.1.1.22 POST/AppServices/ProcessData - 80 - 10.1.12.74 Mozilla/5.0 +(Windows; + U; + Windows + NT + 5.1 ; + en-US)+ AppleWebKit/533.4 +(KHTML,+ like + Gecko)+ Chrome/5.0.375.70 + Safari/533.4 500 0 0 IE:2010-06-15 01:48:14 W3SVC1452470319 10.1.1.22 POST/AppServices/ProcessData - 80 - 10.1.12.74 Mozilla/4.0 +(兼容; + MSIE + 7.0; + Windows + NT + 5.1; + Trident/4.0; +。NET + CLR + 2.0.50727; +。NET + CLR +3.0.4506.2152; +。NET + CLR + 3.5.30729; +。NET4.0C; +。NET4.0E)200 0 0 任何提示? – synergetic 2010-06-15 01:55:17