简体   繁体   中英

Get current display mode

Assuming the following custom mode provider:

DisplayModeProvider.Instance.Modes.Insert(1, new DefaultDisplayMode("CustomMode")
{
ContextCondition = //some bool logic
});

How can I get the current display mode from my code?

Following the documentation, the current display mode suffix will be the user agent. You could get it from HttpContext.Current.Request.UserAgent

In order to get the DisplayMode object, you can do:

var currentMode = DisplayModeProvider.Instance.Modes.SingleOrDefault(x => x.DisplayModeId == HttpContext.Current.Request.UserAgent);

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM