1

我的 Silverlight 4 应用程序托管在 ASP.NET MVC 2 Web 应用程序中。当我使用 Internet Explorer 8 浏览时它工作正常。但是 Google Chrome(版本 5)找不到 ASP.NET 控制器。具体来说,以下 ASP.NET 控制器适用于 Chrome 和 IE。

//[OutputCache(NoStore = true, Duration = 0, VaryByParam = "None")]
public ContentResult TestMe()
{
  ContentResult result = new ContentResult();
  XElement response = new XElement("SvrResponse", 
    new XElement("Data", "my data"));
  result.Content = response.ToString();
  return result;
}

如果我取消注释 [OutputCache] 属性,则它适用于 IE,但不适用于 Chrome。此外,我将自定义模型绑定与控制器一起使用,因此如果我编写以下内容:

public ContentResult TestMe(UserContext userContext)
{
  ...
}

它也适用于 IE,但同样不适用于 Chrome,它给我的错误消息是找不到资源。当然,我将 IIS 6 配置为通过 aspnet_isapi.dll 处理所有请求,并且我已经在我的 Web 应用程序的 Global.asax 中 Application_Start() 方法中注册了自定义模型绑定器。有人可以解释一下可能是什么原因吗?谢谢你。

4

3 回答 3

1

这并不能直接回答您的问题,但我建议您尝试Fiddler,并查看浏览器发送的实际请求。比较差异并尝试找出问题所在(您可以使用 Fiddler 中的“请求生成器”选项卡来嗯,摆弄参数)。

于 2010-06-15T07:00:36.320 回答
1

我发现WebRequest的两种方法:CreateCreateHttp在使用 HTTPS 时表现不同。始终使用Create方法根据协议实例化正确的请求。我有类似的情况,这就是我所拥有的。对于以下代码,我们在尝试使用WebRequest获取某些内容时出现Not Found异常:

HttpWebRequest request = WebRequest.CreateHttp(uri); 

但是下面的部分效果很好:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
于 2012-06-15T09:37:21.207 回答
0

好的,我找到了解决这个问题的方法。在我的 silverlight 应用程序中,我选择使用客户端堆栈而不是使用默认的 http 堆栈。

WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
WebRequest.RegisterPrefix("https://", WebRequestCreator.ClientHttp);

另请参阅:http: //blogs.msdn.com/b/silverlight_sdk/archive/2009/08/12/new-networking-stack-in-silverlight-3.aspx

于 2010-06-15T08:50:43.383 回答