Need to read appsettings from config file.

Discussion in 'ASP .Net' started by Valli, Oct 17, 2007.

  1. Valli

    Valli Guest

    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?

    --
    Regards
    Valli
     
    Valli, Oct 17, 2007
    #1
    1. Advertising

  2. "Valli" <> wrote in message
    news:...

    > 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...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Oct 17, 2007
    #2
    1. Advertising

  3. Valli

    Valli Guest

    HI,

    Thanks a lot .. It works fine.
    --
    Regards
    Valli
    "Mark Rae [MVP]" <> wrote in message
    news:%...
    > "Valli" <> wrote in message
    > news:...
    >
    >> 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...
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
     
    Valli, Oct 17, 2007
    #3
  4. "Valli" <> wrote in message
    news:...

    > "Mark Rae [MVP]" <> wrote in message
    > news:%...
    >> "Valli" <> wrote in message
    >> news:...
    >>
    >>> 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...


    > 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...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Oct 17, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    3
    Views:
    3,761
    =?Utf-8?B?TG9yaSBNY0RvbmFsZA==?=
    Feb 23, 2004
  2. Jeff Robichaud

    <appSettings> in another file (not web.config)

    Jeff Robichaud, Feb 4, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    5,311
    DalePres
    Feb 5, 2005
  3. Jared Hagel
    Replies:
    2
    Views:
    3,363
    Jared Hagel
    Apr 7, 2005
  4. =?Utf-8?B?U2hhcmsgQmFpdA==?=

    Web.Config file path question "<appSettings file=..."

    =?Utf-8?B?U2hhcmsgQmFpdA==?=, Jun 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    7,802
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Jun 13, 2005
  5. Sergei Shelukhin
    Replies:
    1
    Views:
    1,187
    David
    Mar 29, 2007
Loading...

Share This Page