Category: ASP.net MVC
How to fix problem with asp.net mvc 3 and json

The Problem: You are attempting to import json data into your web application, but you continue to get weird errors.  Here is what the json data looked like

[{"entry":{"tags":[{"name":"Web Development","billable":true,"id":117906}],”created_at”:”2011-02-04T01:00:28Z”,”billable”:true,”minutes”:150,”updated_at”:”2011-02-04T01:00:40Z”,”recently_updated_at”:”2011-02-04T01:00:40Z”,”project_id”:40401,”import_id”:null,”url”:null,”time_to”:null,”id”:670893,”date”:”2011-02-02″,”user_id”:12914,”formatted_description”:””,”description_text”:””,”time_from”:null,”description”:”Web Development”,”invoiced_at”:null,”project_invoice_id”:null}},{“entry”:{“tags”:[{"name":"Web Development","billable":true,"id":117906}],”created_at”:”2011-02-04T01:04:42Z”,”billable”:true,”minutes”:180,”updated_at”:”2011-02-04T01:04:42Z”,”recently_updated_at”:”2011-02-04T01:04:42Z”,”project_id”:40401,”import_id”:null,”url”:null,”time_to”:null,”id”:670909,”date”:”2011-02-01″,”user_id”:12914,”formatted_description”:””,”description_text”:””,”time_from”:null,”description”:”Web Development”,”invoiced_at”:null,”project_invoice_id”:null}},{“entry”:{“tags”:[{"name":"Web Development","billable":true,"id":117906}],”created_at”:”2011-02-04T01:11:13Z”,”billable”:true,”minutes”:60,”updated_at”:”2011-02-04T01:11:13Z”,”recently_updated_at”:”2011-02-04T01:11:13Z”,”project_id”:40401,”import_id”:null,”url”:null,”time_to”:null,”id”:670914,”date”:”2011-01-31″,”user_id”:12914,”formatted_description”:””,”description_text”:””,”time_from”:null,”description”:”Web Development”,”invoiced_at”:null,”project_invoice_id”:null}}] 

The Cause: The json is not in the format you think it should be in  While it looks like you would get each record back, you get one solid blob.

Read more on How to fix problem with asp.net mvc 3 and json…

Popularity: 1% [?]

By Steve French with 0 comments
How to fix problems with Coded User Interface Tests

The Problem: You attempt to create a new Coded User Interface Test in Visual Studio 2010, and you get the following error:

The following package failed to load: C:Users[File Path Goes Here]Microsoft.VisualStudio.TestTools.UITest.Extension.IE.dll. Coded UI Test is now in an inconsistent state. Remove this package and restart Visual Studio to work with Coded UI Test.

The Cause: For whatever reason, Visual Studio does not copy Microsoft.VisualStudio.TestTools.UITest.Extension.IE.dll into the solution, and but it thinks it did.

Read more on How to fix problems with Coded User Interface Tests…

Popularity: 1% [?]

By Steve French with 0 comments
How to fix problems with Linq and the Entity Framework

database 2The Problem: You attempt to do a query using Linq To Entities and your code does not work.

The Cause: For reasons unknown, Linq to Entities has different operators than Linq To Sql.

Read more on How to fix problems with Linq and the Entity Framework…

Popularity: 1% [?]

By Steve French with 0 comments
How to fix problems uploading images in asp.net mvc 3/razor

The Problem: You are attempting to create create an asp.net mvc 3 page with razor that uses an upload control.  You try to upload an image and all you get is a “server not available” error.  Not very descriptive it it?

Read more on How to fix problems uploading images in asp.net mvc 3/razor…

Popularity: 2% [?]

By Steve French with 1 comment
How to do a cool flash notification message in asp.net mvc 3 in 6 easy steps

I pieced all of this together from various sources online, so the code is a bit rough, but here it is:

1.  Create a partial razor view, call it _NotifyBar.cshtml, it contains this:

Read more on How to do a cool flash notification message in asp.net mvc 3 in 6 easy steps…

Popularity: 2% [?]

By Steve French with 2 comments
How to create a asp.net gridview hyperlink field with multiple querystring parameters

Frozen linksThe Problem: You need to put a relatively complicated link (i.e. the link has more than one parameter) into an asp.net gridview column.

The Cause: No cause really, you just need to know the exact syntax
The Solution:

Read more on How to create a asp.net gridview hyperlink field with multiple querystring parameters…

Popularity: 2% [?]

By Steve French with 0 comments
How to fix problems with asp.net mvc 3 charts and razor pages

The Problem: You attempt to use the super-cool new charting features in asp.net mvc 3, and all you get is compilation errors

The Cause: You are using the old school System.Web.UI.DataVisualization.Charting.Chart namespace

Read more on How to fix problems with asp.net mvc 3 charts and razor pages…

Popularity: 2% [?]

By Steve French with 0 comments
How to fix the copy file problem in C#

Cavalry moving forwardphoto © 1918 National Library of Scotland | more info (via: Wylio)The Problem: You need to copy a file from one location on the server to another and cannot remember how.

The Cause: It is too short and simple, and easily forgotten

Read more on How to fix the copy file problem in C#…

Popularity: 1% [?]

By Steve French with 0 comments
How to fix the “Unable to cast object of type” problem

Drill Bitsphoto © 2008 Justin Gurbisz | more info (via: Wylio) The Problem – you have several asp.net web controls (.ascx files) in your website project and for no obvious reason you suddenly get the error “Unable to cast object of type ‘YourWebControlName_ascx’ to type ‘YourWebControlName_ascx’.”  You recompile and the program works, then stops working.  You recompile and it works again, then it stops working, ad infinitum, but the working times become less frequent, and eventually the site stops working at all.

Read more on How to fix the “Unable to cast object of type” problem…

Popularity: 1% [?]

By Steve French with 0 comments
A simple way to create a Microsoft Word document from a template in Asp.net/C#

Will code for food I recently had the need to create a Microsoft Word document from a template. I initially tried using Office Web Components and Interop but all that really wasn’t worth the trouble.  I wound up doing global replacements in the html of html   Here is how I did it:

Read more on A simple way to create a Microsoft Word document from a template in Asp.net/C#…

Popularity: 2% [?]

By Steve French with 1 comment