2012-03-14 6 views
2

ASP.NET MVC4ベータ版のモバイルアプリケーションで再生していますが、articleを使用していますが、表示モードに問題があります。つまり、私は私の_ViewStart.cshtml内ASP.NET MVC4モバイル:CS0103:現在のコンテキストに「DisplayModes」という名前がありません

@{ 
    ViewBag.Title = "ASP.NET Articles"; 
    DisplayModes.RequireConsistentDisplayMode = true;  
} 

を使用しようとするが、complitionのエラーを取得:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0103: The name 'DisplayModes' does not exist in the current context

いずれかは、同様のことを見ていますか?

+0

私はDisplayModesクラスはすべてで私だけのために利用可能でないことを追加します。 –

答えて

3

リンクされた記事は2011年9月12日からのものですので、APIを変更したようです。

(それはMVC4のベータ版で動作します)、これを試してみてください:

@{ 
    ViewBag.Title = "ASP.NET Articles"; 
    DisplayModeProvider.Instance.RequireConsistentDisplayMode = true; 
} 
+0

すばらしい答え、ありがとう! –

+1

すべてのページ要求に対して実行される_ViewStart.cshtmlに設定するのではなく、Global.asax.csのApplication_Startで 'DisplayModeProvider.Instance.RequireConsistentDisplayMode = true'を一度設定する方がよいでしょう。 –

関連する問題