473,756 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What happened to the Global class code behing in 2.0?

Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax
code file.

In 1.1 I could have a code behind file for the global.asax file. This allow
for shared variables of the Global class. Note: I use these shared variables
for read only values that are set at application start.

It would appear the 2.0 doesn't like you to use shared variables in the
global class. How do I convert my 1.1 applications to 2.0 without the
ability to have these shared variables?

Why would Microsoft get rid of the global.asax code behind? There must a
reason and a good conversion method (I hope).
--
Pat B
BCC Software, Inc
A BÖWE BELL + HOWELL COMPANY
Jul 16 '07
15 2571
re:
!Try to add a shared variable? You can't do it without a code behind file
!with a class definition. At least I couldn't get it to do it.

Why can't you use an Application Variable to do that ?

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"PatB" <Pa**@community .nospamwrote in message news:7A******** *************** ***********@mic rosoft.com...
Bruce,

Try to add a shared variable? You can't do it without a code behind file
with a class definition. At least I couldn't get it to do it.

--
Pat B
BCC Software, Inc
A BÖWE BELL + HOWELL COMPANY
"bruce barker" wrote:
>there is no need for a codebehind file. you just put the code in
global.asax file. as there is nothing but the code in the global.asax
file, 2 files don't make much sense.

-- bruce (sqlwork.com)


PatB wrote:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax
code file.

In 1.1 I could have a code behind file for the global.asax file. This allow
for shared variables of the Global class. Note: I use these shared variables
for read only values that are set at application start.

It would appear the 2.0 doesn't like you to use shared variables in the
global class. How do I convert my 1.1 applications to 2.0 without the
ability to have these shared variables?

Why would Microsoft get rid of the global.asax code behind? There must a
reason and a good conversion method (I hope).


Jul 16 '07 #11
let's deal with one issue at a time or we will all get confused!
Web Site Project - the original ASP.NET model that shipped with Visual
Studio 2005.
Web Application Project - the new model that is similar to Visual Studio
2003 (has a project file, builds a single dll assembly). This was an add-on
delivered in 2006 and is now standard as of Service Pack 1.

AJAX projects are a separate issue, but you should still be able to do the
codebehind as explained by others in this thread.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder( BETA): http://www.blogmetafinder.com

"PatB" wrote:
Peter,

I created a ASP.NET AJAX-enabled Web application.

Your comments confuse me. What's the difference between Web Site Project
model amd the Web Application Project model? How do I switch or create a Web
Application Project Model? Am I missing something during the project creation?

Thank you,

--
Pat B
BCC Software, Inc
A BÖWE BELL + HOWELL COMPANY
"Peter Bromberg [C# MVP]" wrote:
If you're "just starting" to move into ASP.NET 2.0, then it's not too late to
start developing good habits. One that I've gotten is NOT to use the Web Site
Project model, but the Web Application Project model for building my "stuff".
The original global.asax codebehind arrangement is preserved. My humble
opinion, of course.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder( BETA): http://www.blogmetafinder.com

"PatB" wrote:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax
code file.
>
In 1.1 I could have a code behind file for the global.asax file. This allow
for shared variables of the Global class. Note: I use these shared variables
for read only values that are set at application start.
>
It would appear the 2.0 doesn't like you to use shared variables in the
global class. How do I convert my 1.1 applications to 2.0 without the
ability to have these shared variables?
>
Why would Microsoft get rid of the global.asax code behind? There must a
reason and a good conversion method (I hope).
>
>
--
Pat B
BCC Software, Inc
A BÖWE BELL + HOWELL COMPANY
Jul 16 '07 #12
I could use an application variable, but they are not strongly typed which
requires a conversion every time you use it.

Shared variables of the global class are typed and do not require a
conversion.

--
Pat B
BCC Software, Inc
A BÖWE BELL + HOWELL COMPANY
"Juan T. Llibre" wrote:
re:
!Try to add a shared variable? You can't do it without a code behind file
!with a class definition. At least I couldn't get it to do it.

Why can't you use an Application Variable to do that ?

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"PatB" <Pa**@community .nospamwrote in message news:7A******** *************** ***********@mic rosoft.com...
Bruce,

Try to add a shared variable? You can't do it without a code behind file
with a class definition. At least I couldn't get it to do it.

--
Pat B
BCC Software, Inc
A BÖWE BELL + HOWELL COMPANY
"bruce barker" wrote:
there is no need for a codebehind file. you just put the code in
global.asax file. as there is nothing but the code in the global.asax
file, 2 files don't make much sense.

-- bruce (sqlwork.com)


PatB wrote:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax
code file.

In 1.1 I could have a code behind file for the global.asax file. This allow
for shared variables of the Global class. Note: I use these shared variables
for read only values that are set at application start.

It would appear the 2.0 doesn't like you to use shared variables in the
global class. How do I convert my 1.1 applications to 2.0 without the
ability to have these shared variables?

Why would Microsoft get rid of the global.asax code behind? There must a
reason and a good conversion method (I hope).




