Reading web.config from JavaScript

You can generate your JavaScript from ASP.NET.

Then simply write the settings at the server-side to your var defaults like this:

var defaults = {
    inactivity: <%=ConfigurationManager.AppSettings["Inactivity"] %>
}

EDIT:

If you want to keep your JavaScript in static js files, you can still initialize your var defaults from a small <script> rendered by your ASP.NET application. Your settings would be global, just like the AppSettings in web.config.

Leave a Comment