.NET Discussion

.NET Issues, Problems, Code Samples, and Fixes

BlogEngine.NET: The First Stumbling Block

Let me start off by saying that BlogEngine.NET is a fantastic piece of software with a ton of awesome features and is relatively easy to use.

That said, I’ve spent nearly all of my free time in the past month building a custom site using the BE.NET framework as a base, and while it’s been frustrating at times (I basically had to teach myself C#), I learned a lot about programming just by getting into the core and messing around and seeing how things are linked up and organized. It’s been working great on my local machine (first hooked up to my local MySQL database and then hooked up to the hosted MySQL database) and I was really excited to upload it and get it going.

I fired up good ol’ FileZilla, took a deep breath, and hit “Upload” and watched with mounting anticipation as the 700-some files in the queue slowly (actually, really quickly, but it seemed slow) dwindled. Finally, it was time! I opened my browser, typed in my URL, and held my breath as IE7’s thinking circle went round and round.

That’s when disaster struck.

The YPOD popped up with an unfamiliar error message: “Unable to find the requested .Net Framework Data Provider.  It may not be installed.” Exqueeze me? What does that even mean?? My first instinct was that there was something wrong with my Web.Config file, so I checked there. Some idiot (read: me) forgot to change over the local DB string to the hosted DB string. Fixed. Uploaded. Ta-da!….. ? What? Still not working? Oy… this is going to be a long night…

Well, I did some digging and found out that my instincts were correct and that there is probably an issue with my Web.Config. I found a CodePlex thread by someone who got the same error and tried their solution, but to no avail. I also created my own thread, but as of this writing, no one has responded to my cry for help. I found this tutorial by Al Nyveldt and my spirits were raised again because he is one of the authors of the damn software, but again they were dashed when his tips were also unable to help me out. I even downloaded his sample Web.Config and applied it to my own.

I downloaded the latest MySQL/ASP.NET connector ( as of now), placed it in my /bin folder and modified the versions in the Web.Config to match (they are in the Web.Config). Still nothing.

With frustration and utter lack of any idea where to turn, I emailed both Mads Kristensen and Nyveldt beseeching them for advice on what to do. I don’t expect an answer (as I’m sure they get 290352268 emails a day from guys like me who are too dumb to figure out their software), but hopefully they will help me out.

Unfortunately, there is no happy ending to this story as of yet… no magical fix that I can present to you that will get you out of the same rut. But maybe I’ve pointed you in the right direction where someone’s suggestions may help you.  If you have any ideas, please please please post them or email me. If it works, I will definitely post your solution with a link to whatever site you want. I would not be surprised if it’s a one-line fix in my Web.Config that makes me smack my forehead. With a hammer.

Thanks in advance for any help you can provide!

EDIT: I’ve received a bit of help from the wonderful nberardi and we (he) came to the conclusion that my host is running a pre-5.1 MySql/ASP.NET connector (they are running an outdated MySql.Data assembly) [, to be exact]). The 5.1 release included support for Roles and Memberships, so anything older than that will not work with this engine. Should they update it (or I go elsewhere) I will keep you posted.

8/30: SOLVED! But you’ll never guess what the problem was. You ready for this? My hosting company had a stray character in their Machine.config file that was right by the DbProviderFactories node… no, I’m not kidding. Everything is working fine now… I will post more on this tool later.


August 27, 2008 Posted by | BlogEngine.NET, Bugs, C#, Errors, MySQL | 5 Comments

ASP.NET and AJAX: Error Making Forms Visible With UpdatePanel

While converting a site to a MasterPage-driven site, I ran across an issue involving UpdatePanels, Panels and Forms. The scenario is that in my MasterPage, I have an UpdatePanel that wraps my ContentPlaceHolder, thereby applying the AJAX functionality to all pages associated with that MasterPage. The content page in question has a panel that is invisible until a button is pressed. The contents of the panel are two non-server forms for PayPal and Google Checkout. Before I converted the site to MasterPages and AJAX, the functionality performed correctly, but afterwards, the site would hang (ie, not complete the server side action), and the browser would produce the Javascript error:

“Unknown runtime error”

I tried many different combinations of contents for the panel, but the only one that seemed to produce the error was whenever a form was present inside the panel. This was very frustrating, as no one around the internet community really seemed to have run across this error, and modifying the MasterPage to account for this single scenario would be a nightmare.

A working solution I came up with for this rare error is to wrap your content (on your .aspx page) with another UpdatePanel and set your triggers to post back when the button is pressed. While the client may have to suffer another postback, it’s not as bad as a total loss of functionality.

If you can find a more elegant solution to this problem, I would love to hear it!

EDIT (2/29/08): I believe the error occurs whenever you are using nested HTML forms within your runat=”server”. If you’re looking to post to another form, please see my article on integrating PayPal and Google Checkout.

January 18, 2008 Posted by | AJAX, ASP.NET, Errors, Google, Javascript, MasterPages, PayPal, UpdatePanel | Leave a comment

ASP.NET: Issues with Generics

The introduction of Generics into .NET 2.0 was a huge improvement over the previous methods of aggregating objects. There are many, many new things you can do with Generics that could not be done previously, in addition to making harder tasks easier and more efficient. For example, I can take a Generics list of my own objects and bind them to a GridView and be able to use the objects’ properties as bound datafields! Something not possible before. However, they do, of course, come with problems of their own. For instance, for the novice to intermediate user, the concept of predicates and actions is enough to make your (my) head spin. And it seems like this is the most efficient way to find things, even though to me, it makes no sense. I suppose until I decide to really hunker down and attempt to learn how to use these features, I’ll stick with my For Each [whatever] in MyGenericsList ... Next code.

