1/28/2006

What's the World Coming to with Web Ads?

I just read here about how Google is going to add those absolutely nasty interstitials, expanding and floating ads to its Adsense portfolio.

Good God! I avoid any site that has this crap like the plague! How could they possibly expect people to put up with this utter crap and even stay on their site, much less click on one of these doozies! The quote:

"Floating ads are ads that either stay on top as the page is scrolled, or ones that "float in" from the side of the page to the center of the page. Expanding ads are those that require user interaction to expand, either with a mouseover or a click. Interstitials are perhaps the most interesting addition to this rich media beta, because they are a format that people love to hate, and that are often more annoying than pop-ups. You have likely stumbled across an interstitial ad - they appear when you click through to read a page, and before they will show you the page, you are bypassed through to a full page ad that you must view before seeing the actual content you were wanting, often by having to click a link on the interstitial ad page."

This person (whoever it is) is actually reporting this as if it is a "cool thing"! The people who design and promulgate this horrible crap should be taken out, lined up and shot, firing-squad style, IMHO!


Frankly, I wish there were a way to automatically ban these sites from my browsing experience. You know, some kind of a webservice that automatically puts them into your hosts file pointing to 127.0.0.1 or something like that! That would do the trick quite nicely.

Does anybody have anything like this?

1/26/2006

WebService? XML? SOAP? REST? What?

Look! Up in the sky! Is it a bird? Is it a plane? No! It's XML! Er, no -- its SOAP! No, scratch that - its --- its --- well, dang-it! Its Something, ain't it?

Interesting because what with all the so-called web "API's" put out by everybody and their little brother these days, its getting harder and harder to figure out what you are dealing with. if it's XML, did it come from a WebService? or is it just a resultset in XML format? Who the hell knows, right? Yahoo's new Web Search API's get called with REST - and return either RSS or some sort of XML resultset. There's XSD schemas for those, but no SOAP -- yikes!

This all became even more clear this evening when I was answering a post on the C# MS Newsgroup about how to deal with something that was obviously an XML Document representing a "result" object, but with no SOAP wrapper. The poster was asking essentially, "what's the best way to deal with this?".

Not long after, I ran into Simon Guest's blog where he has fortuitously laid out in black and white Arial 11 point type EXACTLY what he thinks are the determinants of what is a WebService. I reproduce them here:


1. Uses WSDL. A Web Service should expose its service contract using WSDL. If it can’t give you a WSDL document, it’s probably just XML over HTTP

2. Uses SOAP. All messages sent from and received by the Web Service must use SOAP formatting. If it’s not using SOAP it’s probably just XML over HTTP

3. Uses XSD. All data types in the SOAP payload must be XSD compliant. No platform native types are allowed. If it’s not using XSD it’s probably just XML over HTTP

4. Uses XML. The underlying messages should of course be formatted using XML.

5. No Arbitrary Binary Data. The message payload should 7 bit ASCII and should contain no embedded binary blobs. Any binary data passed over a Web Service should be sent using either SwA, DIME or MTOM (preferably MTOM).

6. Transport is likely to be HTTP. Although not a requirement, the majority of Web Services today use HTTP as the transport. Compliant Web Services should definitely work over HTTP.

7. Discovery can be through UDDI. Again although not a requirement, it should be possible to host the Web Service endpoint using UDDI.

8. Agreed Versions of Specifications. The versions of the above specifications (WSDL, SOAP, XSD, XML, HTTP, UDDI) should be in line with the latest version of the WS-I Basic Profile (http://www.ws-i.org) – to ensure Web Service compliance between vendors.

9. Operations should be Document Style. Operations to/from a Web Service should be Document/Message Style (e.g. SendOrder(order o)). RPC style should be avoided (e.g. SetOrderLine1(orderId id)).

10. Should be compliant with WS-*. Compliant Web Services should be able to accept WS-* payloads and extensions for Security, Reliability and Transactions (although not all stacks today support these yet).


Now, you can get all huffy and make excuses and attempt to eliminate some of the above based on this, that or the other. But the point is, this is the first time I have seen anybody possessing an above room-temperature IQ and some credentials actually lay it out and put a number in front of each Commandment.

The first 4 "Commandments" are so ubiquitous, and the standards so well set and agreed on, that they are really a no-brainer at this late stage of the game. Butter my butt and call me a biscuit, Mabel - if it don't offer WSDL, use SOAP, support XSD Schema, and come over as well-formed XML, it ain't a Webservice!

Nice, Simon! If I can find the first six, I'll be happy! One of the things I like about standards is -- you know there won't be any Filibusters. You either dig the standard, or you don't!


1/25/2006

Hot enough for ya?

Not long ago I wrote an entry about global warming and energy in the wake of rapidly rising oil prices.

According to NASA, last year was the warmest recorded on Earth's surface, and all five of the hottest years since modern record-keeping began in the 1890s occurred within the last decade. A spokesman indicated that it was "fair to say that it's the warmest in the last several thousand years."

Over the past 30 years, Earth has warmed by 1.08 degrees F, NASA said. Over the past 100 years, it has warmed by 1.44 degrees F. Most scientists attribute the rise to emissions of greenhouse gases such as carbon dioxide, methane and ozone, with the burning of fossil fuels being the primary source.

The 21st century could see global temperature increases of 6 to 10 degrees F, which will bring us up to the warmest temperatures the world has experienced probably in the last million years.

Yet, we continue to consume ever-increasing amounts of oil and coal, the byproducts of which continue to pour into the atmosphere. Hey, folks! This is the only atmosphere we have got! What the fyook are we doing? You worry about terrorists driving planes into big buildings? Don't worry about them--crap, we're committing suicide all by ourselves!

Here's a hopeful link though - the top 25 purchasers of renewable energy.

Meanwhile, the NYT reports that a NASA Climate physicist says he's being censored by the government.

In the meantime, we have the capability to run every car and truck in America on ethanol from corn, husks, whatever - produced riight here in the good old USA. CNN.com has an excellent article about what's happening with ethanol right now. Because cellulosic ethanol comes from cornstalks, grasses, tree bark--fibrous stuff that humans can't digest--it doesn't threaten the food supply at all. Genencor says its enzymes have brought cost of making a gallon of cellulosic ethanol down to 20 cents today. Hell, they could mark up the stuff 500% to $1.00 a gallon and I"d be happy to tell those yahoos over that-a-way to take a long walk off a short oasis.

<Segue>A study by the University of London's Institute of Psychiatry, commissioned by Hewlett-Packard, finds that "an average worker's functioning IQ falls 10 points when distracted by ringing telephones and incoming e-mails ... more than double the four-point drop seen following studies on the impact of smoking marijuana."</Segue>

Go figure.



1/23/2006

SharpDevelop Comin' At Ya, newsgroup spellers and Sparkle!

Mike Krueger (developer of Sharp ZipLib) and his crew have been working hard on SharpDevelop 2.0, the open-source IDE for .NET 2.0, and it looks really nice.

The Beta 1 is quite feature - complete, and VIsual Studio.NET developers will find it very familiar to work with. I just checked it out because one of our messageboard posters was complaining that C# Express has no project template for a Windows Service. Well, SharpDevelop does! And that's not all: it has a IL project template if you are interested in getting close to the metal with working breakpoints and a lot more!

If you would like to read up more about the features, here's a good recent review.

>>>>Snag yourself a copy at Sourceforge.net<<<<


NewsGroup Spellers



I don't know about you, but I've been frequenting the MS C# language group and also the ASP.NET group. Most of the people in the C# group seem to be able to spell. However, a sizeable number of the posters at the ASP.NET group seem to be having difficulty with English. Examples:

"Link in gridbiew"
"Loop threw datalist"
"Treeview Control. No selected Treenode wanted..."
"SMLDataSource problem"
"Please help - Remot name could not br resolved"
...and my favorite,
"Need help immediatly"

Boy!! I wonder what their web pages must look like!

Answering Public Newsgroup Posts

On a related note, posting answers to public newsgroup questions has been very instructive for me. Among other valuable lessons, I've started to learn:

1) To be courteous, no matter how ridiculous someone's post may seem.
2) To read the original poster's (OP's) post carefully so as to be sure to completely understand their problem or question.
3) To not post an answer in haste, but to take the time to carefully consider and if necessary research a proper answer.
4) To accept from and give corrections to others graciously.
5) To not attempt to answer a post where I am not completely sure of the answer.