Jul 16 '07 #13
re:
!Shared variables of the global class are typed and do not require a conversion.

To each his own, depending on his coding preferences, I guess.

I wouldn't sacrifice performance for a coding preference, though.

Even though the difference is not really critical,
compiling somthing twice doesn't appeal much to me.

;-)

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== ========
"PatB" <Pa**@community .nospamwrote in message news:E0******** *************** ***********@mic rosoft.com...
>I could use an application variable, but they are not strongly typed which
requires a conversion every time you use it.
Shared variables of the global class are typed and do not require a conversion.

--
Pat B
BCC Software, Inc
A BÖWE BELL + HOWELL COMPANY
"Juan T. Llibre" wrote:
>re:
!Try to add a shared variable? You can't do it without a code behind file
!with a class definition. At least I couldn't get it to do it.

Why can't you use an Application Variable to do that ?

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
============== =============== =========
"PatB" <Pa**@community .nospamwrote in message news:7A******** *************** ***********@mic rosoft.com...
Bruce,

Try to add a shared variable? You can't do it without a code behind file
with a class definition. At least I couldn't get it to do it.

--
Pat B
BCC Software, Inc
A BÖWE BELL + HOWELL COMPANY
"bruce barker" wrote:

there is no need for a codebehind file. you just put the code in
global.asax file. as there is nothing but the code in the global.asax
file, 2 files don't make much sense.

-- bruce (sqlwork.com)


PatB wrote:
Just starting to move to ASP.NET 2.0 and having trouble with the Global.asax
code file.

In 1.1 I could have a code behind file for the global.asax file. This allow
for shared variables of the Global class. Note: I use these shared variables
for read only values that are set at application start.

It would appear the 2.0 doesn't like you to use shared variables in the
global class. How do I convert my 1.1 applications to 2.0 without the
ability to have these shared variables?

Why would Microsoft get rid of the global.asax code behind? There must a
reason and a good conversion method (I hope).



Jul 16 '07 #14
Thanks for Juan's input.

Hi Pat,

As Juan mentioned, due to the new dynamic compilation model, in ASP.NET
2.0, it prefer to use the inline code model for global.asax. However, you
can still use a codebehind class(define in App_Code dir) and inherit it in
@Application directive.

Or you can also direclty put a separate partial class file(ASP.NET 2.0
specific model) with the global.asax(nam ed global.asax.cs) . e.g.
====in global.asax==== =======
<%@ Application Language="C#" CodeFile="Globa l.asax.cs" Inherits="Globa l"
%>
====global.asax .cs=========
public partial class Global : HttpApplication
{
........
=============== =============

In addition, for sharing some global variables, in ASP.NET 2.0 application,
I think you can consider using the following means instead of define them
in global class:

You can create a dedicated utility class(mark as public) and define some
static(shared) member variables in it so that other pages can access them.
How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Jul 17 '07 #15
Hi Pat,

Have you got any further idea on this? If you have any other questions,
please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 19 '07 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
19124
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
121
10135
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
17
5630
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm constantly running tests on imperfect code. On of the cumbersome jobs encountered is reassigning global vars their values after a close encounter with an untrapped runtime error. Rather than writing a procedure to simply reassign them all with a...
4
2424
by: Leo Muller | last post by:
I am about to deploy my first ASP.NET project. But, I was used to store my variables, such as connection strings, in the global.asa file, in an application. However, these variables are different on my development and production server. If I use the global.asax file, then it is in the code behing, compiled part. Thus I can't change the setting on my production server. So where is the right place to save my connecting string? Leo
22
3795
by: fd123456 | last post by:
Hi Tom ! Sorry about the messy quoting, Google is playing tricks on me at the moment. > Global.asax is where you normally have the Global Application > and Session variables and code to manipulate them. It starts > and ends with <script></script> tags. > > Yours looks like a compiled version of it.
4
2368
by: Chris | last post by:
Hi, I want to put the namespaces and the data connection into global.asax like this: <%@ import namespace="System.Data"%> <%@ import namespace="System.Data.OleDb"%> <script runat="server"> Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) Dim oConnection As System.Data.OleDb.OleDbConnection oConnection = New System.Data.OleDb.OleDbConnection()
12
8646
by: =?Utf-8?B?QnJhZA==?= | last post by:
i dont understand this behaviour... i open a vb form i created and want to save it as a new name and make some changes when i do (in vs2005) the original form looses its ui whats up with that??? it turned into a straight class
4
1679
by: lightaiyee | last post by:
Dear Gurus, I would like to implement a function that computes the number of times a certain condition is met in a global array. For example, I have an global array of size 500. float array; I have a function that finds the maximum of an array of size 50. bool findMax50(float input)
8
1535
by: Viktor | last post by:
Can somebody give me an explanation what happened here (or point me to some docs)? Code: HMMM = None def w(fn): print 'fn:', id(fn) HMMM = fn
0
10014
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9844
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9689
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8688
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7226
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5119
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5289
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3780
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2647
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.