Scott Hanselman

Machineconfig versus webconfig Ive Gordon Weaklie

December 03, 2002 Comment on this post [0] Posted in Web Services | XML | Bugs | Tools
Sponsored By

Machine.config versus webconfig.

I've [Gordon Weakliem has] developed some pretty strong opinions on managing configurations, and I've got the scars (and a #12 ranking on Google ;-) ) to prove it.  Someone forwarded me this article by Jonathan Goodyear or ASP Today asking what I thought about storing app settings in machine.config versus web.config.  Off the top of my head, it sounded like a bad idea, but I'm willing to listen.  So I've read the article, and I still think it's a bad idea.  Jonathan's reason for discouraging use of web.config were:

  1. "this approach would require you to change your web.config settings every time you migrated your web application to a different environment"
  2. "Second, it is not a good idea for the development team to know what the QA and production database connection information is, so storing it in the web.config file doesn't make a whole lot of sense from a security perspective"

<snip>
The real headache with configuration comes with managing the configuration.  You need to be sure that as the application changes, the configuration stays up to date, and you need to coordinate use of the <appSettings> section among developers, so that they don't both use the same setting for divergent purposes.  [Gordon Weakliem's Radio Weblog]

I have a couple of thoughts on this...specifically as a retort to the two reasons Jonathan Goodyear had for not using Web.config.  First, yes you have to change some kind of configuration everytime you change environments, but that's easily fixed in a few different ways.

One thing we do is to have the config file during development include multiple configuration sections each named for the stage of dev the system's in and a VERY simple configurationHandler class to manage it.  Kind of an <appSettings environment="test | dev | production"/> kind of thing.  Of course, if Jonathan doesn't want some of the QA secrets known by the Dev team, this is less useful considering that until you strip the dev values at the time of production the config file represents the union of all possible keys.

An alternate way I use to update Config files is via a tool a wrote called ConfigPusher that takes an .config-style XML file that contains the UNION of all keys you'd need in all .config (web.config or otherwise) files - useful for a single logical application like ours that consists of multiple physical Web Apps and Web Services.  You call ConfigPusher from the command line and it updates only the keys that are present in each of the *.config files from the working directory down.  (The master file that represents the union updates only those keys in each config file that intersects with the larger set)  You have multiple configs for debug, test, production and you can update the whole bunch in one swell foop without much trouble.  Each team can have there own configs.  Sure, you're updating Web.config every time you change envionrments, but if this ConfigPusher stage is part of the automated build, so what?  Plus, I don't have to ever look at another config file in notepad again.  (And of course you don't put database connection into in for the production box, it goes in a secure secret location, ssh!) 

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

IMG height321 altA picture named ole2cdjpg hspace15 srchttpradioweblogscom0108971images20021203ole2cdjpg

December 03, 2002 Comment on this post [0] Posted in Web Services
Sponsored By

A picture named ole2cd.jpgCOM was love

This isn't an Enterprise Services crusade. There's a lot of very useful stuff and I am pointing it out. That's all ;)

However, I think I should admit that I did indeed have a very long affair with the entire ES/COM+/MTS/COM family. {Is that a nasty thing to admit?}. The love went away, now we're just good friends.  

October 1992. The first time COM got into customer's hands. I got this CD and I was like "man, that's nuts! Way too complicated!". The first shipment came with docs that dealt in very deep and great detail with IUnknown, structured storage and especially IMoniker. I didn't understand the moniker stuff until two years later. What I understood was AddRef()/Release() and QueryInterface(). An implementation of IUnknown became my default-base class for anything in November 1992. Only about 3 months later I understood how "outer IUnknowns" and aggregation worked. A lot of code-rewriting followed ;). It took about a year to realize that not *everything* should be a COM class. And so it went on and on....

And I just realize... there was no 10th birthday party;) 

[Clemens Vasters: Enterprise Development & Alien Abductions]

Ah, Clemens, you rock!  Thanks for bringing back memories of this CD.  Now I need to go dig up my copy! :)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Been doing some A hrefhttpmsdnmicrosoftcomlibrarydefaultaspurllibraryenuscpguidehtmlcpcondevelopinghighpe

November 27, 2002 Comment on this post [0] Posted in Web Services | ASP.NET | TechEd | Speaking | XML | Bugs
Sponsored By

