MVC4 Beta: Important Change to DisplayMode


As many of you know the beta of MVC4 came out. Of course I downloaded and installed it.

I noticed my existing code such as…

DisplayModes.Modes.Insert(0, new DefaultDisplayMode("iPhone")
{
ContextCondition = (ctx => ctx.Request.UserAgent.IndexOf(
"iPhone", StringComparison.OrdinalIgnoreCase) >= 0)
});

gave an error “DisplayModes” does not exist in the current context. Wait a sec, I updated my references and everything, what gives.

well they threw something new in there.

the correct code is now..

DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("iPhone")
{
ContextCondition = (ctx => ctx.Request.UserAgent.IndexOf(
"iPhone", StringComparison.OrdinalIgnoreCase) >= 0)
});

Notice the

 DisplayModeProvider.Instance 

it replaced the older DisplayModes.

I am sure there is more. I will post them as I find them.

Advertisements