These are good qualities we all could use more of, and they spill over into one's professional daily life. In particular, the C# newsgroup is frequented by studious, knowledgable MVPs and other professionals who set the tone and an example for everyone by their exemplary behavior. Among these are Jon Skeet, Nicholas Paladino, Willy Denoyette, Ignacio Machin, and others.

Carefully reading posts by other professionals, many of whom may be more advanced than you are, is the most instructive of all. And, you can even learn to spell if you work at it!



Sparkle CTP is out!



Sparkle is the Graphical UI designer that was presented at the MVP Summit last September (requires Windows Presentation Foundation).

Content is provided "AS IS" with no warranties and confers no rights. Opinions are my own and do not represent those of my employer, Microsoft, The Republican Party, or the patrons of the Blind Pig Saloon.

1/18/2006

Value Types, Reference Types, and writing with clarity!

Recently I served as a technical review editor for a book on C# and .NET. Among other issues, I noticed that the explanation "bullet points" describing "pass by value" and "pass by reference" semantics were not only unclear, they appeared to contradict each other. Quite annoyed, I wrote up a particularly scathing review comment and the authors took my advice (plus, I hope similar advice from other tech reviewers).

Unfortunately, when I read the section in the final published copy of the book, I suspect the authors may have jumped from the frying pan into the fire - they added more content, which instead of clarifying the issue and the major points, served to muck it up even more, in my opinion. A clear and unequivocal understanding of value types vs reference types in .NET is of the utmost importance.

Therefore, I present my own attempt. Einstein said that a theory should be as simple as possible, but no simpler. With that in mind (and to their credit, much of this relies on the MS Patterns and Practices whitepaper):

Value Types and Reference Types



All .NET Framework data types are either value types or reference types.

Value Types
Memory for a value type is allocated on the current thread's stack. A value type's data is maintained completely within this memory allocation. The memory for a value type is maintained only for the lifetime of the stack frame in which it is created. The data in value types can outlive their stack frames when a copy is created by passing the data as a method parameter or by assigning the value type to a reference type. Value types are passed by value by default . "By Value" is when an argument is passed into a function by passing a copy of the value. In this case, changing the copy doesn't affect the original value,


If a value type is passed to a parameter of reference type, a wrapper object is created (the value type is boxed), and the value type's data is copied into the wrapper object. For example, passing an integer to a method that expects an object results in a wrapper object being created.

Reference Types
The data for reference type objects is always stored on the managed heap. Variables that are reference types consist of only the pointer to that data. The memory for reference types such as classes, delegates, and exceptions is reclaimed by the garbage collector when they are no longer referenced. It is important to know that reference types are always passed by reference. "By Reference" is when an argument is passed to a function by passing a reference to the actual value. In this case, if you change the argument in the function, you also change the original.

If you specify that a reference type should be passed by value, a copy of the reference is made and the reference to the copy is passed *.

Additional Notes on VB.NET:

Boxing in Visual Basic .NET tends to occur more frequently than in C# due to the language’s pass-by-value semantics and extra calls to GetObjectValue. Use the DirectCast operator to cast up and down an inheritance hierarchy instead of using CType. DirectCast offers superior performance because it compiles directly to MSIL. Also, note that DirectCast throws an InvalidCastException if there is no
inheritance relationship between two types.

Further, it should be noted that in the .NET Framework 2.0, Generics provide for a much more efficient mechanism to avoid the overhead of boxing, particularly with Collections.


I think the above is both simple and elegant. It has sufficient information to cover the most important points, but not "too much information". It is presented clearly, and it does not assume that the reader already knows the definitions of key terms that are used. I can understand what I wrote, and I suspect most others can.

Why can't book authors learn to do this? Developers buy and read technical books in the hopes of receiving clarity, not muck.

* Note that in the case of the difference between passing a value object by reference and a reference object by value, as noted by Bruce Wood in his comment below, MVP Jon Skeet (whose writing I much admire because he understands the word "clarity" as it applies to writing) illustrates here. In particular the finer point is, as Jon describes, "This difference is absolutely crucial to understanding parameter passing in C#, and is why I believe it is highly confusing to say that objects are passed by reference by default instead of the correct statement that object references are passed by value by default."

Bruce's other comment clarifying the finer distinction of where memory is allocated for value types based on whether they are class fields vs. local variables or method arguments should also be noted.

1/15/2006

Iran plans Holocaust Conference?


