简体   繁体   English

从HTML JavaScript读取Web.Config AppSettings项。 可能?

[英]Read Web.Config AppSettings key from HTML JavaScript. Possible?

I'm trying to access a key that is in my web.config file from javascript in a static html page. 我正在尝试从静态html页面中的javascript访问web.config文件中的密钥。 I understand that having something like <%=ConfigurationManager.AppSettings["MyAttribute"]%> in the script works well for aspx or dynamic pages. 我了解脚本中具有<%=ConfigurationManager.AppSettings["MyAttribute"]%>之类的内容对于aspx或动态页面效果很好。

How can I achieve the same from a static html page? 如何从静态html页面实现相同目的? Is it possible? 可能吗? Can it be done just by using plain javascript or will I need to modify my config file? 可以仅使用普通的javascript来完成,还是需要修改配置文件?

Any assistance will be highly appreciated. 任何帮助将不胜感激。 Thanks. 谢谢。

Not possible to add scripting code in pain HTML unless you change ISAPI filters for html in IIS and add an httpHandler entry to the web.config to handle your page for html file. 除非在IIS中更改html的ISAPI过滤器并将一个httpHandler条目添加到web.config中以处理html文件的页面,否则无法在HTML中添加脚本代码。 Better you create a aspx page 更好地创建一个aspx页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM