Saturday, March 31, 2012

separate .cs file for global.asax

Simple question: I have a c# asp.net project that was given to me. It has
the c# code within the <scriptsection 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.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" <larryepn@.noemail.noemailwrote in message
news:4F16F9B8-3CD2-480E-8FF9-5911014EFF98@.microsoft.com...

Quote:

Originally Posted by

Simple question: I have a c# asp.net project that was given to me. It
has
the c# code within the <scriptsection 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.


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:

Quote:

Originally Posted by

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" <larryepn@.noemail.noemailwrote in message
news:4F16F9B8-3CD2-480E-8FF9-5911014EFF98@.microsoft.com...

Quote:

Originally Posted by

Simple question: I have a c# asp.net project that was given to me. It
has
the c# code within the <scriptsection 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.


>
>
>


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

See. http://dallas.sark.com/SarkBlog/cbo...11/14/2234.aspx
and
http://groups.google.com/group/micr...9acb5c0fbd1bc54
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Larry Epn" <larryepn@.noemail.noemailwrote in message
news:BDD1A75B-64E9-4BCB-BAAE-3DEDFD1A60CC@.microsoft.com...

Quote:

Originally Posted by

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

Quote:

Originally Posted by

>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" <larryepn@.noemail.noemailwrote in message
>news:4F16F9B8-3CD2-480E-8FF9-5911014EFF98@.microsoft.com...

Quote:

Originally Posted by

Simple question: I have a c# asp.net project that was given to me. It
has
the c# code within the <scriptsection 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.


>>
>>
>>


Hi Larry,

Besides Teemu's input, you can also find related feedback here:
https://connect.microsoft.com/Visua...ack.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 (wawang@.online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.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/subscript...rt/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

0 comments:

Post a Comment