Jerrold
Jerrold

Reputation: 1564

Possible read webconfig AppSetting in html?

i want to grab an AppSetting key from my webconfig in a regular .htm file - is this possible to do?

Normally id make it into an aspx file so i can do some codebehind something similar but the htm is out in the wild and i dont think i can change the url

Webconfig

<add key="SomeLocation" value="http://my.ip.address/"/>

Htm Markup

<a href="<%=MyCodeBehind()%>">Contact Us</a>

VB.Net Codebehind

    Public ReadOnly Property MyCodeBehind() As String
    Get
        Return General.GetAppSetting("SomeLocation")
    End Get
End Property

Thanks

Upvotes: 3

Views: 3000

Answers (1)

Eric J.
Eric J.

Reputation: 150138

A file that is not generated with any server-side processing cannot possibly include any additional data, per se.

You do have a few options (if I understand your problem correctly):

  • You can reconfigure the server to process ".htm" as an ASPX page and use your code behind.
  • You can redirect the specific URL to an ASPX page from the web server using rewrite rules

Upvotes: 2

Related Questions