在MVC应用程序中将配置设置注入Javascript的最佳方法是什么?

jaf*_*ffa 7 asp.net-mvc-3

在MVC应用程序中将配置设置注入Javascript的最佳方法是什么?我已经看过如何使用ASP.NET webforms完成它,但不知道如何使用MVC.

@using System.Configuration
...

var checkTimer = @ConfigurationManager.AppSettings["CheckTimer"];
Run Code Online (Sandbox Code Playgroud)

在Web.config中:

<appSettings>        
    <!-- Polling timer to check for alerts -->
    <add key="CheckTimer" value="10000"/>    
</appSettings>
Run Code Online (Sandbox Code Playgroud)

但在我的渲染输出中,我得到以下内容:

var checkTimer = ;
Run Code Online (Sandbox Code Playgroud)

Dar*_*rov 7

var checkTimer = @Html.Raw(Json.Encode(ConfigurationManager.AppSettings["CheckTimer"]));
Run Code Online (Sandbox Code Playgroud)