Global vs Web.config

It seems that the Global and Web.config files can both serve the same purpose for items like a connection string or general error messages.  I was wondering what do most .NET developers choose to hold these settings?  any good rule of thumb on this?

2/17/2009 5:47:38 PM 1239 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 20
Get it on Google Play
Get it on Apple App Store

Global.asax isn't really used to store things like connection strings or global data.  True, you can use it to modify application variables, but Global.asax is more of an event manager, where web.config is more of a configuration data store.  Some of the common events in Global.asax that are implemented are:


void Application_Start(object sender, EventArgs e)
		//sometimes there is some initialization you'd
		//like to do on application variables when 
		//the application starts (not, this doesn't
		//typically work out to be once for an 
		//application's entire lifecycle.  Server
		//reboots and other things along those lines
		//will cause this to happen too

	void Session_Start(object sender, EventArgs e)
		//A typical place to increment your current 
		//user count
		int counter = Convert.ToInt32(Application.Get("numUserCount"));
		Application.Set("numUserCount", counter);

	void Session_End(object sender, EventArgs e)
		//A typical place to decrement your current 
		//user count
		int counter = Convert.ToInt32(Application.Get("numUserCount"));
		Application.Set("numUserCount", counter);

	void Application_Error(object sender, EventArgs e)
		//Maybe you'd like to track your errors in a

	void Application_End(object sender, EventArgs e)
		//Maybe you can track application end
		//events for performance monitoring
I never lose, some people are just better than me at winning.
2/17/2009 6:41:04 PM


I have this global.asax file in my web service project. I have placed some code in the Application_Start and Session_Start events.

Now when I try to put a breakpoint in these two events and try to debug, I do not find my debug step breaking into these lines.

Instead it directly breaks into another class file method. Am I missing something.

Is there a better way to do this.



4/9/2009 3:51:09 PM

Similar Artilces:

VS 2005 SP1 + .NET AJAX => automatically adds web.config in nested Web Application Project when opening project or solution
I get a 'Configuration Error' on an aspx page because VS added automatically a web.config to my nested Web Application Project where no web.config file should be. This effect I have noticed since I have installed SP1 and .NET AJAX Extensions. Why is VS 2005 adding the web.config file and how can I disable this behavior? Following is the content of the automatically added web.config file (comments omitted): <?xml version="1.0"?><configuration>    <appSettings/>    <connectionStrings/>    <system.web> &...

