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的问题吗?

+0

你看IIS日志以检查URI和参数是否正确来自Chrome? IE具有良好的HTML编码参数习惯。我不知道Chrome是否做到这一点(Firefox不)。 – Timores 2010-06-14 11:10:08

+0

我检查了日志文件: 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

回答