storing domain info in web.config, how??

Discussion in 'ASP .Net' started by Jeff, Feb 10, 2007.

  1. Jeff

    Jeff Guest

    Hey

    ASP.NET 2.0

    I'm working on a web site and I want info about the domain stored in
    web.config. By domain I mean for example: www.domain.com

    The reason I want info about the domain stored is that the web site will
    send email to it's registered users. This email will contain a link to a web
    page on the web site. If I don't know the domain then I must hard code it...
    When developing I can set the domain to localhost and on the final version I
    set to www.domain.com (where www.domain.com is just an example) . But I
    don't like the idea of hard coding this info.. I would like to change it
    without the need for hard coding

    So I'm wondering what setting in web.config can I use to store this info? or
    do I need to use a custom setting?

    Any suggestions?

    Jeff
     
    Jeff, Feb 10, 2007
    #1
    1. Advertising

  2. Morning Jeff,

    Is it separate thread that sends emails from a queue? Or, Do you send emails
    directly from a aspx page? in the first scenario, you must define it
    somewhere i.e. web.config, In second case you can easly determine it from
    current request:

    string emailLandinPageUrl = Request.Url.GetComponents(
    UriComponents.SchemeAndServer, UriFormat.Unescaped) +
    ResolveUrl("~/emailLandingPage.aspx?id=userid");
    --
    Milosz


    "Jeff" wrote:

    > Hey
    >
    > ASP.NET 2.0
    >
    > I'm working on a web site and I want info about the domain stored in
    > web.config. By domain I mean for example: www.domain.com
    >
    > The reason I want info about the domain stored is that the web site will
    > send email to it's registered users. This email will contain a link to a web
    > page on the web site. If I don't know the domain then I must hard code it...
    > When developing I can set the domain to localhost and on the final version I
    > set to www.domain.com (where www.domain.com is just an example) . But I
    > don't like the idea of hard coding this info.. I would like to change it
    > without the need for hard coding
    >
    > So I'm wondering what setting in web.config can I use to store this info? or
    > do I need to use a custom setting?
    >
    > Any suggestions?
    >
    > Jeff
    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Feb 10, 2007
    #2
    1. Advertising

  3. Jeff

    Jeff Guest

    WOW, thanks for that great tip

    "Milosz Skalecki [MCAD]" <> wrote in message
    news:...
    > Morning Jeff,
    >
    > Is it separate thread that sends emails from a queue? Or, Do you send
    > emails
    > directly from a aspx page? in the first scenario, you must define it
    > somewhere i.e. web.config, In second case you can easly determine it from
    > current request:
    >
    > string emailLandinPageUrl = Request.Url.GetComponents(
    > UriComponents.SchemeAndServer, UriFormat.Unescaped) +
    > ResolveUrl("~/emailLandingPage.aspx?id=userid");
    > --
    > Milosz
    >
    >
    > "Jeff" wrote:
    >
    >> Hey
    >>
    >> ASP.NET 2.0
    >>
    >> I'm working on a web site and I want info about the domain stored in
    >> web.config. By domain I mean for example: www.domain.com
    >>
    >> The reason I want info about the domain stored is that the web site will
    >> send email to it's registered users. This email will contain a link to a
    >> web
    >> page on the web site. If I don't know the domain then I must hard code
    >> it...
    >> When developing I can set the domain to localhost and on the final
    >> version I
    >> set to www.domain.com (where www.domain.com is just an example) . But I
    >> don't like the idea of hard coding this info.. I would like to change it
    >> without the need for hard coding
    >>
    >> So I'm wondering what setting in web.config can I use to store this info?
    >> or
    >> do I need to use a custom setting?
    >>
    >> Any suggestions?
    >>
    >> Jeff
    >>
    >>
    >>
     
    Jeff, Feb 10, 2007
    #3
  4. Jeff

    Leon Tayson Guest

    you can put it in your web.config's <appSettings> section...

    <appSettings>
    <add key="YourDomainKey" value=www.domain.com/>
    </appSettings>

    HTH,

    Leon

    "Jeff" <> wrote in message
    news:...
    > WOW, thanks for that great tip
    >
    > "Milosz Skalecki [MCAD]" <> wrote in message
    > news:...
    >> Morning Jeff,
    >>
    >> Is it separate thread that sends emails from a queue? Or, Do you send
    >> emails
    >> directly from a aspx page? in the first scenario, you must define it
    >> somewhere i.e. web.config, In second case you can easly determine it from
    >> current request:
    >>
    >> string emailLandinPageUrl = Request.Url.GetComponents(
    >> UriComponents.SchemeAndServer, UriFormat.Unescaped) +
    >> ResolveUrl("~/emailLandingPage.aspx?id=userid");
    >> --
    >> Milosz
    >>
    >>
    >> "Jeff" wrote:
    >>
    >>> Hey
    >>>
    >>> ASP.NET 2.0
    >>>
    >>> I'm working on a web site and I want info about the domain stored in
    >>> web.config. By domain I mean for example: www.domain.com
    >>>
    >>> The reason I want info about the domain stored is that the web site will
    >>> send email to it's registered users. This email will contain a link to a
    >>> web
    >>> page on the web site. If I don't know the domain then I must hard code
    >>> it...
    >>> When developing I can set the domain to localhost and on the final
    >>> version I
    >>> set to www.domain.com (where www.domain.com is just an example) . But I
    >>> don't like the idea of hard coding this info.. I would like to change it
    >>> without the need for hard coding
    >>>
    >>> So I'm wondering what setting in web.config can I use to store this
    >>> info? or
    >>> do I need to use a custom setting?
    >>>
    >>> Any suggestions?
    >>>
    >>> Jeff
    >>>
    >>>
    >>>

    >
    >
     
    Leon Tayson, Feb 10, 2007
    #4
  5. On Feb 10, 11:58 am, Milosz Skalecki [MCAD]
    <> wrote:
    > Morning Jeff,
    >
    > Is it separate thread that sends emails from a queue? Or, Do you send emails
    > directly from a aspx page? in the first scenario, you must define it
    > somewhere i.e. web.config, In second case you can easly determine it from
    > current request:


    You can still access it from another thread you just need to pass the
    URL as a prameter to the thread startup method...!!

    ..t

    --
    http://ajaxwidgets.com
    Free ASP.NET Ajax Widgets NOW!
     
    Thomas Hansen, Feb 11, 2007
    #5
  6. Good Evening Thomas,

    Of course, but read OP's question again. He asked if there was an autmatic
    way of detrmining the full url. You have to define site's URL before passing
    to HttpRequest or Uri constructor - right? This is not the case for separate
    email-sending thread created by you, because it does not serve the http
    request, so there is no HttpContext and you cannot automatically obtain
    application full URL using standard asp.net framework API.

    Regards
    --
    Milosz


    "Thomas Hansen" wrote:

    > On Feb 10, 11:58 am, Milosz Skalecki [MCAD]
    > <> wrote:
    > > Morning Jeff,
    > >
    > > Is it separate thread that sends emails from a queue? Or, Do you send emails
    > > directly from a aspx page? in the first scenario, you must define it
    > > somewhere i.e. web.config, In second case you can easly determine it from
    > > current request:

    >
    > You can still access it from another thread you just need to pass the
    > URL as a prameter to the thread startup method...!!
    >
    > ..t
    >
    > --
    > http://ajaxwidgets.com
    > Free ASP.NET Ajax Widgets NOW!
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Feb 11, 2007
    #6
    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. Matt

    Storing Enums in web.config

    Matt, Jun 7, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,614
  2. toton
    Replies:
    11
    Views:
    712
    toton
    Oct 13, 2006
  3. CSharpner
    Replies:
    0
    Views:
    1,047
    CSharpner
    Apr 9, 2007
  4. =?Utf-8?B?Qw==?=

    Problem storing a URL in my Web.config?

    =?Utf-8?B?Qw==?=, May 23, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    1,255
    =?Utf-8?B?Qw==?=
    May 23, 2007
  5. Jonathan Wood
    Replies:
    1
    Views:
    511
    Jonathan Wood
    Jun 2, 2008
Loading...

Share This Page