Hi,
When you create a new web site in VS.NET 2005, it doesn't contain a
Global.asax file by default and, when you add one manually, it creates a
Global.asax file with in-line code e.g.
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
}
........
</script>
However, when upgrading from v1.x to v2, the Upgrade Wizard keeps the
existing Global.asax and Global.asax.cs files separate e.g.
<%@ Application Inherits="Global" Language="C#" %>
and
using System;
public class Global : System.Web.HttpApplication
{
protected void Application_Start(Object sender, EventArgs e)
{
// Code that runs on application startup
}
........
}
Someone asked me today why that was, since they had always been led to
believe that code-behind was better then in-line code - I didn't have an
answer as to why the default Global.asax file in v2 uses in-line code.
Does anyone know the reason(s) for this? I'd be interested to know if anyone
is using v2 this way. Are there any issues regarding compilation i.e. would
the Global.asax file have to be deployed with the full in-line code, or
would the v2 compiler wrap it into the site's DLL?
Any assistance gratefully received.
Mark 6 2126
There are a bunch of new compilation models in 2.0. One of them allows all
inline code to be precompiled and deployed.
One isn't better than the other. Prior to 2005, there wasn't intellisense
with inline which made codebehind more compelling. I can't tell u why the
upgrade wizard does it one way, but adding the file does it the other way.
To be honest, the best way, especially if you are worried about deploying
source code, is (and always has been) to use HttpModules instead of
global.asax..
Karl
-- http://www.openmymind.net/ http://www.fuelindustries.com/
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:eC**************@TK2MSFTNGP05.phx.gbl... Hi,
When you create a new web site in VS.NET 2005, it doesn't contain a Global.asax file by default and, when you add one manually, it creates a Global.asax file with in-line code e.g.
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup } ....... </script>
However, when upgrading from v1.x to v2, the Upgrade Wizard keeps the existing Global.asax and Global.asax.cs files separate e.g.
<%@ Application Inherits="Global" Language="C#" %>
and
using System;
public class Global : System.Web.HttpApplication { protected void Application_Start(Object sender, EventArgs e) { // Code that runs on application startup } ....... }
Someone asked me today why that was, since they had always been led to believe that code-behind was better then in-line code - I didn't have an answer as to why the default Global.asax file in v2 uses in-line code.
Does anyone know the reason(s) for this? I'd be interested to know if anyone is using v2 this way. Are there any issues regarding compilation i.e. would the Global.asax file have to be deployed with the full in-line code, or would the v2 compiler wrap it into the site's DLL?
Any assistance gratefully received.
Mark
"Karl Seguin [MVP]" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:%2****************@TK2MSFTNGP03.phx.gbl... There are a bunch of new compilation models in 2.0. One of them allows all inline code to be precompiled and deployed.
Yes indeed.
One isn't better than the other. Prior to 2005, there wasn't intellisense with inline which made codebehind more compelling. I can't tell u why the upgrade wizard does it one way, but adding the file does it the other way.
Fair enough.
To be honest, the best way, especially if you are worried about deploying source code, is (and always has been) to use HttpModules instead of global.asax..
I'm not particularly worried about it because I never write in-line code.
I've not had much occasion to look at HttpModules, other than this one: http://www.codeproject.com/aspnet/We...sp?msg=1494506 which I
use for every web app that needs SSL.
I should look more into HttpModules.
re: I didn't have an answer as to why the default Global.asax file in v2 uses in-line code
Because it saves a compilation step.
Anything you want/need to do in code-behind can be done inline.
Since global.asax has no renderable components,
there's nothing to be gained by using code-behind in it.
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:eC**************@TK2MSFTNGP05.phx.gbl... Hi,
When you create a new web site in VS.NET 2005, it doesn't contain a Global.asax file by default and, when you add one manually, it creates a Global.asax file with in-line code e.g.
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup } ....... </script>
However, when upgrading from v1.x to v2, the Upgrade Wizard keeps the existing Global.asax and Global.asax.cs files separate e.g.
<%@ Application Inherits="Global" Language="C#" %>
and
using System;
public class Global : System.Web.HttpApplication { protected void Application_Start(Object sender, EventArgs e) { // Code that runs on application startup } ....... }
Someone asked me today why that was, since they had always been led to believe that code-behind was better then in-line code - I didn't have an answer as to why the default Global.asax file in v2 uses in-line code.
Does anyone know the reason(s) for this? I'd be interested to know if anyone is using v2 this way. Are there any issues regarding compilation i.e. would the Global.asax file have to be deployed with the full in-line code, or would the v2 compiler wrap it into the site's DLL?
Any assistance gratefully received.
Mark
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:eo****************@TK2MSFTNGP05.phx.gbl... re: I didn't have an answer as to why the default Global.asax file in v2 uses in-line code Because it saves a compilation step.
Really? Doesn't inline code get compiled along with code-behind in v2?
Anything you want/need to do in code-behind can be done inline.
Anything...?
Since global.asax has no renderable components, there's nothing to be gained by using code-behind in it.
Fair enough, but there's nothing to be lost by using code-behind in it
either, right...?
This is quite interesting: http://www.dotnetheaven.com/Uploadfi...a-651ceba126cd
re: Because it saves a compilation step. Really? Doesn't inline code get compiled along with code-behind in v2?
Yes. It gets compiled *twice*.
If you use code-behind in global.asax/cs/vb, first the code-behind
script gets compiled, and then global.asax gets compiled.
*That* is the compilation step which is saved by not using code-behind in global.asax.
Why do you think it's convenient for global.asax to be compiled,
and then re-compiled, if there's no renderable code in it ?
re: Anything you want/need to do in code-behind can be done inline. Anything...?
Yes, anything.
Can you point to *anything* which can't be done inline
in global.asax which *can* be done in code-behind cs or vb ?
re: Fair enough, but there's nothing to be lost by using code-behind in it either, right...?
Sure, but why go through the extra effort for no gain ?
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markN-O-S-P-A-M.co.uk> wrote in message
news:O$**************@TK2MSFTNGP03.phx.gbl... "Juan T. Llibre" <no***********@nowhere.com> wrote in message news:eo****************@TK2MSFTNGP05.phx.gbl...
re: I didn't have an answer as to why the default Global.asax file in v2 uses in-line code
Because it saves a compilation step.
Really? Doesn't inline code get compiled along with code-behind in v2?
Anything you want/need to do in code-behind can be done inline.
Anything...?
Since global.asax has no renderable components, there's nothing to be gained by using code-behind in it.
Fair enough, but there's nothing to be lost by using code-behind in it either, right...?
This is quite interesting: http://www.dotnetheaven.com/Uploadfi...a-651ceba126cd
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl... re: Because it saves a compilation step. Really? Doesn't inline code get compiled along with code-behind in v2?
Yes. It gets compiled *twice*.
If you use code-behind in global.asax/cs/vb, first the code-behind script gets compiled, and then global.asax gets compiled.
*That* is the compilation step which is saved by not using code-behind in global.asax.
Fair enough.
Why do you think it's convenient for global.asax to be compiled, and then re-compiled, if there's no renderable code in it ?
I don't per se...
Can you point to *anything* which can't be done inline in global.asax which *can* be done in code-behind cs or vb ?
Of course I can't - that's why I asked the question in the first place.
Sure, but why go through the extra effort for no gain ?
No reason, I guess... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
by: John M |
last post by:
Hello,
On Microsoft Visual Studio .NET 2003,
I want to use some global elements,
that can be used in each one of my pages.
i.e I put a oleDBConnection on global.asax.vb
How can I use it...
|
by: Vishwanathan Raman |
last post by:
Hi
I have a declared a static DataSet object SOBJ in Global.asax.I also have a
localy defined DataSet LSOBJ in Global.asax which I am storing in Application
State.Is there any technical...
|
by: ad |
last post by:
The Global.asax is code-inside with default.
How to change Global.asax to code-behind?
|
by: Steve |
last post by:
I am new to this newsgroup & to .NET in general. I have been playing around
with Visual Studio .NET, building and rendering web pages using VB "code
behind" files. My problem / question is;
How...
|
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...
|
by: Al Santino |
last post by:
Hello,
I've created a simple C# web services project using Visual Studio 2005. My
service compiles and runs correctly when called by remote clients.
I'm able to step through the service in the...
|
by: thefritz_j |
last post by:
We just converted our VS2003 1.1 VB web project (which was working
fine) to VS2005 2.0 and now I get:
Parser Error Message: Could not load type '<Namespace>.'.
Source Error:
Line 1: <%@...
|
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...
|
by: =?Utf-8?B?UGF0Qg==?= |
last post by:
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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,...
|
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...
| |