Here is where I come across my problem, though. One of my business objects has a Generics list of another object (AllPrices as List(Of Price)) consisting of prices and options. This is bound to a GridView, which displays all the properties. On update, I have all the properties of the selected Price object update, some numbers are automatically determined by various variables and business calculations, and then the object is matched up back to its appropriate item in my AllPrices Generics collection, and the GridView is rebound. This works wonderfully for all but one situation, which has me vexed and confused. Here’s how I match the item and recalibrate my AllPrices Generics list (in my RowUpdating event):

' "newPrice" contains all my price changes. it is of type PriceInfo.Price
Dim updatedprice As New PriceInfo.Price
		For Each updatedprice In Prod.Prices.AllPrices
			If updatedprice.PriceID = newPrice.PriceID Then
				updatedprice = newPrice
				updatedprice.UpdatePrice() 'updates the database
				Prod.Prices.AllPrices(Prod.Prices.AllPrices.IndexOf(updatedprice)) = updatedprice 'update AllPrices ****
				Exit For
			End If
		GridView1.EditIndex = -1
		BindGridView() 'rebinds the AllPrices Generics list to the GridView

What this code does is finds the matching object in the list by PriceID, updates it with the changes (updatedprice = newPrice), updates the database, and then re-inserts the object into the AllPrices Generics list. However, in one situation, I get an “out of index” error at the line with four asterisks (****), even though the database updates correctly. Logically, this doesn’t make sense to me, since 1) it is finding the object in the collection (it can’t get to that line unless it does), 2) it is updating the database correctly (I’ve verified this in my database), it just isn’t updating the AllPrices list!

What the crap?

Any help is much appreciated. Also, if you’ve experienced similar issues with Generics, please post them! Or if you have some normal, realistic way to use actions and predicates! 🙂

Status: Solved! (12/11/07)
Solution: I was making things way too complex, apparently. I was running two loops (the For loop and the IndexOf() loop) and trying to match objects to one another. Rather than include all this ridiculous complexity, I created a simple counter variable (Dim i As Integer) outside the For loop and just incremented it after the conditional statement runs (i += 1), and replaced Prod.Prices.AllPrices(Prod.Prices.AllPrices.IndexOf(updatedprice)) = updatedprice with Prod.Prices.AllPrices(i) = updatedprice. Now everything is gravy. Thanks to Nick Berardi for the tips!

December 11, 2007 Posted by | ASP.NET, Errors, Generics, GridView | Leave a comment

ASP.NET GridView: ‘The Gridview [x] Fired Event RowDeleting Which Wasn’t Handled’

Came across this error today which left me scratching my head for a bit. Basically, I have a Gridview with a Select column, two Button columns, and a few Bound columns.  I gave each button column a unique CommandName property, and one of them was “Delete”, because I was using it to delete the row (I was doing it manually).  I am handling the buttons’ click events in the RowCommand event and discerning which is which by e.CommandName. However, every time I clicked the delete button, I would get the error:

The Gridview [x] Fired Event RowDeleting Which Wasn’t Handled

This struck me as odd, because I wasn’t doing anything with a “RowDeleting” event. I tried putting some random code in there, nothing worked, although the code was getting executed every time. After trying any and everything I could think of, I decided to change the CommandName “Delete” to “Delort” (courtesy of Strongbad 🙂 ) and viola! It worked!

Apparently, the CommandName “Delete” is reserved for the Built-In Editing Functionality of the GridView. I’m sure there are others reserved, too, but I didn’t really look into it any further. Who knew?

August 31, 2007 Posted by | ASP.NET, Errors, GridView, Tips & Tricks | 5 Comments

ASP.NET: How To Send Email When Your SMPT Server Requires Authentication

I ran into this problem that I simply could not for the life of me figure out.  My main site, www.columbussupply.com, has never had any problems sending email via my usual SMTP server.  However, I have a couple sites using the same host in my account at Successful Hosting (a FANTASTIC webhost, by the way, if for no other reason than the spectacular customer service [no they did not pay me a dime to say this]), and I was having problems with my new site, www.proudwearsports.com, sending email.  The error I kept receiving was:

System.Net.Mail.SmtpFailedRecipientException: Mailbox name not allowed. The server response was: sorry, that domain isn’t allowed to be relayed thru this MTA (#5.7.1)

After talking with Wade (at Successful Hosting) about my issue, he quickly diagnosed the problem.  Apparently, their server requires authentication (ie, logging in) before sending any mail.  The server was simply not allowing me to send mail from the site without the proper authentication.  So, we went through  my code, and there just wasn’t anywhere in the System.Net.Mail class that would allow me to authenticate the email before I sent it, which had me confused (if there is, in fact, a way to do this programmatically, please correct me!).  But, after a bit of searching I came up with the following magical Web.config code:

   <smtp from=”emailaccountyouaretryingtosendfrom@yourdomain.com”>
    <network host=”whatever.yoursmtphostis.com” password=”yourpassword” userName=”emailaccountyouaretryingtosendfrom@yourdomain.com” />

And that’s it!  Once I put that in, the email was sent and everyone went on with their day with a big ol’ smile on their face.

August 16, 2007 Posted by | ASP.NET, Email, Errors, Tips & Tricks | 6 Comments