0

I am working on an ASP.NEt application. In one of the ASPX page, in the tag, in a function, I need to use a value from the Web.config file. I tried using couple of options online, but it not working.

Is it a good idea to read web.config value like this? If not, then is there a better way to do it? Please help

0

1 Answer 1

1

The Web.config file should never be read by anything that is not part of your web application. If you need a value out of it there are classes in System.Web.Configuration or System.Configuration that do exactly that. You can then use the read value and embed it in the page itself.

Sign up to request clarification or add additional context in comments.

2 Comments

I agree, but when I use the System.Configuration in the Javascript function on ASPX page, its not working:"For example: <%ConfigurationManager.AppSettings["SiteRootURL"]%>"
You'll need to use it in the Page_Load handler in the code behind, assigning the value to a property you can then databind in the page itself.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.