如何读取html的网页web.config设置? [英] How to read web.config settings in .html page?

查看:87
本文介绍了如何读取html的网页web.config设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET 3.5 Web表单。

我已经存储在web.config中添加一个名为文件版本键,我的网站的路径。

现在我一个简单的HTML页面,并想用这个静态的html页面上此键。
那么,如何做到这一点?或者是否有任何其它的办法吗?

I'm using ASP.NET 3.5 web forms.
I've stored my site path in web.config adding key named "CommonPath".
Now I've one simple html page and want to use this key on this static html page. So how can i do this? or Is there any other way for this?

在此先感谢

推荐答案

我在过去所做的是登记名.html网页是作为PTED动态页面间$ P $,太。 (即就像ASPX)。

What I did in the past was to register ".html" pages to be interpreted as dynamic pages, too. (I.e. just like ASPX).

这可以通过您的web.config文件来完成:

This can be done through your "web.config" file:

....
<system.web>
    <compilation ...>
        <buildProviders>
            <add extension=".html" 
                 type="System.Web.Compilation.PageBuildProvider" />
        </buildProviders>
    ....

....
<system.webServer>
    <handlers>
        <remove name="WebServiceHandlerFactory-Integrated" />
        <add name="PageHandlerFactory-Integrated-HTML" path="*.html" 
             verb="GET,HEAD,POST,DEBUG" type="System.Web.UI.PageHandlerFactory" 
             resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>
....

由于罗伯特指出,这与IIS 7行之有效和IIS 7.5(也可能是上面的版本,太)。如果使用的是IIS 6,您可以通过IIS管理控制台来做到这一点。

As Robert points out, this works well with IIS 7 and IIS 7.5 (and probably on above versions, too). If you are using IIS 6, you have to do it through the IIS Management Console.

这篇关于如何读取html的网页web.config设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