GlobalConstants.cs:
---------------------
namespace Utility
{
public static class GlobalConstants
{
public const string SecurtityKey = "gkjhhkjhykhihfsdjhglkjhgkdfjlghdsfklghfdgeriutyrthvbfkjghdfklghdfskghrtguiutert";
}
}
InviteUser.chtml:
--------------
<script type="text/javascript" src="@Url.Action("GlobalConstants")"></script>
<script type="text/javascript">
alert(constants.SecurtityKey);
</script>
UserManagementController.cs:
--------------------------------
public ActionResult GlobalConstants()
{
var constants = typeof(BasePage)
.GetFields()
.ToDictionary(x => x.Name, x => x.GetValue(null));
var json = new JavaScriptSerializer().Serialize(constants);
return JavaScript("var constants = " + json + ";");
}