Copying VS.NET web project to Win 2003 and opening it in VS.NET
Hi all, Environment: ASP.NET 1.1; VS.NET Enterprise 2003; Windows Server 2003; IIS 6.0 I hope somebody can help me figure this out. I created a Web project on my XP Dev machine which I can open, run, debug and do everything else. I can "deploy" the project to my 2003 server and open the site in explorer browser. But now, I want to transfer the whole solution to my Win 2003 and continue the development and testing on it. So, I transferred the whole VS solution directory from my XP machine to the Win 2003 machine. I created a Web site (not a virtual directory under default...

web app vs web site vs web project
Could someone describe the differences between web sites, web apps and web projects? (or send me a link that contains this comparison?). Is one of these terms synonomous with another? What are the advantages/disadvantages of each?  How does one choose when starting new development? Can one type be converted into another?     Thank you. Here is my definition: Website: perspective of users. Collection of web pages.Webapp and project: perspective of developer (and webmasters). Collection of web pages and resouces (database, code, etc.). Maybe software installers...

Web Application Projects vs. Web Site Project- Where is Copy Project?
I have opted to use the Web App Project in 2005 (The 2003 Model) is the copy project missing when this model is used? It was there in 2003?Thank you,Patrick I wanted to bump this topic again to see if any Microsoft techs had any input on this

VS.NET vs. MSBuild web project compilation difference
Hi, Question is: Why would msbuild assume that a bin folder in my web project already contains its project references? I have a 2.0 solution which contains a local file system web project (among other class libraries). If I compile it inside Whidbey, there will be a \bin folder created for me and put in there all of the web project's dll references. Then later if I do in Whidbey Build->Clean Solution, the bin\ folder will not be removed nor will the contents of it. Therefore after that if I run in command line msbuild mysolution.sln, msbuild succeeds. However, if I do in Whidb...

Website Project vs. Web Application Project in Visual 2005
 Website Project vs. Web Application Project in Visual 2005 What are the main benefits of using a Web App project over a Website project or vice-versa? Web App Project: You have to jump through hoops to use edit and continue with a Web App where in a website it just works. I’ve figured this out with the help of ScottGu. Thanks! Web App Project: what are the *.aspx.designer.cs files for? Website Project: how do you set up the project to use a ...

Migrating from VS 2005 Web Site Projects to VS 2005 Web Application Projects witn vb and c# code
I've tring to migrate Web Site to Web Aplication in VS 2005. In my Web Site I have pages written using VB and C#. During converting to WA i choose VB and only pages with VB code i can migrate. If I choose C# as language for WA only pages with C# I can migrate. Is a way to migrate Web Site with mix of VB and C# code? Wieslaw Hi, As far as I know, The ASP.NET Web application doesn't support that C# application project contains VB page or VB application project contains C# page. But it can compile the different language class file in project. In your case, you can tr...

Benefits of creating a Web Deployment project for a Setup project for a website vs a Web Setup project
I'm creating an installer for a website.The only thing I require as input from the user (in Custom Actions) is settings for the web.config. My initial approach was to create a Deployment project from my web project ans use this as input to the Setup project.Couldn't I use a Web Setup project instead of a Web Deployment + Setup project to do the same thing?Issues I have found with the Web Deployment is that I cannot edit it's contents at installation time, I'm taking user input at installation time to write to the web.config that the Installer uses but of course this file is embedded in the Web Deployment projects output (I don't think this can be edited once the Web Deployment project has been compiled, correct me if I'm wrong please!!!!!) Hi, You can use a Web Deployment Project with a Web Setup Project. Create custom install actions in the Setup project and use the primary output of Web Deployment project. Since the custom actions will fire after the project has been physically deployed, there is no case of "modifying embedded" file as you will modify the file which is present in the user's installation directory. Hope this helps, VivekSocial Networking Platform in ASP.NET || Join now: CodeASP.NET Community Please mark the most helpful reply/replies as "Answer". I see, so the installation functionality works on the already installed website files, but is this not dictated by the developer pointing the functi...

How to open a VS.NET 2003 project in VS.NET 2002
My colleague created a ASP.NET project by VS.NET 2003. I can not open it by the VS.NET 2002 in my machine. Can I call my colleague to modify some settings on this project and so I can open it by 2002? How to do that? thx...

Converting project from VS:Net 2003 to Vs.Net 2005
Hi there,can anyone help with converting a project from Vs.NET 2003 to 2005. Its not the internal workings that are a problem but the organization...I understand that under mydocuments\visual Studio 2005\  there are 2 directories (amongst others)1 is projects1 is websitesin projects these store the sln file and all the code for a gui app for examplefor websites in projects is just the sln which points to the websites directory where all the code is for a website i.e. under \mydocs\visual studio 2005\websitesam i right?So in simple terms, what is the best way of importing my

C#.NET in VS.NET vs. C# in Web Matrix
Hi all, I am very new to .NET ... I realized C#.NET is only available from Visual Studio.NET ... however, I realized Web Matrix also allowed us to choose C# as language but not C#.NET ... they are not the same, right? If not, then why it's in Web Matrix which runs ASP.NET?? If I need to run C#.Net, I MUST GET VS.NET, right? Can C#.NET has the abality to create chat program? Thank you very much. C#.NET and C# are the same thing. JimMS MVP ASP.NET [VC++/MFC emeritus]Old Dog Learns New TricksPreferred programming language: cuneiform on clay tablets So ... that means I can use web matrix to create C#.NET web application? Hi, yes you can. C# and C#.NET are the same languages. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons....

Web Deployment Project / Setup Project and editable web.config
I'm working on an installer for a website. The Installer will prompt the user for the web settings such as as various AppSettings. How would you recommend implementing this? Below I describe my initial thoughts but they seem over complicated !!!! My first idea is to created the Web Deployment Project and create a web.config section overwrite file, and then using it in the usual manner to overwrite the web.config appSettings section at installation time.Property Pages->Deployment section to "appsettings=appsettings.config"Then to make this appsettings.config file editable by a Custom ...

VS.NET Open project from the web
Hi All, I have a webapplication running a server. I would like to develop the webapplication from another machine. How is this achieved? How does "Open project from the web" work? What do i need to do to set up my webapplication to do this? Do i have to be on the same network? Do both computer need to be part of a Domain? This goes back to another question i have regarding HOW a team of people work on the same webapplication?? What is the general procedure for doing this?? Thanks, rw As to how a team works on a web application, see this guide: Team Developm...

web.config VS global.asax
Please ! what is the main difference between web.config and global.asax ??? in ASP, I used to put global variables in global.asax, but now we have both of them... quite confusing.... looking for answer. thanks, Bei Hi, Take a look @ What is the difference between config.web and global.asax HTH K B ShajudeenAreYaar.comDubai, United Arab Emirates. In the simplest way: Web.config usually for setting configuration of the web application which may includes: security mode, and the application configuration key, debug mode, etc Global.asax contains a lot of events which affects your web application, such as Application_Start and End, Application_AuthenticateRequest, Application_Error. In these events you can create / add some codes for dealing with user authentication, and what to do when there is an error occur. For more info have a look on articles on MicrosoftShoot for the moon and if you miss, you'll still be in the stars...

Web Deployment Project - Config Properties
I'm using a Web Deployment Project to compile my web site. In the Property Pages - Configuration Properties - Deployment section, there is an option to 'Enable Web.config file section replacement'. I have this working to replace certain sections of my web.config for each build config (release/staging/dev). I think this makes sense so other developers do not have to remember to change the web.config file. HOWEVER, this only seems to work when replacing parts of web.config; such as appSettings, connectionString, etc. This would require me to have separate config files for each section and bui...

convert the web application from 2002 to 2003
hi how can i convert the web application from 2002 to 2003 and how i know that the application is made in 2002 and not in 2003 and thank for your time VS.NEt 2003 detects 2002 project format automatically when you try to open 2002 project with it. It also asks you if the project needs to be converted into 2003 format (if I remember right conversion must be done to use the project in 2003). If you say yes, it does the conversion and you don't have to do anything. Note that VS.NEt 2002 can't open 2003 projects.Thanks,Teemu KeiskiFinland, EU thank you for your...

vs2005 web application with vs2005 web deployment project build failed
We Migrated our faily large ASP.NET project (has several folder hierarchy and our aspx pages refers to usercontrols in parent folders) to a VS2005 Web Application (not web site) project.Migration went well. We can build and run the project successfully.But when we comes to deploy vs 2005 web application project we did not find publish web site option unfortunately.So we added a Web deployment project to our web application project. But we could not complie the web deployment projecteven though we can complie out web application project. We encounter the following error in all of our ascx pag...

Opening project created in VS.NET 2003 in VS.NET 2002?
hi everyone, Can this be done? i'm havin problems opening my applications. the solution file i created is not recognise by VS.NET 2002.. can anyone provide me with a solution? thanks very much.. It is not designed to do this, so don't think you are doing anything wrong. There is a tool designed to do this, it can be foundHERE You must register, but it is a free download. Hope this helps.Chris Paterra thanks very much.....

Is it possible to migrate VS2005 Web Application Project to VS2005 Web Site.
Good afternoon.On my first project using VS2005, it was a brand new project so we didn't have to face the migration issue.  As we were developing right after VS2005 was released, we created the code using File | New | Web Site.I have now moved onto my second project and this one is a migration from a previously existing .NET 1.1 codebase to .NET 2.0.   We are currently investigating the best approach for migrating this code from VS2003 to VS2005.  We are thinking that at least initially, we might convert the code into a VS2005 Web Application Project using the steps located at...

Which is best web application projects or Web site projects in VS 2008
Hi, Using VS.NET 2008 We are developing a web based product (inventory, accounts,etc). This product has DA, BO layers. We are currently using web site project model. We are using webdelopyemnt project for deploying at client place.I want to know that, which model Web site model or web applicaton model is a best model for applications?I read most of the blogs and also articles for knowing difference between these two models.  But I am not coming under conclusion.Let me know your views and alos best answers Regards S. Muhilan   As you probably know, the difference between...

Problem when deploying Web Application project over VS2005 Web Site project
Hi,  we ran into this issue yesterday evening when we were trying to deploy new code on production box. It was running previous version of our app that was VS 2005 Web Site project, but the new version was migrated into Web App project. New build was tested on sandbox and even on the same production machine (but under different, non public web site configured there) and was working fine. However, when we deployed on production web site, we got this error:Compiler Error Message: CS0246: The type or namespace name 'ProfileCommon' could not be found (are you missing a using directi...

How to deploy web project in VS 2005 using web setup project
I have developed a new .NET Web application in C#. It is working find in localhost, i want to deploy the application to the production server. Please let me know what are the steps i need to follow to create an MSI file with VS.NET Installer in VS 2005. When i am trying to create a websetup project with a new solution option, it is not giving me the primary output file selection, i mean to say i am not at all getting the list of resources to select in the drop down list and also my project in the projects drop down list. Please some boyd help me and tell me is there any thing need to be done...

How to deploy a VS.VB net project to websever withour
The VB app is developed on professional. I plan to deploy it on a web server that doesn't have Would the code behind files cause problems? Should I compile the app and deploy the assembly only? I'd appreciate some quickstart tips on how to deploy a VB project to websever withour Thanks. Please mark the post(s) that have helped you as "Answer" The only thing you would need to do is compile the project and push the .aspx files and the bin folder to the server, and of course any other sub-folders that are used in your app like images. The...

VS.NET Projects on the Net
If I'm done with a project/solution that I created with IIS(Localhost) and VS.NET, what files from the solution will I need to upload to the host? (Host in this case is Brinkster(Free Plan)) only the aspx and ascx files ... in the bin folder you will need the compiled dll files ... Also in the root you need: web.config and flobal.asax That's itVerhoeven Bart MCSD.NET Technical Project Leader There is only 2 files in the .bin folder. ..dll file and .pdb All the ACSX and ASPX files are in the project's folder. When ever I try building the project, I get nothing in the B...

Web resources about - Global vs Web.config -

29 Pictures Of Miley Cyrus’ Rogue Tongue (PHOTOS) - Global Grind
29 Pictures Of Miley Cyrus’ Rogue Tongue (PHOTOS) - Global Grind

Global Rich List
Didn't make it onto the yearly roll call of the mega-wealthy? Why not find out where you'd actually sit in comparison to the rest of the world? ...

Global Voices · Citizen media stories from around the world
Global Voices is an international community of bloggers who report on blogs and citizen media from around the world.

Global News Desk - Daily Current Affairs From All Continents
Exclusive news items from all corners of the globe, including UK and Europe, Middle East, Asia, Africa, and North and South America, delivered ...

Global climate model - Wikipedia, the free encyclopedia
Climate models are systems of differential equations based on the basic laws of physics , fluid motion , and chemistry . To “run” a model, scientists ...

Spike in global temperature fuels climate change fears
The recent spike in global temperatures have brought a two-degree warming world a bit closer, placing in sharper focus what needs to be done ...

Reed Hastings on Netflix's global algorithm
Founder Reed Hastings talks about changing viewing habits, the drive for more original content and its round-the-world reach.

Cadillac to ditch China-only LWB models for global 'right size'
... is scoring big with young Chinese buyers, and its bid to hang on to these wealthy consumers will have ramifications for the brand on a global ...

FINTECH BRIEFING: The UK's global ambitions — Android Pay gears up for UK launch — Kreditech's funding ...
... Hub to refer a firm to the other, guaranteeing the firm support and advice from the partner regulator. The competition to be the top global ...

Resources last updated: 3/28/2016 7:37:13 AM