DisplayModes give you another level of flexibility on top of the default capabilities we saw in the last section. DisplayModes can also be used along with the previous feature so we will simply build off of the site we just created.
Using display modes involves in 2 steps
- We should register Display Mode with a suffix for particular browser using “DefaultDisplayMode”e class inApplication_Start() method in the Global.asax file.
- View name for particular browser should be appended with suffix mentioned in first step.
- Desktop browsers (without any suffix. e.g.: Index.cshtml, _Layout.cshtml).
- Mobile browsers (with a suffix “Mobile”. e.g.: Index.Mobile.cshtml,Layout.Mobile.cshtml)
If you want design different pages for different mobile device browsers (any different browsers) and render them depending on the browser requesting. To handle these requests you can register custom display modes. We can do that using DisplayModeProvider.Instance.Modes.Insert(int index, IDisplayMode item) method.