Ok, we all know this dood is downright dangerous. But, people need to understand how "holocausts" happen. They don't happen because the German people, or the Japanese people are "evil" in some way.

They happen because, usually during bad times, some psychotic power-hungry maniac is able to get into a position of power and is allowed to do his thing unchecked. It's the psychology of crowd madness. It's happened scores of times in recorded history. The people are mesmerized by these evildoers, and they follow.

And oftentimes, the rest of the world is apathetic, wants to stay out of the way, or just plain doesn't understand the risk of letting them go unchecked.

OK? So now, friends, you are staring a brand new one of these right in the face. I mean, for real, right now, not a game, not a sound bite! A real Hitler, a real Osama Bin Laden. You are watching him on TV, he's out in the open. And, he's both NUTS and DANGEROUS, as in "NUCLEAR Dangerous". You aren't watching Dr. Evil in an Austin Powers movie. YOU ARE WATCHING THE REAL BANANA.


The situation with Iran right now is eerily similar to the way the world viewed Hitler in the 1930's.


What ya gonna do about it? You gonna let him do his thing? You gonna "negotiate" with him?

BULLSHIT!

Hey! I got friends who are Iranian. They can't understand this crap! It's incomprehensible to them. They are great, intelligent Americans who believe in freedom.

And, I believe one more thing. In order to preserve freedom, you must identify and eliminate the threats to it, before they succeed. You wanna wait around for the U.N. to do something? Heh! You will grow old and die first!

According to figures provided by the Auschwitz-Birkenau State Museum, the overall number of victims of Auschwitz in the years 1940-1945 is estimated at between 1,100,000 and 1,500,000 people. The majority of them, and above all the mass transports of Jews who arrived beginning in 1942, died in the gas chambers. Jews were not the only victims of this Nazi German killing machine - historians estimate that among the people sent to Auschwitz alone, there were at least 1,100,000 Jews from all the countries of occupied Europe, over 140,000 Poles (mostly political prisoners), approximately 20,000 Gypsies from several European countries, over 10,000 Soviet prisoners of war, and over 10,000 prisoners of other nationalities.

Anybody can sponsor a "conference" to attempt to discredit documented historical facts. This kind of Revisionism is the very first sign of a budding Hitler! Jews and non-Jews alike should be extremely vigilant in the face of individuals like Iranian President Mahmoud Ahmadinejad.

There's only one thing to do. You don't negotiate with terrorists! Take him out. FAST! I suppose we could just wait for Mossad to do it, huh?

I leave you with this quote from Ruth Gordon, who played an Auschwitz concentration camp survivor in "Harold and Maude":

"Courage is very important. Like a muscle, it is strengthened by use. " -- Ruth Gordon


My 2 cents.


Enumerating WindowsIdentity Roles with Reflection


Windows Identity has some properties, but you must use reflection to enumerate the private GetRoles() method:




namespace CurrentUser

{

    using System;

    using System.ComponentModel;

    using System.Reflection;

    using System.Security.Principal;

    using System.Windows.Forms;

 

    public class Form1 : Form

    {

        private TextBox textBox1;

        private Container components = null;

 

        public Form1()

        {

            InitializeComponent();

        }

 

        protected override void Dispose(bool disposing)

        {

            if (disposing)

            {

                if (components != null)

                {

                    components.Dispose();

                }

            }

            base.Dispose(disposing);

        }

 

        #region Windows Form Designer generated code

 

        private void InitializeComponent()

        {

            this.textBox1 = new System.Windows.Forms.TextBox();

            this.SuspendLayout();

            this.textBox1.Location = new System.Drawing.Point(8, 16);

            this.textBox1.Multiline = true;

            this.textBox1.Name = "textBox1";

            this.textBox1.Size = new System.Drawing.Size(320, 384);

            this.textBox1.TabIndex = 0;

            this.textBox1.Text = "textBox1";

            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

            this.ClientSize = new System.Drawing.Size(344, 414);

            this.Controls.Add(this.textBox1);

            this.Name = "Form1";

            this.Text = "Form1";

            this.Load += new System.EventHandler(this.Form1_Load);

            this.ResumeLayout(false);

        }

 

        #endregion

 

        [STAThread]

        private static void Main()

        {

            Application.Run(new Form1());

        }

 

        private void Form1_Load(object sender, EventArgs e)

