谷歌浏览器的客户端ASP.NET MVC路由问题 [英] ASP.NET MVC routing issue with Google Chrome client

查看:131
本文介绍了谷歌浏览器的客户端ASP.NET MVC路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My Silverlight 4 app is hosted in ASP.NET MVC 2 web application. It works fine when I browse with Internet Explorer 8. However Google Chrome (version 5) cannot find ASP.NET controllers. Specifically, the following ASP.NET controller works both with Chrome and 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浏览器。此外,我使用自定义的模型绑定的控制器,所以如果我写了以下内容:

If I uncomment [OutputCache] attribute then it works with IE but not with Chrome. Also, I use custom model binding with controllers, so if I write the following:

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

它也可以与IE浏览器,但不再使用Chrome,给了我错误说资源没有被发现。当然,我配置了IIS 6处理通过ASPNET_ISAPI.DLL所有的请求,我已经注册的自定义模型绑定里面的Application_Start我的web应用程序的Global.asax中()方法。
有人可以解释我什么可能是原因是什么?谢谢你。

it also works with IE, but again not with Chrome which gives me error message saying that resource was not found. Of course, I configured IIS 6 for handling all requests via aspnet_isapi.dll and I have registered custom model binder in my web app's Global.asax inside Application_Start() method. Can someone explain me what might be the cause? Thank you.

推荐答案

好吧,我找到了一种方法来解决这个问题。在我的Silverlight应用程序,我选择了使用客户端堆栈,而不是使用默认的HTTP协议栈。

Ok, I found a way to solve this problem. In my silverlight app I opted for using client stack instead of using default http stack.

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

参见:<一href=\"http://blogs.msdn.com/b/silverlight_sdk/archive/2009/08/12/new-networking-stack-in-silverlight-3.aspx\" rel=\"nofollow\">http://blogs.msdn.com/b/silverlight_sdk/archive/2009/08/12/new-networking-stack-in-silverlight-3.aspx

这篇关于谷歌浏览器的客户端ASP.NET MVC路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