473,766 Members | 2,172 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET 2.0: Global.asax Design Surface Gone

I have several ASP.NET 1.1 websites where I centralized a read-only dataset (i.e., one which no web page ever changed) and its
associated SqlDataAdapters .

In 2.0 I noticed that the Global.asax file does not have a design surface, so I can't drag and drop database components onto it.

I could configure all this stuff manually, but that would be a lot of work duplicating what the visual designers do just fine.
Besides, it would put me way behind the curve on getting that promised 70% productivity improvement that I'm guaranteed by switching
to ASP.NET 2.0 :).

Is there a way to use the visual database tools in ASP.NET 2.0 in a global setting for a website?

- Mark
Dec 23 '05 #1
4 4218
Hi Mark,

Welcome to ASPNET newsgroup.
As for the global.asax file component designing problem, yes, in asp.net
2.0/vs2005, the global.asax has changed to not use code behind(all code be
put in asax file by default). Also, ASP.NET 2.0 page no longer mainly rely
on component (draged droped on component designer for page). For data
accessing, we use the DataSource controls instead of the Components
(DataAdapter and DataSet....). And for your scenario, you need get a
global scope DataSet to let other pages read the static datas, you can use
the new VS 2005 DataSet wizard to create a TypedDataSet , the new typed
DataSet wizard will also help us create a TableAdapter, which simplifies
the code for creating TypedDataset, e.g:

suppose we've created the following DataSet and TableAdapter:
(the code will be put in App_code dir)

DataSet1, CategoriesTable Adapter, then we can just use the below code to
create the global dataset in Application_Sta rt event
void Application_Sta rt(object sender, EventArgs e)
{
// Code that runs on application startup
DataSet1TableAd apters.Categori esTableAdapter adapter = new
DataSet1TableAd apters.Categori esTableAdapter( );
DataSet1 ds1 = new DataSet1();
adapter.Fill(ds 1.Categories);

Application["g_data"] = ds1;
}

this is what is being easied through the net TableAdapter components.....
So the original work in asp.net 1.1/vs2003 is not divided into to parts:

1. Use IDE wizard to create the typedDataSet and TableAdapter,

2. Use the TableAdapter to get the TypedDataSet instance ....

Here are some msdn reference about the TableAdapter:
#TableAdapter Overview
http://msdn2.microsoft.com/en-us/library/bz9tthwx.aspx

#TableAdapter Configuration Wizard
http://msdn2.microsoft.com/en-us/library/dex7k4dw.aspx

#How to: Create TableAdapters
http://msdn2.microsoft.com/en-us/library/6sb6kb28.aspx

Thanks & Merry Christmas,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| NNTP-Posting-Date: Fri, 23 Dec 2005 00:05:14 -0600
| From: Mark Olbert <Ch*********@ne wsgroups.nospam >
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Subject: ASP.NET 2.0: Global.asax Design Surface Gone
| Date: Thu, 22 Dec 2005 22:05:14 -0800
| Organization: Olbert & McHugh, LLC
| Reply-To: ma**@arcabama.c om
| Message-ID: <ck************ *************** *****@4ax.com>
| X-Newsreader: Forte Agent 3.1/32.783
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Lines: 12
| X-Trace:
sv3-5Ntq93RzHckZwcp yWNViHv0C5LXsgf ulNlvYZG8LBTIms 4iqnfyXGL77l/orNaiRDiHQVShl
mtlY0sx!EOtCFvu Eclp6p544nSH9cV 0rVTIPp2hi5ArOt F2EIpsdi6DrPyi6 J5lK324SmvHHSpR w
cw==
| X-Complaints-To: ab***@giganews. com
| X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
| X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
| X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
| X-Postfilter: 1.3.32
| Path:
TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!ne wsfeed00.sul.t-online.de!t-onli
ne.de!border2.n ntp.dca.giganew s.com!border1.n ntp.dca.giganew s.com!nntp.giga n
ews.com!local01 .nntp.dca.gigan ews.com!news.gi ganews.com.POST ED!not-for-mail
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3667 26
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| I have several ASP.NET 1.1 websites where I centralized a read-only
dataset (i.e., one which no web page ever changed) and its
| associated SqlDataAdapters .
|
| In 2.0 I noticed that the Global.asax file does not have a design
surface, so I can't drag and drop database components onto it.
|
| I could configure all this stuff manually, but that would be a lot of
work duplicating what the visual designers do just fine.
| Besides, it would put me way behind the curve on getting that promised
70% productivity improvement that I'm guaranteed by switching
| to ASP.NET 2.0 :).
|
| Is there a way to use the visual database tools in ASP.NET 2.0 in a
global setting for a website?
|
| - Mark
|

