Need to read appsettings from config file.

V

Valli

Hi,

I am desigining a web page in asp.net. My page contains a drop down list
which will get filled using an XML file in the application folder.
The drop down list gets filled up with data written in Javascript.

I am accessing the xm file using the javascript syntax.
var querystring
="http://localhost/Website/WebInterface/Asyncdropdownprocess.aspx?ID=E&SelectedValue="
+ document.getElementById('<%=ExchangeDropDownList.ClientID%>').value ;
xmlHttpReq.open('POST', querystring, true);

The error is - I am using 'localhost' to access the file. The page will get
accessed from lot of places. So the 'localhost' syntax provides error.
I need to replace the Server IP in the localhost place.

The Server IP will be given in the Web.Config file. I need to read the IP
from the config file & replace that in the localhost place.
How can I read the config item using Javascript?

Can anyone help me?
 
M

Mark Rae [MVP]

How can I read the config item using Javascript?

You can't.

You will need to read the value out of web.config server-side and then place
it into a hidden field which can be referenced client-side...
 
M

Mark Rae [MVP]

Thanks a lot .. It works fine.

I should have mentioned the potential security implications of this,
though...

Web.config is a "special" file in ASP.NET terms in that it can't be accessed
by a browser directly - if you type the full URL of your web.config into
your browser, you won't see it.

Placing a value from web.config into a hidden client-side field means that
it is downloaded to the browser as part of the HttpResponse, where it can be
easily read by anyone doing a View Source on the page.

If this represents a security risk to you, then you will need to rethink
this...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top