        {

            WindowsIdentity id = WindowsIdentity.GetCurrent();

            Type idType;

            idType = id.GetType();

            object result =

                idType.InvokeMember("_GetRoles", BindingFlags.Static | BindingFlags.InvokeMethod |

                    BindingFlags.NonPublic, null, id, new Object[] {id.Token}, null);

            string[] roles = (string[]) result;

            int i;

            for (i = 0; i < roles.Length; i++)

                textBox1.Text += roles[i] + "\r\n";

        }

    }

}



-- You can paste the above directly into a Windows Form class to test it out.

1/13/2006

Activator.CreateInstance Pattern with Interface

This has come up several times already in newsgroup and forum posts, so I thought I would post my "keep it smple" implementation here. What we want to do is be able to load an assembly dynamically, create an instance of a named class, and call a method with parameters. The information we need to do this probably comes out of a database.

First, I start with an interface:

public interface IMessage
{
NameValueCollection Parameters { get; set; }
DateTime DateTimeCreated { get; set; }
bool Success { get; set; }
Exception OperationException { get; set; }
IMessage Execute(YourClassToProcess yourClass);

}

The IMessage interface defines a NameValueCollection (which name-values could also be coming out of associated rows in another database table), a bool for Success, and an Exception object.
By simply populating a NameValue Collection with our parameter names and values, and assigning this to the IMessage Parameters field, the internal implementation can get all the parameters it needs for its specific operation.

Its Execute method also accepts a class of your choosing, and returns another IMessage interface object to hold the result. Simple!

Now here is a method to use all this:

private void ExecuteMethodOnAssembly( string assemblyName,
string className,
YourClassToProcess yourClass,
NameValueCollection parameters)
{
Type ObjType = null;
IMessage im;
try
{
// load it
Assembly ass = null;
ass = Assembly.Load(assemblyName);
if (ass != null)
{

ObjType = ass.GetType(className);
}
}
catch (Exception ex)
{
// whatever you need to do here
}
try
{
// OK Lets create the object
if (ObjType != null)
{
im = (IMessage)Activator.CreateInstance(ObjType);
im.Parameters=parameters;
IMessage resMsg= im.Execute(yourClass) ;
if(resMsg.Success ==false)
// whatever you need to do
}
}
catch (Exception ex)
{
// whatever you need to do
}
} // end Method ExecuteMethodOnAssembly


I have found that this arrangement, or similar ones, provides the most flexibility. Note the use of the interface means we don't care what assembly or class we are using, as long as it implements IMessage, we are fine.

"There's a BUG in ...." vs User Stupidity and Blanket Statements about .NET

I"ve been doing this .NET thing since they gave out the first BETA at PDC in Orlando 2000. That's nearly FIVE years of toil and learning with the .NET platform. And I mean toil, because early on I had the good sense to completely give up on Visual Basic and go almost 100% with C#. Boy! That was a GOOD decision.

And one thing I've learned well, especially from my own mistakes and all the newsgroup and forum posts I've read and answered:

If you think you found a "BUG" in .NET, think again, because 99% of the time it's just USER STUPIDITY (and sometimes even arrogance!) that is the real problem.

There are plenty of things you can do wrong that will make it "look like" .NET is fubar, and almost without exception, it was YOU, the developer. That's not to say there aren't any bugs - of course there are. But most developers never even run into them.

It's very easy, for example, to write a stored procedure that attempts to access a table by the wrong name. This will compile just fine. At runtime, you are going to get errors that "look like" there's something wrong with the SQLDataAdapter's Update method. Nope! .NET is simply reporting the news of your stupidity, and unless you learn how to read the road signs it gives you, it may take you a long time to fix it, since you are already off "reporting a bug" -- instead of writing quality code!

Unit tests are extremely helpful in preventing errors and insuring the integrity of your codebase as projects evolve and become more complex.


But I wonder what percentage of .NET developers know how to use NUnit? Or who have read a book on unit testing or refactoring? I bet, less than 5 percent.

Think about it.


Blanket Statements About .NET



Another thing developers should be vigilant about is the temptation to accept "blanket statements" about some issue from Self-Proclaimed Guru-Types, many of whom are simply parroting something they've heard or read from some other SPGT online. A case in point is the blanket statement (which was recently made on a public newsgroup) "You should always use StringBuilder for string concatenation because ... blah, blah"