Dec 23 '05 #2
Steven,

Just what I needed, thanks very much!

- Mark
Dec 23 '05 #3
Steven,

Something's not right with the approach you suggested:
void Application_Sta rt(object sender, EventArgs e)
{
// Code that runs on application startup
DataSet1TableAd apters.Categori esTableAdapter adapter = new
DataSet1TableA dapters.Categor iesTableAdapter ();
DataSet1 ds1 = new DataSet1();
adapter.Fill(ds 1.Categories);

Application["g_data"] = ds1;
}


If I take your approach, and try to access ds1 in the website using something like this:

DataSet1 GetDataSet1()
{
return (DataSet1) Application["g_data"];
}

an exception gets thrown because the Application object is null. Session won't work either, because the Session object is "...not
available in this context".

So where/how do I persist application-wide data?

And, while I'm at it, why in the world did Microsoft think it was a bright idea to so radically change the model for ASP.NET that it
broke every single website I've built in the last two and a half years????

Frankly, this new version of ASP.NET leaves a LOT to be desired.

- Mark
Dec 23 '05 #4
Thanks for your response Mark,

From the error you mentioned, seems the context your code executed can not
access the ApplicationStat e. Genearlly the ApplicaionState of an ASP.NET
application is available to all the pages, and the "Applicatio n" member
proeprty is associated with Page class and the Global class, so where did
you put the following code?

DataSet1 GetDataSet1()
{
return (DataSet1) Application["g_data"];
}

Anyway, we can get the current ASP.NET application's ApplicationStat e
through

