代码之家  ›  专栏  ›  技术社区  ›  synergetic

Silverlight 4、Google Chrome和HTTPWebRequest问题

  •  0
  • synergetic  · 技术社区  · 16 年前

    我的silvrlight 4应用程序托管在ASP.NET MVC 2中,通过Internet Explorer 8(开发服务器和远程Web服务器(IIS 6.0))使用时工作正常。但是,当我尝试浏览Google Chrome(5.0.375.70版)时,它抛出了“远程服务器返回未找到”错误。导致问题的代码如下:

    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时工作。有人能解释一下谷歌Chrome有什么问题吗?

    1 回复  |  直到 16 年前
        1
  •  0
  •   Community Mohan Dere    9 年前

    我发现问题与使用Google Chrome的ASP.NET MVC路由处理有关,因此打开了一个新问题:

    ASP.NET MVC routing issue with Google Chrome client