我的代码中有这个:
<script type="text/javascript"
src="path?key=1234567890">
</script>
我在 web.config 中添加了这个:
<appSettings>
<add key="key" value="1234567890"/>
上面的代码如何实现?
最佳答案
您可以使用System.Web.Configuration.WebConfigurationManager.AppSettings
集合来访问配置设置。
<script type="text/javascript"
src="path?key=<%=WebConfigurationManager.AppSettings["key"]%>">
</script>
关于Javascript 文件 - 在运行时从 web.config 更改源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9703464/