473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 4203
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, CategoriesTableAdapter, then we can just use the below code to
create the global dataset in Application_Start event
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
DataSet1TableAdapters.CategoriesTableAdapter adapter = new
DataSet1TableAdapters.CategoriesTableAdapter();
DataSet1 ds1 = new DataSet1();
adapter.Fill(ds1.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*********@newsgroups.nospam>
| Newsgroups: microsoft.public.dotnet.framework.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.com
| 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-5Ntq93RzHckZwcpyWNViHv0C5LXsgfulNlvYZG8LBTIms4iqnf yXGL77l/orNaiRDiHQVShl
mtlY0sx!EOtCFvuEclp6p544nSH9cV0rVTIPp2hi5ArOtF2EIp sdi6DrPyi6J5lK324SmvHHSpRw
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.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!border1.nntp.d ca.giganews.com!nntp.gigan
ews.com!local01.nntp.dca.giganews.com!news.giganew s.com.POSTED!not-for-mail
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:366726
| X-Tomcat-NG: microsoft.public.dotnet.framework.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_Start(object sender, EventArgs e)
{
// Code that runs on application startup
DataSet1TableAdapters.CategoriesTableAdapter adapter = new
DataSet1TableAdapters.CategoriesTableAdapter();
DataSet1 ds1 = new DataSet1();
adapter.Fill(ds1.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 ApplicationState. Genearlly the ApplicaionState of an ASP.NET
application is available to all the pages, and the "Application" 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 ApplicationState
through

HttpContext.Current.Application (HttpContext.Current 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.Current.Cache....

Also, these variables are not available out of the ASP.NET page's
serverside lifecycle , so we need to make sure our code(referencing 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*********@newsgroups.nospam>
| Newsgroups: microsoft.public.dotnet.framework.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.com
| Message-ID: <9j********************************@4ax.com>
| References: <ck********************************@4ax.com>
<ZP**************@TK2MSFTNGXA02.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+7stoWYDwdlFOMVPLFgTlJu9YWANDk8cQh4o u00XfNyhs9pyWjvj8N7KNg
CSyFxg6!6w6ocRZiSY1iqPcwYX8BT5og6E9bNGPwDsiY9aY4Qj XDGdUQw8B820JYMeVEM3VWN6rE
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.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfee d00.sul.t-online.de!t-onli
ne.de!border2.nntp.dca.giganews.com!border1.nntp.d ca.giganews.com!nntp.gigan
ews.com!local01.nntp.dca.giganews.com!news.giganew s.com.POSTED!not-for-mail
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:366834
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Steven,
|
| Something's not right with the approach you suggested:
|
| > void Application_Start(object sender, EventArgs e)
| > {
| > // Code that runs on application startup
| > DataSet1TableAdapters.CategoriesTableAdapter adapter = new
| >DataSet1TableAdapters.CategoriesTableAdapter();
| > DataSet1 ds1 = new DataSet1();
| > adapter.Fill(ds1.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
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...
15
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...
5
by: ad | last post by:
The Global.asax is code-inside with default. How to change Global.asax to code-behind?
2
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...
11
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...
7
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...
8
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...
12
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.