Wrong! Fact is, StringBuilder is NOT always faster or more efficient for string concatenation. I've seen several tests with charts showing that somewhere between 5 and 7 concatenations, StringBuilder is LESS EFFICIENT than "+=". Here is a link to one..

Furthermore, Jon Conwell did an excellent blog piece that shows from his tests that the String.Concat function outperforms the StringBuilder by 2.3 times! Sure there are provisos such as pre-initialization and other considerations. However, the point is, don't accept everything you read as "The Gospel". Test, and verify.

I leave you with this little gem from Tesla. When you plug your PC into the AC outlet in the wall, please thank this guy, as he invented it:

"The scientists of today think deeply instead of clearly. One must be sane to think clearly, but one can think deeply and be quite insane." -- Nikola Tesla





1/11/2006

Hacker History and You! and Target


Wikipedia's Timeline of Hacker History is an amusing if not frightening look into the psychology of how technology has been - and will be -- misused over the last 35 years or so and into the future.

The original meaning of the word "hack" was born at MIT, and originally meant an elegant, witty or inspired way of doing almost anything.

Many early hacks took the form of elaborate practical jokes. In 1994, MIT students put a convincing replica of a campus police car on top of the Institute's Great Dome.

Of course, there is a lot of notable stuff missing from this piece; in the 1870s, several teenagers were evicted from the country's brand new phone system by enraged authorities. However, it presents a keyhole look from the Universe into the mind of the Hacker. In 1998, an anti-hacker ad ran during Super Bowl XXXII. The Network Associates ad, costing $1.3-million for 30 seconds, showed two Russian missile silo crewmen worrying that a computer order to launch missiles may have come from a hacker. They decide to blow up the world anyway.
(Shades of Peter Sellers in Dr. Strangelove [1964] - the classic!)

Hacking works two ways -- some hackers use their skills to damage or shut down computer systems. Others have altered computer data in order to steal money.

However, many hackers do not break into computers for vandalism or personal gain. These hackers often feel rebellious towards authority and want to cross computer boundaries simply to prove that they can. Some people respect or romanticize these hackers as defenders of freedom on the Internet. Law enforcement officials view computer hacking as a serious crime, however, and prosecute hackers as criminals.

Some hackers who have been convicted of computer crimes, and others who simply want to keep access to the Internet open and free, work with the authorities. They seek out spots where computer systems are vulnerable to hacking and help make them more secure.

What are the lessons we have learned, if any?

Whoopee! Ain't technology grand!



Target goes for .NET in all 1400 stores


Target Corp., the nation's second-largest discount general merchandise retailer, will adopt Microsoft(R) .NET Framework- based technologies within its 1,400 stores in 47 U.S. states. Target will migrate its systems within each store to the Microsoft .NET Framework 2.0, Windows Server(TM) 2003 and Microsoft SQL Server(TM) 2005, core technologies that deliver on the Microsoft Smarter Retailing strategy for connecting people, information, systems and devices. (Hey! I wonder if they'll be using -er, "AJAX"?)

1/07/2006

How to determine if a running ASP.NET App was compiled in Debug or Release Mode?

Recently there was a dotnet.framework.aspnet newsgroup post on this subject. I answered it, but my answer wasn't complete. Here is a short example of how you can definitively tell - AT RUNTIME - if the assembly was built in Debug or Release mode:


// in AssemblyInfo.cs:
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif

private string buildMode=String.Empty;
private void Page_Load(object sender, System.EventArgs e)
{
Assembly asm = Assembly.GetExecutingAssembly();
object[] objArray=asm.GetCustomAttributes(false) ;
foreach (object obj in objArray)
{
AssemblyConfigurationAttribute conf =
obj as AssemblyConfigurationAttribute;
if (conf != null)
this.buildMode=conf.Configuration ;
}
Response.Write("Build Mode: " +this.buildMode);
}


On a lighter note, you just gotta weep to see this on Microsoft's security pages :
A Parent's Primer to Computer Slang.



--- w00t?

Default ASP.NET Web Administration with SQL Server 2005, and a PreserveProperty Control

The ASP.NET 2.0 machine configuration has a pre-defined connection string for providers which points to the default SQLExpress Edition configuration that ships with Visual Studio 2005. As a result, if you never installed the Express edition and use SQL Server 2005, it won't work. To get the expected 'out-of-the-box' functionality of the Web Site Administration Tool , you can change the machine.config. Here's an example from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config:

original:

<runtime/>
<connectionStrings>
<add name="LocalSqlServer"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=DataDirectoryaspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient"/>
</connectionStrings>

Adjusted:

<runtime/>
<connectionStrings>
<add name="LocalSqlServer"
connectionString="data source=.\YOURSQL2005;Initial Catalog=aspnetdb;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />
</connectionStrings>

Update [2006/01/28]:
Responding to this on the asp.net MS newsgroup to someone who was having issues with this with their web hosting company (who it appears already had their default membership database configured in machine.config):

"If the error you receive is still the one about an already attached DB of the same name, how have you modified the web.config file? It needs to have a
<connectionstrings></connectionstrings> section and in that section you need the following tags (in order):
<remove name="LocalSqlServer">
<add name="LocalSqlServer" connectionstring="data source=YourServerandInstance;Integrated Security=SSPI;AttachDBFilename=DataDirectoryYourAppDB.mdf;User Instance=true" providername="System.Data.SqlClient">

Obviously, you'll need to modify the server/instance and mdf values. The key is that ASPNET uses the "LocalSqlServer" connection string to do its authorization, etc.-- "



PreserveProperty Control

MVP buddy Rick Strahl has a created a really interesting control to save other controls' state. This enables you to declare what properties you specifically want, which represents improvement over ViewState and even ControlState. Several developers who looked at Rick's original work, including yours truly, suggested improvements and Rick has incorporated these. I've already backported this to ASP.NET 1.1 and plan to do some more testing on it. I added a Cache option in addition to the HiddenField and SessionVariable Storage options as some testing I did earlier indicated that using Cache to store ViewState-related stuff was the most performant. One thing I really respect about Strahl is that he isn't afraid to put out unfinished ideas and take good feedback from others, and then work these improvements in (along with other good stuff he's discovered in the process). That's the mark of a professional developer!

1/04/2006

Requiring a login just to read your content?

One of my little pet peeves is how some developer - oriented sites require you to log in in order to read their content, even though they appear to have taken pains to enable Google and MSN et al to index it.

Is this piss-poor, or what? I've practically memorized these sites already and when I am searching for something and I see a link to one of these sites, I don't even bother to click on it anymore.

These folks are advertising - supported too, and apparently they just haven't "got it"! Apparently they are happier shooting themselves in the foot than making advertising revenue from quality search-engine driven traffic!

Then there are the blokes who make you log in in order to download their "precious resources" (zip files of code, usually). What a bunch of HORSESHIT! People don't deep-link to other sites' downloads, they link to the articles!

Now, if you have a messageboard, sure I can see the validity of requiring a login so that you can track threads and provide email feedback notifications. We run a profitable site at eggheadcafe.com, we've never required users to log in to read our stuff.

I just don't get the mentality at all. Anyway, I've always seemed to be able to find another site where I can read up on what I'm searching for for free. And if I like their ads, I click. Isn't that what its about?

Enlighten me if I appear to be missing something, but it appears to me that these people are just a bunch of fyookin' idiots! On second thought, don't bother. Since I've already made up my mind they're idiots, most likely any explanation would be like farting into the wind.


HOW ABOUT BANKS?

While I'm on it (venting my spleen) How about BANKS?

Let's face it, most banks absolutely SUCK at customer service! They hide behind their internet banking facades and their Voice response systems. I needed some statement copies that we misplaced from last year. I walked into the lobby of the bank and basically was told by a bunch of incompetent boobs, "Call the 800 number". Well, the 800 number guy told me if I used their Internet banking, I could request statements there. So I did. Know what? They want $4.00 for each check image plus an additional fee for the fyookin' statement itself! Highway Robbery! So if I had a statement where I wrote 20 checks, they are into me for $80 bucks for a copy of a lousy statement! The other bank we use let's you get them online for FREE, and you can download it as a PDF in seconds!

You know what? When I start my first BANK, I'm gonna offer the "75+" account. If your IQ is over 75, I give you free checking. Doubt if any of the bank employees at my bank would qualify...


Internet Explorer Developer Toolbar


The Microsoft Internet Explorer Developer Toolbar provides a variety of tools for quickly creating, understanding, and troubleshooting Web pages. This version is a preview release and behavior may change in the final release.