Been doing some Web Gardening lately, and I'm disappointed at the lack of documentation on this supposedly powerful option for ASP.NET.  If I'm using a Quad-Proc Box and an ASP.NET Application that as some time is calling (via Interop) an inproc free-threaded C++ COM Component that then does some opereations and a (legacy) DCOM call out to another box, you'd think that having MaxWorkerThreads (per CPU) at some number x where 25<x<75 would be reasonable thing.  I would assume that a DCOM call (or Web Service call) would count as "waiting for an external resource" and that a few extra threads, and certainly a worker process per CPU would be ideal.  Per MSDN:

"If your application uses a slow database server or calls COM objects that have external dependencies, to name only a couple of possibilities, it can be beneficial to enable Web gardening for your application."

Certainly, this is vague at best.  Of course, everyone has seen the decks with one slide that mention Web Gardening, as well as books that spend a sentence on Web Gardening.  How do these ASPNET_WP.exe worker processes really behave?  I would presume it's as if one box becomes four...separate Cache Objects, separate Application objects. 

With Web Gardening, I'm seeing ASPNET_WP processes recycling constantly, and CoCreateInstance calls to my legacy DLLs failing.  However, without Web Gardening, things are peachy keen, and 30-50% better performance.

  • What are the ramifications for legacy COM and DOM calls within ASP.NET Worker Processes within a Garden?
  • Is Web Gardening just one of those many tweaks you give a try? 

Before this exercise, Web Gardening was an option in my architectural quiver...now (as it's not behaving at ALL like I'd have though) I'm not sure.

I'd had similar trouble in the past trying to tune MaxIoThreads and MaxWorkerThreads.  I had an ASP.NET application that was calling out to 2 or 3 Web Services, and when the system was under significant load, it would crap out - It was actually unable to get a free thread (from the system's thread pool I assume) to even get out of the box.  I was getting errors in the Socket Class, in the bowels of WebRequest.  Seemed that the box was SO busy dealing with the multiplicity of calls coming in (that were fanning out into n*2 outbound calls - ya, I know...) that it couldn't make the calls out...everyone blocked. (I even wondered if this was a nageling issue...or perhaps the HTTP stack not wanting too many calls (>2 [section 8.1.4]) out to the same server? ) And changing MaxIoThreads and MaxWorkerThreads from ANYTHING but the default of 25 was useless. 

  • Would it have been better to have written my own reserved thread pool and made the calls from there? 
  • Calling back to the Web Gardening problem...in the interest of throughput, should the calls to the COM object (that then calls out via DCOM to others) be made via my own worker thread pool? 
  • Or perhaps, from a COM+ application (That's what Clemens suggested).

These are the things that are currently disturbing my sleep...

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Automated Testing NET Web Services and Applications I just found Jim Klo

November 27, 2002 Comment on this post [0] Posted in Web Services | ASP.NET | NUnit | Nant | XML
Sponsored By

Automated Testing .NET Web Services and Applications

I just found Jim Klopfenstein's Executing ASMX files without a web server article. Jim's code could simplify most Web Service unit testing. And since it doesn't need IIS, or even ASP.NET, it would be easy to run during automated builds. Jim doesn't say, but I wouldn't be surprised if this is the reason he was trying to get this working.
I haven't thought much about it but you should be able to do the same thing for ASPX files. Has someone already done this?
[matt.griffith]

Interesting!  I knew that Cassini  (the ASP.NET "Host ASPNET_WP.EXE yourself" sample) and Web.Hosting, once "discovered", would cause good things to be built.  I'm sure if this was combined with my friend Jim Little's NUnitASP it could all be run within a NAnt automated build.

I wonder how hard it would be to insert an .NET interception layer/proxy server in between a Web Browser and ASP.NET to record the HTTP GETs and POSTs into a simple XML "recorder" file.  These could then be played back as part of an NUnit/NUnitASP Test and added to the build.  Regular expressions and and maybe an SGMLReader, also stored in the XML could validate the reponses...then I could stop using LoadRunner or SilkPeformer...

Has this app already been written? 

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Good article and primary on the basics of Cryptography and NE

November 26, 2002 Comment on this post [0] Posted in Web Services
Sponsored By

Good article and primary on the basics of Cryptography and .NET.

"Mark Strawmyer provides an overview of cryptography, covers the basics on some of what's available through the .NET Framework, and then focuses on the use of symmetric encryption to protect data such as user passwords."

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.