HttpContext.Cur rent.Applicatio n (HttpContext.Cu rrent represent the
current execting worker thread's associated HttpContext...)
In addition, we also have some other approachs to provide application-wide
data, e.g:

using a certain class's static member property , or use the ASP.NET
Application Cache,

HttpContext.Cur rent.Cache....

Also, these variables are not available out of the ASP.NET page's
serverside lifecycle , so we need to make sure our code(referencin g them
are in the correct scope....).

Please feel free to post here if there're anything unclear or need any
further assistance..

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| NNTP-Posting-Date: Fri, 23 Dec 2005 13:26:52 -0600
| From: Mark Olbert <Ch*********@ne wsgroups.nospam >
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Subject: Re: ASP.NET 2.0: Global.asax Design Surface Gone
| Date: Fri, 23 Dec 2005 11:26:52 -0800
| Organization: Olbert & McHugh, LLC
| Reply-To: ma**@arcabama.c om
| Message-ID: <9j************ *************** *****@4ax.com>
| References: <ck************ *************** *****@4ax.com>
<ZP************ **@TK2MSFTNGXA0 2.phx.gbl>
| X-Newsreader: Forte Agent 3.1/32.783
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Lines: 33
| X-Trace:
sv3-X6cP5YBOWrdZgQ+ 7stoWYDwdlFOMVP LFgTlJu9YWANDk8 cQh4ou00XfNyhs9 pyWjvj8N7KNg
CSyFxg6!6w6ocRZ iSY1iqPcwYX8BT5 og6E9bNGPwDsiY9 aY4QjXDGdUQw8B8 20JYMeVEM3VWN6r E
dg==
| X-Complaints-To: ab***@giganews. com
| X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
| X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
| X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
| X-Postfilter: 1.3.32
| Path:
TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!ne wsfeed00.sul.t-online.de!t-onli
ne.de!border2.n ntp.dca.giganew s.com!border1.n ntp.dca.giganew s.com!nntp.giga n
ews.com!local01 .nntp.dca.gigan ews.com!news.gi ganews.com.POST ED!not-for-mail
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3668 34
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Steven,
|
| Something's not right with the approach you suggested:
|
| > void Application_Sta rt(object sender, EventArgs e)
| > {
| > // Code that runs on application startup
| > DataSet1TableAd apters.Categori esTableAdapter adapter = new
| >DataSet1TableA dapters.Categor iesTableAdapter ();
| > DataSet1 ds1 = new DataSet1();
| > adapter.Fill(ds 1.Categories);
| >
| > Application["g_data"] = ds1;
| > }
|
| If I take your approach, and try to access ds1 in the website using
something like this:
|
| DataSet1 GetDataSet1()
| {
| return (DataSet1) Application["g_data"];
| }
|
| an exception gets thrown because the Application object is null. Session
won't work either, because the Session object is "...not
| available in this context".
|
| So where/how do I persist application-wide data?
|
| And, while I'm at it, why in the world did Microsoft think it was a
bright idea to so radically change the model for ASP.NET that it
| broke every single website I've built in the last two and a half years????
|
| Frankly, this new version of ASP.NET leaves a LOT to be desired.
|
| - Mark
|

Dec 26 '05 #5

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

Similar topics

22
3796
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.
15
2470
by: randyr | last post by:
I am developing an asp.net app based on a previous asp application. in the asp applications global.asa file I had several <object id="id" runat="server" scope="scope" class="comclass"> tags for objects that the app used to speed up some global level data access and functionality. I have recoded the class libraries in .net and would like to acomplish the same functionality in asp.net.
5
15149
by: ad | last post by:
The Global.asax is code-inside with default. How to change Global.asax to code-behind?
2
2284
by: Michael Tissington | last post by:
How do I specify the CodeFile for my Global.asax file ? According to the documentation I can use the CodeFile attribute with Application, however when I try to use this I get an error saying that it not a valid attribute. <%@ Application Language="C#" Inherits="SQLView.Global" CodeFile="Global.asax.cs"%> --
11
8376
by: Ron | last post by:
I have a web project compiled with the new "Web Deployment Projects" plugin for VS2005. I'm deploying the web project to one assembly and with updateable option set to ON. When I'm running the generated code on a W2K3 server the application_start and any other event on the global.asax file won't fire. I added tracing and logging to make sure and I can see the code is just not execution. When running the same exact (deployed etc.) code on...
7
1686
by: Jason Kester | last post by:
Best I can tell, there are three basic ways you can deal with global error handling in ASP.NET. Namely: 1. Derive all your pages from a custom Page class, and override OnError() 2. Specify a custom 500 handler in Web.Config 3. Specify a custom 500 handler in IIS
8
13207
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project compiles & runs fine locally, but when I copy to the production machine, I get this error: Parser Error Message: Could not load type 'Global'. Source Error: Line 1: <%@ Application Codebehind="Global.asax.vb" Inherits="Global" %> Source...
12
10698
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I am trying to maintain a list of people who are currently "online" in SQL. I do this by adding a simple entry to a simple PeopleOnline table whenever someone logs in to my site. If they manually log OUT of the site, I have no problem deleting them from the PeopleOnline table. But if they just close the browser, I was assuming I'd have to use the Session_End() event in Global.asax even though I know that this will only occur once the...
0
9571
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10168
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...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8835
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
7381
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
5279
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...
1
3929
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
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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.