是否可以更改 ASP.NET 4 WebForms 中的“DisplayModeProvider.Instance.Modes”集合?如果用户代理包含“iPhone”,我想将“Microsoft.AspNet.FriendlyUrls”的行为更改为仅重定向到页面的“.mobile”版本。Scott Hanselman 给了我这段代码,但我无法让它在 ASP.NET 4 WebForms 中工作。
放置在“Application_Start”中。
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iPhone")
{
ContextCondition = ctx => ctx.GetOverriddenUserAgent().Contains("iPhone")
});
任何帮助深表感谢!