DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 13 Aug 2007 08:51:52 -0700,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Chris Peeters
          2    Teemu Keiski


global.asax in ASP.NET 2.0 ???   
Hi,

How do you use a global application class as in ASP.NET 1.0 ?

I try to use the following Global-class but it doesn't work at all:

In Global.asax:
<%@ Application Language="C#" CodeBehind="Global.asax.cs"
Inherits="Global" %>

In Global.asax.cs:

public partial class Global : System.Web.HttpApplication
{
	static string LOGFILENAME = @"c:\temp\cslog.txt";

	protected void Application_Start(object sender, EventArgs e)
	{
		StreamWriter sw = new StreamWriter(LOGFILENAME, bAppend);
		sw.WriteLine("Application_Start");
		sw.Close();
	}
}

When starting up, Application_Start() is not invoked at all!
(Know that the code generates no compiler error)

I know that one way to make things work is to put the event handlers in
a <script> - tag directly in Global.asax, 
but i want to put the code in a class. it gives more possibillities.

So, just how can you make a global-class work ?

thank you
Chris

*** Sent via Developersdex http://www.developersdex.com ***
Date:Mon, 13 Aug 2007 08:51:52 -0700   Author:  

Re: global.asax in ASP.NET 2.0 ???   
If you use the stock project model (web site model), you cannot write 
code-behind directly to global.asax. Instead you'd declare the class in 
App_Code and put the global.asax to inherit from it.

However if you use Web Application Project (Visual Studio 2005 Sp 1 feature 
/ add-in project model), then this should work fine.

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


"Chris Peeters"  wrote in message 
news:uN1reHc3HHA.1184@TK2MSFTNGP04.phx.gbl...

> Hi,
>
> How do you use a global application class as in ASP.NET 1.0 ?
>
> I try to use the following Global-class but it doesn't work at all:
>
> In Global.asax:
> <%@ Application Language="C#" CodeBehind="Global.asax.cs"
> Inherits="Global" %>
>
> In Global.asax.cs:
>
> public partial class Global : System.Web.HttpApplication
> {
> static string LOGFILENAME = @"c:\temp\cslog.txt";
>
> protected void Application_Start(object sender, EventArgs e)
> {
> StreamWriter sw = new StreamWriter(LOGFILENAME, bAppend);
> sw.WriteLine("Application_Start");
> sw.Close();
> }
> }
>
> When starting up, Application_Start() is not invoked at all!
> (Know that the code generates no compiler error)
>
> I know that one way to make things work is to put the event handlers in
> a <script> - tag directly in Global.asax,
> but i want to put the code in a class. it gives more possibillities.
>
> So, just how can you make a global-class work ?
>
> thank you
> Chris
>
> *** Sent via Developersdex http://www.developersdex.com *** 
Date:Mon, 13 Aug 2007 19:25:30 +0300   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us