Determining URL in Application_OnStart

Discussion in 'ASP General' started by David Logan, May 21, 2004.

  1. David Logan

    David Logan Guest

    Hello,

    I working on a project where we will be hosting several websites on
    the same server. These websites are built of a similar template and I
    want to use the URL as a key to get settings from the database. Is
    there a way to programatically get the website url in the
    application_onstart.

    I know I could hard code it in but that leaves things open to user
    error.

    Thanks

    David Logan
     
    David Logan, May 21, 2004
    #1
    1. Advertising

  2. David Logan

    Bob Lehmann Guest

    Request.ServerVariables("Server_Name")

    Bob Lehmann

    "David Logan" <> wrote in message
    news:...
    > Hello,
    >
    > I working on a project where we will be hosting several websites on
    > the same server. These websites are built of a similar template and I
    > want to use the URL as a key to get settings from the database. Is
    > there a way to programatically get the website url in the
    > application_onstart.
    >
    > I know I could hard code it in but that leaves things open to user
    > error.
    >
    > Thanks
    >
    > David Logan
     
    Bob Lehmann, May 21, 2004
    #2
    1. Advertising

  3. David Logan

    David Logan Guest

    Sorry Bob,

    Thats where I started but it won't work. You don't have access to the
    Request object in the Application_OnStartup. I'm looking to only have
    to do this one time not every time a user starts a session.

    Any other ideas?

    Thanks

    "Bob Lehmann" <> wrote in message news:<u4od$#>...
    > Request.ServerVariables("Server_Name")
    >
    > Bob Lehmann
    >
    > "David Logan" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > I working on a project where we will be hosting several websites on
    > > the same server. These websites are built of a similar template and I
    > > want to use the URL as a key to get settings from the database. Is
    > > there a way to programatically get the website url in the
    > > application_onstart.
    > >
    > > I know I could hard code it in but that leaves things open to user
    > > error.
    > >
    > > Thanks
    > >
    > > David Logan
     
    David Logan, May 21, 2004
    #3
  4. David Logan

    Bob Lehmann Guest

    Any reason not to do it in Session Start?

    Bob Lehmann


    "David Logan" <> wrote in message
    news:...
    > Sorry Bob,
    >
    > Thats where I started but it won't work. You don't have access to the
    > Request object in the Application_OnStartup. I'm looking to only have
    > to do this one time not every time a user starts a session.
    >
    > Any other ideas?
    >
    > Thanks
    >
    > "Bob Lehmann" <> wrote in message

    news:<u4od$#>...
    > > Request.ServerVariables("Server_Name")
    > >
    > > Bob Lehmann
    > >
    > > "David Logan" <> wrote in message
    > > news:...
    > > > Hello,
    > > >
    > > > I working on a project where we will be hosting several websites on
    > > > the same server. These websites are built of a similar template and I
    > > > want to use the URL as a key to get settings from the database. Is
    > > > there a way to programatically get the website url in the
    > > > application_onstart.
    > > >
    > > > I know I could hard code it in but that leaves things open to user
    > > > error.
    > > >
    > > > Thanks
    > > >
    > > > David Logan
     
    Bob Lehmann, May 21, 2004
    #4
  5. You don't have to do it "every" time a user starts a session. Only the first
    user. Use a variable in Application to indicate if the process was already
    done. If not, get the url and do the process, ending by setting the variable
    to indicate that the process is completed.

    Bob Barrows
    David Logan wrote:
    > Sorry Bob,
    >
    > Thats where I started but it won't work. You don't have access to the
    > Request object in the Application_OnStartup. I'm looking to only have
    > to do this one time not every time a user starts a session.
    >
    > Any other ideas?
    >
    > Thanks
    >
    > "Bob Lehmann" <> wrote in message
    > news:<u4od$#>...
    >> Request.ServerVariables("Server_Name")
    >>
    >> Bob Lehmann
    >>
    >> "David Logan" <> wrote in message
    >> news:...
    >>> Hello,
    >>>
    >>> I working on a project where we will be hosting several websites on
    >>> the same server. These websites are built of a similar template
    >>> and I
    >>> want to use the URL as a key to get settings from the database. Is
    >>> there a way to programatically get the website url in the
    >>> application_onstart.
    >>>
    >>> I know I could hard code it in but that leaves things open to user
    >>> error.
    >>>
    >>> Thanks
    >>>
    >>> David Logan


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], May 21, 2004
    #5
    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. yop
    Replies:
    4
    Views:
    440
  2. Shiv Kumar

    Global - Application_OnStart question

    Shiv Kumar, Jan 13, 2004, in forum: ASP .Net
    Replies:
    19
    Views:
    753
    Shiv Kumar
    Jan 14, 2004
  3. Marek

    Application_OnStart event

    Marek, May 9, 2004, in forum: ASP .Net
    Replies:
    8
    Views:
    487
    Scott Allen
    May 11, 2004
  4. =?Utf-8?B?QmlsbCBIZWNrbGU=?=

    Application_OnStart

    =?Utf-8?B?QmlsbCBIZWNrbGU=?=, Aug 16, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    343
    =?Utf-8?B?QnJhZCBRdWlubg==?=
    Aug 16, 2004
  5. =?Utf-8?B?TWlrZSBMb2dhbg==?=

    HTTP Module attaching to Application_OnStart

    =?Utf-8?B?TWlrZSBMb2dhbg==?=, Dec 17, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    4,702
    Steven Cheng[MSFT]
    Dec 31, 2004
Loading...

Share This Page