本文整理汇总了C#中System.Web.HttpContextWrapper.ClearOverriddenBrowser方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContextWrapper.ClearOverriddenBrowser方法的具体用法?C# HttpContextWrapper.ClearOverriddenBrowser怎么用?C# HttpContextWrapper.ClearOverriddenBrowser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpContextWrapper
的用法示例。
在下文中一共展示了HttpContextWrapper.ClearOverriddenBrowser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnLoad
/// <summary>
/// Raises the <see cref="System.Web.UI.Control.OnLoad"/> event
/// </summary>
/// <param name="e">The event data</param>
protected override void OnLoad(System.EventArgs e)
{
if (!Page.IsPostBack)
{
HttpContextBase context = new HttpContextWrapper(Context);
Mobile = context.GetOverriddenBrowser().IsMobileDevice;
string view = (string)StateContext.Data[ViewKey];
StateContext.Data[ViewKey] = null;
if (view != null)
{
if ((Page.Request.Browser.IsMobileDevice && view == "mobile")
|| (!Page.Request.Browser.IsMobileDevice && view != "mobile"))
context.ClearOverriddenBrowser();
else
context.SetOverriddenBrowser(view == "mobile" ? BrowserOverride.Mobile : BrowserOverride.Desktop);
StateController.Refresh(new NavigationData(true));
}
}
base.OnLoad(e);
}
示例2: Session_Start
/// <summary>
/// This is necessary so that the response can be flushed without causing errors. DisplayModelForDebug wants to flush the
/// response.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
/// <remarks>
/// <para>
/// http://stackoverflow.com/questions/904952/whats-causing-session-state-has-created-a-session-id-but-cannot-save-it-becaus
/// </para>
/// <para>
/// At the start of a session, clear the overridden browser.
/// </para>
/// </remarks>
protected void Session_Start(object sender, EventArgs e)
{
string sessionId = Session.SessionID;
var wrapper = new HttpContextWrapper(this.Context);
wrapper.ClearOverriddenBrowser();
}