separate .cs file for global.asax

Discussion in 'ASP .Net' started by =?Utf-8?B?TGFycnkgRXBu?=, Sep 1, 2006.

  1. Simple question: I have a c# asp.net project that was given to me. It has
    the c# code within the <script> section of the global.asax file. I would
    rather have it in separate files; e.g., global.asax.cs; So, I deleted the
    existing global.asax file (there was nothing important in it yet), and went
    to add a new one through VS2005. I chose the "Global Application Class"
    (Global.asax) item from the list of new items. The "Place code in separate
    file" checkbox option is DISABLED! WHY?
    Thanks.
    =?Utf-8?B?TGFycnkgRXBu?=, Sep 1, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?TGFycnkgRXBu?=

    Teemu Keiski Guest

    Hi,

    if you want to add a code-behind class for global.asax, you do it by adding
    a class to App_Code (or into external class library) which derives from
    HttpApplication and then associate this class with global.asax by specifying
    CodeFile and Inherits attributes in @Application directive.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke

    "Larry Epn" <> wrote in message
    news:...
    > Simple question: I have a c# asp.net project that was given to me. It
    > has
    > the c# code within the <script> section of the global.asax file. I would
    > rather have it in separate files; e.g., global.asax.cs; So, I deleted the
    > existing global.asax file (there was nothing important in it yet), and
    > went
    > to add a new one through VS2005. I chose the "Global Application Class"
    > (Global.asax) item from the list of new items. The "Place code in
    > separate
    > file" checkbox option is DISABLED! WHY?
    > Thanks.
    Teemu Keiski, Sep 1, 2006
    #2
    1. Advertising

  3. Thanks for the reply. I know this construct and have manually put this into
    some files; however, I just don't know why VS2005 is being so stubborn. Is
    there a project or environment configuration setting that I can use to turn
    this on? The thing is that the option is ENABLED when I add a new web page,
    but not when I want to add a global.asax. It makes no sense.

    "Teemu Keiski" wrote:

    > Hi,
    >
    > if you want to add a code-behind class for global.asax, you do it by adding
    > a class to App_Code (or into external class library) which derives from
    > HttpApplication and then associate this class with global.asax by specifying
    > CodeFile and Inherits attributes in @Application directive.
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    > "Larry Epn" <> wrote in message
    > news:...
    > > Simple question: I have a c# asp.net project that was given to me. It
    > > has
    > > the c# code within the <script> section of the global.asax file. I would
    > > rather have it in separate files; e.g., global.asax.cs; So, I deleted the
    > > existing global.asax file (there was nothing important in it yet), and
    > > went
    > > to add a new one through VS2005. I chose the "Global Application Class"
    > > (Global.asax) item from the list of new items. The "Place code in
    > > separate
    > > file" checkbox option is DISABLED! WHY?
    > > Thanks.

    >
    >
    >
    =?Utf-8?B?TGFycnkgRXBu?=, Sep 1, 2006
    #3
  4. =?Utf-8?B?TGFycnkgRXBu?=

    Teemu Keiski Guest

    There is no setting for that. You need to set that manually

    See. http://dallas.sark.com/SarkBlog/cboland/archive/2005/11/14/2234.aspx
    and
    http://groups.google.com/group/micr...debehind VS2005&rnum=1&hl=en#69acb5c0fbd1bc54

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke


    "Larry Epn" <> wrote in message
    news:...
    > Thanks for the reply. I know this construct and have manually put this
    > into
    > some files; however, I just don't know why VS2005 is being so stubborn.
    > Is
    > there a project or environment configuration setting that I can use to
    > turn
    > this on? The thing is that the option is ENABLED when I add a new web
    > page,
    > but not when I want to add a global.asax. It makes no sense.
    >
    > "Teemu Keiski" wrote:
    >
    >> Hi,
    >>
    >> if you want to add a code-behind class for global.asax, you do it by
    >> adding
    >> a class to App_Code (or into external class library) which derives from
    >> HttpApplication and then associate this class with global.asax by
    >> specifying
    >> CodeFile and Inherits attributes in @Application directive.
    >>
    >> --
    >> Teemu Keiski
    >> ASP.NET MVP, AspInsider
    >> Finland, EU
    >> http://blogs.aspadvice.com/joteke
    >>
    >> "Larry Epn" <> wrote in message
    >> news:...
    >> > Simple question: I have a c# asp.net project that was given to me. It
    >> > has
    >> > the c# code within the <script> section of the global.asax file. I
    >> > would
    >> > rather have it in separate files; e.g., global.asax.cs; So, I deleted
    >> > the
    >> > existing global.asax file (there was nothing important in it yet), and
    >> > went
    >> > to add a new one through VS2005. I chose the "Global Application
    >> > Class"
    >> > (Global.asax) item from the list of new items. The "Place code in
    >> > separate
    >> > file" checkbox option is DISABLED! WHY?
    >> > Thanks.

    >>
    >>
    >>
    Teemu Keiski, Sep 2, 2006
    #4
  5. Hi Larry,

    Besides Teemu's input, you can also find related feedback here:
    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?Feedba
    ckID=104811. According to Visual Studio Product team, it will be considered
    in future version of Visual Studio. Thank you for your understanding.

    Sincerely,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Sep 4, 2006
    #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. VSK
    Replies:
    1
    Views:
    767
    Alvin Bruney
    Jul 29, 2003
  2. Daniel Bass
    Replies:
    2
    Views:
    6,857
    Daniel Bass
    Dec 31, 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:
    801
    =?Utf-8?B?YmNoYXJsZXM=?=
    Oct 5, 2004
  4. EvgueniB
    Replies:
    1
    Views:
    615
    Anthony Borla
    Dec 15, 2003
  5. Mark Rae

    Global.asax / Global.asax.cs in v2

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

Share This Page