Personally, i don't think different View
for each desktop browser is the way to go, the problems you're trying to address are probably Css
/JavaScript
issues and not related to the View
which basically should contain content and not functionality / design.
However, you can leverage the new DisplayModeProvider
mechanism (in MVC 4):
In your Global.asax
:
protected void Application_Start()
{
// Internet Explorer 9 (view prefix will be "ie9")
DisplayModeProvider.Instance.Modes.Add(new DefaultDisplayMode("ie9")
{
ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("MSIE 9.", StringComparison.OrdinalIgnoreCase) >= 0)
});
// Internet Explorer 8 (view prefix will be "ie8")
DisplayModeProvider.Instance.Modes.Add(new DefaultDisplayMode("ie8")
{
ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("MSIE 8.", StringComparison.OrdinalIgnoreCase) >= 0)
});
// Internet Explorer 7 (view prefix will be "ie7")
DisplayModeProvider.Instance.Modes.Add(new DefaultDisplayMode("ie7")
{
ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("MSIE 7.", StringComparison.OrdinalIgnoreCase) >= 0)
});
// Google Chrome (view prefix will be "chrome")
DisplayModeProvider.Instance.Modes.Add(new DefaultDisplayMode("chrome")
{
ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("Chrome", StringComparison.OrdinalIgnoreCase) >= 0)
});
// Mozilla Firefox (view prefix will be "firefox")
DisplayModeProvider.Instance.Modes.Add(new DefaultDisplayMode("firefox")
{
ContextCondition = (context => context.GetOverriddenUserAgent().IndexOf("Firefox", StringComparison.OrdinalIgnoreCase) >= 0)
});
In your Views
folder:
/Views/[Controler]/[Action].ie9.cshtml
/Views/[Controler]/[Action].ie8.cshtml
/Views/[Controler]/[Action].ie7.cshtml
/Views/[Controler]/[Action].chrome.cshtml
/Views/[Controler]/[Action].firefox.cshtml