What is the equivalent of web.config for JavaScript code?

前端 未结 1 1633
感情败类
感情败类 2021-01-06 10:04

What is the equivalent of the .NET web.config for JavaScript code?

I\'m getting to grips with the use of the configuration details in the web.conf

相关标签:
1条回答
  • 2021-01-06 10:18

    You could describe a Global JS variable in your master page and use that.

    [Edit]
    In your web.config have

    <appSettings>
        <add key="appEnvironment" value="DEV"/>
    </appSettings>
    

    In your master page you would have something like this (I would recommend this done in the controller but for easiness)

    <script type="text/javascript">
        var envType = "@ConfigurationManager.AppSettings=["appEnvironment"]";
    </script>
    

    Then all you would need to do is just change the web.config. I am presuming you are using MVC

    0 讨论(0)
提交回复
热议问题