ASP.NET 2/Global.asax/code-behind/Application_Start

Discussion in 'ASP General' started by NoNickname, Nov 8, 2005.

  1. NoNickname

    NoNickname Guest

    Hi,

    I need to get a string from a COM component at application start. (It's a
    Long Story and I cannot change this fact.) In ASP.NET 1.1, I simply called
    this COM component in Global.asax.cs from Application_Start, stuck the string
    in the HttpApplication.Application object and life was good.

    However, I've noticed in ASP.NET 2.0 you are not given the opportunity to
    create a .cs codebehind file for the Global.asax when you go to "Add New
    Item. . .". The "Place code in separate file" is grayed out. I know I can
    get around this by manually creating a Global.asax.cs but I'm worried this
    is creating some sort of risk.

    A) What is the reason for not allowing a code behind file for Global.asax in
    ASP.NET 2.0?

    B) What would be the best way for my to get my string out of the COM object
    at Application_Start – I do not know how do COM interop from a "code-inside"
    file because it seems like you can not add the "using" statement?

    Thanks,
    Nick
    NoNickname, Nov 8, 2005
    #1
    1. Advertising

  2. NoNickname

    [MSFT] Guest

    Hello,

    To add Application_Start() function in VS 2005, you can select "add new
    Items" and you will find "Global Application Class". This is different from
    VS 2003.

    Hope this help,

    Luke
    [MSFT], Nov 9, 2005
    #2
    1. Advertising

  3. There was no way for you to know it, but this is a classic asp newsgroup.
    While you may be lucky enough to find a dotnet-knowledgeable person here who
    can answer your question, you can eliminate the luck factor by posting your
    question to a group where those dotnet-knowledgeable people hang out. I
    suggest microsoft.public.dotnet.framework.aspnet.

    --
    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], Nov 9, 2005
    #3
    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. Max
    Replies:
    5
    Views:
    20,840
    liliancho
    Dec 7, 2011
  2. Bob Johnson
    Replies:
    4
    Views:
    988
    George Durzi
    Nov 13, 2003
  3. =?Utf-8?B?YmNoYXJsZXM=?=

    global.asax and global.asax.cs

    =?Utf-8?B?YmNoYXJsZXM=?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    797
    =?Utf-8?B?YmNoYXJsZXM=?=
    Oct 5, 2004
  4. =?Utf-8?B?Tm9OaWNrbmFtZQ==?=

    ASP.NET 2/Global.asax/code-behind/Application_Start

    =?Utf-8?B?Tm9OaWNrbmFtZQ==?=, Nov 9, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    6,316
    Juan T. Llibre
    Nov 9, 2005
  5. Mark Rae

    Global.asax / Global.asax.cs in v2

    Mark Rae, May 23, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    3,136
    Mark Rae
    May 23, 2006
Loading...

Share This Page