473,804 Members | 2,194 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET 2/Global.asax/code-behind/Application_Sta rt

Hi,

I need to get a string from a COM component at application start. (It's a
Long Story and I cannot change this fact.) In ASP.NET 1.1, I simply called
this COM component in Global.asax.cs from Application_Sta rt, stuck the string
in the HttpApplication .Application object and life was good.

However, I've noticed in ASP.NET 2.0 you are not given the opportunity to
create a .cs codebehind file for the Global.asax when you go to ADD NEW
ITEM..., the PLACE CODE IN SEPERATE FILE grayed out. I know I can get around
this by manually creating a Global.asax.cs but I'm worried this is creating
some sort of risk.

A) What is the reason for not allowing a code behind file for Global.asax in
ASP.NET 2.0?

B) What would be the best way for my to get my string out of the COM object
at Application_Sta rt – I do not know how do COM interop from a CODE-INSIDE
file because it seems like you can not add the using statement (as in using
MyCOMobj;)?

Thanks,
Nick
Nov 19 '05 #1
4 2146
You can still handle the Application_Sta rt in the global.asax file. Other
than what file you put this method in, it's the same as before.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,

I need to get a string from a COM component at application start.
(It's a Long Story and I cannot change this fact.) In ASP.NET 1.1, I
simply called this COM component in Global.asax.cs from
Application_Sta rt, stuck the string in the HttpApplication .Application
object and life was good.

However, I've noticed in ASP.NET 2.0 you are not given the opportunity
to create a .cs codebehind file for the Global.asax when you go to ADD
NEW ITEM..., the PLACE CODE IN SEPERATE FILE grayed out. I know I can
get around this by manually creating a Global.asax.cs but I'm worried
this is creating some sort of risk.

A) What is the reason for not allowing a code behind file for
Global.asax in ASP.NET 2.0?

B) What would be the best way for my to get my string out of the COM
object at Application_Sta rt - I do not know how do COM interop from a
CODE-INSIDE file because it seems like you can not add the using
statement (as in using MyCOMobj;)?

Thanks,
Nick

Nov 19 '05 #2
re:
A) What is the reason for not allowing a code behind file
for Global.asax in ASP.NET 2.0?
Because it's not needed.

Anything you could possibly code in a code-behind file
for global.asax can be coded in global.asax itself.

global.asax is not like .aspx files.
It doesn't have a UI, so you can code directly in it.

Getting rid of code-behind in global.asax corrects an architectural mistake.

re: at Application_Sta rt - I do not know how do COM interop from a CODE-INSIDE
file because it seems like you can not add the using statement (as in using
MyCOMobj;)?
<%@ Import Namespace="MyCO Mobj" %>
<script language="C#" runat="server">

void Application_Sta rt(object sender, EventArgs e) {
// Application startup code goes here
}
</script>


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========
"NoNickname " <No********@noe mail.noemail> wrote in message
news:20******** *************** ***********@mic rosoft.com... Hi,

I need to get a string from a COM component at application start. (It's a
Long Story and I cannot change this fact.) In ASP.NET 1.1, I simply called
this COM component in Global.asax.cs from Application_Sta rt, stuck the string
in the HttpApplication .Application object and life was good.

However, I've noticed in ASP.NET 2.0 you are not given the opportunity to
create a .cs codebehind file for the Global.asax when you go to ADD NEW
ITEM..., the PLACE CODE IN SEPERATE FILE grayed out. I know I can get around
this by manually creating a Global.asax.cs but I'm worried this is creating
some sort of risk.

A) What is the reason for not allowing a code behind file for Global.asax in
ASP.NET 2.0?

B) What would be the best way for my to get my string out of the COM object
at Application_Sta rt - I do not know how do COM interop from a CODE-INSIDE
file because it seems like you can not add the using statement (as in using
MyCOMobj;)?

Thanks,
Nick

Nov 19 '05 #3
Thanks, Juan.

I did not know about Import Namespace. That did the trick.

Nick
Nov 19 '05 #4
You're very much welcome, Nick.

Sometimes it's the little things that trip us,
especially if they are not well documented.

;-)

Juan
=====
"NoNickname " <No********@noe mail.noemail> wrote in message
news:EB******** *************** ***********@mic rosoft.com...
Thanks, Juan.

I did not know about Import Namespace. That did the trick.
Nick

Nov 19 '05 #5

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

Similar topics

5
3945
by: WJ | last post by:
I am attempting to use the Global.Asax to store my user's configuration. Here is the concept: 1. User logs on into the site using Form Authentication. 2. I capture the user Credential, verify it and then assign this Logon ID (user) a so called User's serverside cookie. 3. My system is configured to accept 1,024 concurrent users, this means that my Global.Asax will host no more than 1,024 Logon IDs and their associated cookies/variables....
2
2436
by: Norton | last post by:
I understand how to create HTTP modules that can be used to add functionality to a website but there are a few things I don't understand. If I create an HTTP Module and I want it to intercept a call to AuthenticateRequest, I know that in my init function for my HTTP module, I can add a handler to this method name and then use this event handler delegate to call my own function. I saw some sample code though that mentioned (for some...
12
3843
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 (the oleDBConnection on global.asa.vb) at the other aspx pages ?
2
5216
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb file, and what would I do to access it? (I am using VB.NET for my code) Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
10
3040
by: Ronnie | last post by:
I've created a simple web application using VS2005 Beta 2. Basically, I've added a Web Form and a Global.asax file. In my Global.asax, I create a method like: public static void TestGlobal() { throw new Exception("Foobar"); }
0
2483
by: hynek.cihlar | last post by:
A strange behaviour thatI found in ASP.NET 2.0. I am trying to issue a callback request (handled by ICallbackEventHandler and RaiseCallbackEvent) and a regular GET request in the client browser and handle them at the same time - in parallel. The funny thing is that the behaviour of the implementation I created depends on the existence of Global.asax in the Web application. Here is the source of the page that handles the regular GET...
1
3318
by: Anonieko | last post by:
Global.asax? Use HttpModules Instead! In a previous post, I talked about HttpHandlers - an underused but incredibly useful feature of ASP.NET. Today I want to talk about HttpModules, which are probably more common than HttpHandlers, but could still stand to be advertised a bit more. HttpModules are incredibly easy to explain, so this will hopefully be a short-ish post. Simply put, HttpModules are portable versions of the global.asax....
11
8384
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...
4
3055
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 debugger unless I add a Global.asax file. When I do that and then try to run the debugger I receive error 403. If I remove the Global.asax file things work fine. The Global.asax file is the one generated by VS 2005 - I don't try to add anything...
16
5052
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: <%@ Application Codebehind="Global.asax.vb" Inherits="<Namespace>." %> I've done a lot of things I've found on the web to no avial, but here are some unique things about what is happening to me.
0
9715
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
10353
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...
1
10356
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
10099
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
9176
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...
0
5536
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
4314
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
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3003
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.