<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Deborah's Developer MindScape : C#, CSharp</title><link>http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/CSharp/default.aspx</link><description>Tags: C#, CSharp</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Tips for Building a BO for Silverlight and RIA</title><link>http://msmvps.com/blogs/deborahk/archive/2013/01/21/tips-for-building-a-bo-for-silverlight-and-ria.aspx</link><pubDate>Mon, 21 Jan 2013 20:13:42 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1822958</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1822958</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2013/01/21/tips-for-building-a-bo-for-silverlight-and-ria.aspx#comments</comments><description>&lt;p&gt;The following are some tips when building a business object class for use by Silverlight and RIA services. &lt;/p&gt;  &lt;p&gt;NOTE: This assumes you are not using Entity Framework (EF).&lt;/p&gt;  &lt;h2&gt;&lt;font size="3"&gt;Use Class-Level Validation&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;Specifying class-level validation allows you to perform validation on the entire class. This is a good location for cross-field validation.&lt;/p&gt;  &lt;p&gt;For example, say you are creating a Discount class that defines discounts available to your customers. A percentage discount must be less than 100% where a dollar discount can be any amount. In the class-level validation, you can check the discount type against the amount to determine if the fields are valid.&lt;/p&gt;  &lt;p&gt;Use the CustomValidation attribute to define class-level validation:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&lt;strong&gt;[CustomValidation(typeof(DiscountValidation), &amp;quot;ValidateDiscount&amp;quot;)]&lt;/strong&gt;      &lt;br /&gt;public class Discount&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e"&gt;&lt;font face="Consolas"&gt;&lt;strong&gt;&amp;lt;CustomValidation(GetType(DiscountValidation), &amp;quot;ValidateDiscount&amp;quot;)&amp;gt;&lt;/strong&gt;        &lt;br /&gt;Public Class Discount&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;h2&gt;&lt;font size="3"&gt;Define a Key&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;For WCF RIA Services to recognize your objects, they must have a unique key. In most business objects, this is easy because every object relates to a database row that already has a unique key. &lt;/p&gt;  &lt;p&gt;In the above Discount example, the discount already has a unique DiscountId associated with it.&lt;/p&gt;  &lt;p&gt;Use the Key attribute to define the key field.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;private int _DiscountId;     &lt;br /&gt;&lt;strong&gt;[Key()]&lt;/strong&gt;      &lt;br /&gt;public int DiscountId {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; get { return _DiscountId; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; set&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (!_DiscountId.Equals(value))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Set the value     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _DiscountId = value;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;Private _DiscountId As Integer     &lt;br /&gt;&lt;strong&gt;&amp;lt;Key&amp;gt;&lt;/strong&gt;      &lt;br /&gt;Public Property DiscountId() As Integer      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Get      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return _DiscountId      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Get      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Set(ByVal value As Integer)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; If Not _DiscountId.Equals(value) Then      &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;#39; Set the value     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _DiscountId = value      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End If      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Set      &lt;br /&gt;End Property&lt;/font&gt;    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;NOTE: If you ever have an issue whereby your WCF RIA Service is returning one row when you know you have many rows, chances are that the Key attribute is missing. Without this attribute, RIA views all rows as the same row and therefore only returns one.&lt;/p&gt;  &lt;h2&gt;&lt;font size="3"&gt;Add a String Property for each Numeric Property&lt;/font&gt;&lt;/h2&gt;  &lt;p&gt;If you define a numeric property in your business object, such as an Integer or Decimal, and bind it in Silverlight, Silverlight will automatically convert any entered value to a number. If the user enters &amp;quot;one&amp;quot;, it won&amp;#39;t generate a validation error. Silverlight instead converts it to a number. Any string converted to a number is 0.&lt;/p&gt;  &lt;p&gt;This may not seem likely, but consider the possibility that the user enters 50%. Because of the &amp;quot;%&amp;quot; sign, Silverlight will convert the value to 0 and consider it a valid number.&lt;/p&gt;  &lt;p&gt;To have full control over numeric entry, create a string version of any numeric property. Define a Regular Expression to validate that string as an integer or decimal value. And bind that string value to the Silverlight field.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;[RegularBLOCKED EXPRESSION&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1822958" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/RIA+Services/default.aspx">RIA Services</category></item><item><title>Adding Tables with SSDT</title><link>http://msmvps.com/blogs/deborahk/archive/2012/10/21/adding-tables-with-ssdt.aspx</link><pubDate>Mon, 22 Oct 2012 06:12:55 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1818280</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1818280</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/10/21/adding-tables-with-ssdt.aspx#comments</comments><description>&lt;p&gt;OK, no more SSDT jokes! SSDT, or SQL Server Data Tools, give you the features of SQL Server Management Studio within Visual Studio 2012. You can use the SQL Server Object Explorer from the SSDT to create and maintain tables in your databases.&lt;/p&gt;  &lt;p&gt;See &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/10/21/sql-server-object-explorer-in-vs-2012.aspx"&gt;this link for an introduction&lt;/a&gt; to SQL Server Object Explorer.&lt;/p&gt;  &lt;p&gt;See &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/10/21/adding-a-new-database-with-ssdt.aspx" target="_blank"&gt;this link for details&lt;/a&gt; on creating a new database with SSDT.&lt;/p&gt;  &lt;p&gt;To add a new table to a SQL Server database:&lt;/p&gt;  &lt;p&gt;1) Open the SQL Server Object Explorer toolbox using View | SQL Server Object Explorer from Visual Studio.&lt;/p&gt;  &lt;p&gt;2) Drill down to the Databases node, then to your database, then to Tables.&lt;/p&gt;  &lt;p&gt;3) Right-click and select Add New Table...&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7853.image_5F00_65AEE041.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5722.image_5F00_thumb_5F00_79C7FCCA.png" width="411" height="411" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;4) Visual Studio creates a new table called &amp;quot;Table&amp;quot; and opens it in the Table designer.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0878.image_5F00_43E307B0.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1376.image_5F00_thumb_5F00_4A29DE3E.png" width="417" height="259" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;At this point you can use the design grid in the upper left panel or the T-SQL in the bottom panel or any combination of both to define your table.&lt;/p&gt;  &lt;p&gt;In the example below, the LastName was added in the upper left panel. Notice that Visual Studio automatically generates the matching T-SQL:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1488.image_5F00_7B4918DE.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3482.image_5F00_thumb_5F00_564B5865.png" width="462" height="286" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In this example, the FirstName field was added in the T-SQL. Notice that Visual Studio automatically generates the matching row in the grid:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0218.image_5F00_758DFF38.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8662.image_5F00_thumb_5F00_4D0F1D24.png" width="463" height="318" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To name the table, edit the Create Table statement in the T-SQL.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5852.image_5F00_366CCEDD.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0216.image_5F00_thumb_5F00_75CA826D.png" width="420" height="373" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can use the Properties window (View | Properties Window) to set additional properties for the fields on the table, such as the Identity information.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2112.image_5F00_3BDB3F81.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2727.image_5F00_thumb_5F00_330B3735.png" width="491" height="300" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;When you are done with the table design, click the Update button in the upper left corner. Visual Studio presents a preview dialog:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4743.image_5F00_4DD75D41.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1018.image_5F00_thumb_5F00_30EE386C.png" width="418" height="294" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Click Generate Script to create a deployment script containing the T-SQL. Click Update Database to directly update the database with the new table.&lt;/p&gt;  &lt;p&gt;A few issues I have had working with the Table designer:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;There are sometimes issues when the Table designer is not docked to the main window, meaning that it is either floating or docked to another tab raft (say on a second monitor). At some point, the window stops accepting keyboard input. I have to then re-dock the window to type anything more.&lt;/li&gt;    &lt;li&gt;The only way I was able to get the primary key to be named (instead of unnamed) is to remove the primary key and reset it after naming the table.&lt;/li&gt;    &lt;li&gt;I was not able to set the table&amp;#39;s name using the Properties window.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Use the SQL Server Object Explorer any time you need to add or edit the table structure of your database.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1818280" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Data/default.aspx">Data</category></item><item><title>Adding a New Database with SSDT</title><link>http://msmvps.com/blogs/deborahk/archive/2012/10/21/adding-a-new-database-with-ssdt.aspx</link><pubDate>Mon, 22 Oct 2012 03:58:56 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1818278</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1818278</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/10/21/adding-a-new-database-with-ssdt.aspx#comments</comments><description>&lt;p&gt;No, SSDT is not a disease; it is a set of SQL Server Data Tools that are included as part of Visual Studio 2012. You can use the SQL Server Object Explorer from the SSDT to maintain or view your databases. &lt;/p&gt;  &lt;p&gt;See &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/10/21/sql-server-object-explorer-in-vs-2012.aspx" target="_blank"&gt;this link for an introduction&lt;/a&gt; to SQL Server Object Explorer.&lt;/p&gt;  &lt;p&gt;To create a new database:&lt;/p&gt;  &lt;p&gt;1) Open the SQL Server Object Explorer toolbox using View | SQL Server Object Explorer from Visual Studio 2012.&lt;/p&gt;  &lt;p&gt;2) Drill down to the Databases node.&lt;/p&gt;  &lt;p&gt;3) Right-click and select Add New Database.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2438.image_5F00_05641AD6.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5518.image_5F00_thumb_5F00_44C1CE66.png" width="411" height="252" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;4) Visual Studio creates a database named &amp;quot;New Database&amp;quot; by default and provides an opportunity for you to change the name.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3542.image_5F00_514F7B82.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7612.image_5F00_thumb_5F00_10AD2F13.png" width="412" height="368" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;5) In this example, the database was named &amp;quot;Customer&amp;quot;. Open the new database&amp;#39;s node to view the created folders.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5657.image_5F00_61E77670.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3441.image_5F00_thumb_5F00_3321BDCE.png" width="385" height="385" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can then create tables, views, stored procedures, or whatever.&lt;/p&gt;  &lt;p&gt;Use the SQL Server Object Explorer any time you need to create or maintain a database.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1818278" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Data/default.aspx">Data</category></item><item><title>SQL Server Object Explorer in VS 2012</title><link>http://msmvps.com/blogs/deborahk/archive/2012/10/21/sql-server-object-explorer-in-vs-2012.aspx</link><pubDate>Mon, 22 Oct 2012 00:20:26 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1818274</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1818274</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/10/21/sql-server-object-explorer-in-vs-2012.aspx#comments</comments><description>&lt;p&gt;If you use Visual Studio AND SQL Server Management Studio, you&amp;#39;ll be glad to hear that the SQL Server Management Studio tools, called SQL Server Data Tools (SSDT), are now a part of Visual Studio 2012. You can create, edit, and delete SQL Server tables and stored procedures, you can write and execute queries, you can view and edit database data, and so on, all from within Visual Studio.&lt;/p&gt;  &lt;p&gt;NOTE: You can also get SSDT for Visual Studio 2010 SP1. See &lt;a href="http://msdn.microsoft.com/en-us/jj650014" target="_blank"&gt;this link&lt;/a&gt; for more information.&lt;/p&gt;  &lt;p&gt;SSDT includes database project types, the SQL Server Object Explorer toolbox, and tools to work with analysis services, reporting services and business intelligence.&amp;#160; This post focuses on just the SQL Server Object Explorer.&lt;/p&gt;  &lt;p&gt;Select View | SQL Server Object Explorer from the Visual Studio menu to display the toolbox.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4743.image_5F00_4079DB2E.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8306.image_5F00_thumb_5F00_719915CE.png" width="489" height="129" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If your SQL Server does not appear on the list, click on the Add SQL Server button in the toolbar or&amp;#160; right-click on the SQL Server node and select Add SQL Server. Enter the information to connect to one of your SQL Server databases and your SQL Server should then appear on the list.&lt;/p&gt;  &lt;p&gt;Once your instance of SQL Server appears on the list, you can drill down to see the databases and their details. You can list the tables, views, and stored procedures under each database.&lt;/p&gt;  &lt;p&gt;For example, here are the tables and stored procedures in one of my databases:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8420.image_5F00_308A966A.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0336.image_5F00_thumb_5F00_40B65E63.png" width="327" height="666" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Follow these links to see some of the things you can do with the SQL Server Object Explorer:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/10/21/adding-a-new-database-with-ssdt.aspx" target="_blank"&gt;Add a New Database&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/10/21/adding-tables-with-ssdt.aspx" target="_blank"&gt;Add a New Table&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Use the SQL Server Object Explorer to work with your SQL Server databases in Visual Studio 2012.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1818274" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Data/default.aspx">Data</category></item><item><title>Web API Help Page and XML Comments</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/27/web-api-help-page-and-xml-comments.aspx</link><pubDate>Fri, 28 Sep 2012 06:32:24 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1817487</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1817487</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/27/web-api-help-page-and-xml-comments.aspx#comments</comments><description>&lt;p&gt;The virtues of a Web API Help Page were extolled &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/27/discovering-your-web-api.aspx" target="_blank"&gt;in a prior post&lt;/a&gt;. That prior post demonstrated the &amp;quot;out of the box&amp;quot; functionality of the Microsoft ASP.NET Web API Help Page. This post extends that functionality to include the XML comments from your code.&lt;/p&gt;  &lt;p&gt;You can adjust the configuration file for the Help Page to set the documentation provider to your code&amp;#39;s XML comments. That way your help file documentation will match the XML comments from your code.&lt;/p&gt;  &lt;p&gt;Let&amp;#39;s work through an example:&lt;/p&gt;  &lt;p&gt;[See &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/23/the-world-s-simplest-web-api-poco-example.aspx"&gt;this prior post&lt;/a&gt; for an introduction to building an ASP.NET Web API service. The service created in that post is the example service used here.]&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;[[NOTE: The ASP.NET Web API Help Page is in prerelease and does not currently work with VB.NET.]]&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Here is the prior example Web API service with XML Comments added:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;using ACMService.Models;      &lt;br /&gt;using System.Collections.Generic;       &lt;br /&gt;using System.Linq;       &lt;br /&gt;using System.Net;       &lt;br /&gt;using System.Net.Http;       &lt;br /&gt;using System.Web.Http;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;namespace ACMService.Controllers      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// Provides customer information.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class CustomerController : ApiController       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Provides information for the full list of customers.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;example&amp;gt;GET api/customer&amp;lt;/example&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public IEnumerable&amp;lt;Customer&amp;gt; Get()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return Customer.Retrieve();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Provides information for a single customer by Id.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;param name=&amp;quot;id&amp;quot;&amp;gt;Customer Id&amp;lt;/param&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;example&amp;gt;GET api/customer/2&amp;lt;/example&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public Customer Get(int id)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;Customer&amp;gt; customerList = Customer.Retrieve();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Customer customerInstance = customerList.FirstOrDefault(       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; c =&amp;gt; c.CustomerId == id);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (customerInstance == null)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Content = new StringContent(&amp;quot;Could not locate a customer with id: &amp;quot; + id),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ReasonPhrase = &amp;quot;Customer Id not found&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return customerInstance;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;Imports System.Net      &lt;br /&gt;Imports System.Net.Http       &lt;br /&gt;Imports System.Web.Http&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;summary&amp;gt;      &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; Privides customer information.       &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;       &lt;br /&gt;Public Class CustomerVBController       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Inherits ApiController&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;summary&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; Provides information for the full list of customers.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;example&amp;gt;GET api/customerVB&amp;lt;/example&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Function [Get]() As IEnumerable(Of CustomerVB)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return CustomerVB.Retrieve()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Function&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;summary&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; Provides information for a single customer by Id.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;param name=&amp;quot;id&amp;quot;&amp;gt;Customer Id&amp;lt;/param&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;example&amp;gt;GET api/customerVB/2&amp;lt;/example&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Function [Get](id As Integer) As CustomerVB       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim customerList = CustomerVB.Retrieve()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim customerInstance = customerList.FirstOrDefault(       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Function(c) c.CustomerId = id)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; If customerInstance Is Nothing Then       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Throw New HttpResponseException(New HttpResponseMessage(HttpStatusCode.NotFound) With       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .Content = New StringContent(&amp;quot;Could not locate a customer with id: &amp;quot; &amp;amp; id),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .ReasonPhrase = &amp;quot;Customer Id not found&amp;quot;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; })       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End If       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return customerInstance       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Function       &lt;br /&gt;End Class&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;To modify the Help Pages to use the XML comments from the above code, follow these steps:&lt;/p&gt;  &lt;p&gt;1) Ensure that your code has XML comments. (See the examples above.)&lt;/p&gt;  &lt;p&gt;2) Modify the HelpPageConfig file.&lt;/p&gt;  &lt;p&gt;Find it in Solution Explorer under your Web API project, Areas / HelpPage / App_Start folder.&lt;/p&gt;  &lt;p&gt;3) Uncomment the code line provided in the HelpPageConfig file to set the documentation provider to the XML document generated from your Web API code.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4505.image_5F00_5CF147CF.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4617.image_5F00_thumb_5F00_508324A6.png" width="502" height="226" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;4) Ensure that your build generates the required XML file.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3482.image_5F00_4FAABEBC.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2376.image_5F00_thumb_5F00_06A49CF6.png" width="513" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;5) Ensure that the XML file name used in the dialog above matches the XML file name defined in the HelpPageConfile file:&lt;/p&gt;  &lt;p&gt;config.SetDocumentationProvider(new XmlDocumentationProvider    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; (HttpContext.Current.Server.MapPath(&amp;quot;~/&lt;font style="background-color:#ffff00;"&gt;App_Data/XmlDocument.xml&lt;/font&gt;&amp;quot;)));&lt;/p&gt;  &lt;p&gt;6) Execute the Web API project in Visual Studio and append &amp;quot;/help&amp;quot; to the address bar of the browser.&lt;/p&gt;  &lt;p&gt;The result is shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2308.image_5F00_6C6433D1.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4454.image_5F00_thumb_5F00_6B8BCDE7.png" width="498" height="407" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Notice that the description is now taken from your XML comments.&lt;/p&gt;  &lt;p&gt;Drill down to see the detail:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4807.image_5F00_6EBDB5CF.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5811.image_5F00_thumb_5F00_3B817C66.png" width="427" height="533" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Use these extra steps any time you want to use your Web API XML comments in your help pages.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1817487" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Web+API/default.aspx">Web API</category></item><item><title>Discovering your Web API</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/27/discovering-your-web-api.aspx</link><pubDate>Fri, 28 Sep 2012 05:47:18 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1817482</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1817482</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/27/discovering-your-web-api.aspx#comments</comments><description>&lt;p align="left"&gt;If your ASP.NET Web API service is on the &amp;#39;net and no one is around to explain it, does it provide a service? Unlike no one hearing the tree falling in the woods, this question is more than a philosophical thought experiment. It could be a big issue for the clients needing your service.&lt;/p&gt;  &lt;p align="left"&gt;[See &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/23/the-world-s-simplest-web-api-poco-example.aspx"&gt;this prior post&lt;/a&gt; for an introduction to building an ASP.NET Web API service. The service created in that post is the example service used here.]&lt;/p&gt;  &lt;p&gt;Once you have a Web API service in place, clients can call it. But there is no easy way for those clients to discover the available service methods or their parameters. What they need is a way to view your API.&lt;/p&gt;  &lt;p&gt;That&amp;#39;s where the &lt;strong&gt;Help Page&lt;/strong&gt; comes in to help you help them. As it states in the dialog below, &amp;quot;The ASP.NET Web API Help Page automatically generates help page content for the Web APIs on your site.&amp;quot;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0511.image_5F00_35D7DBFB.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0028.image_5F00_thumb_5F00_3493431C.png" width="505" height="359" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The Help Page is available as a NuGet Package. To install it:&lt;/p&gt;  &lt;p&gt;1) Select your Web API service project in Solution Explorer.&lt;/p&gt;  &lt;p&gt;2) Select Project | Manage NuGet Packages from the Visual Studio menu.&lt;/p&gt;  &lt;p&gt;3) Search for &amp;quot;helppage&amp;quot; using the search box in the upper right corner of the resulting dialog.&lt;/p&gt;  &lt;p&gt;4) Click the Install button next to the Microsoft ASP.NET Web API Help Page.&lt;/p&gt;  &lt;p&gt;This package adds an Areas directory into the project which contains all of the generated code:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7713.image_5F00_7A37CD3A.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7824.image_5F00_thumb_5F00_125B3796.png" width="399" height="505" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;That&amp;#39;s it. After you install it you don&amp;#39;t have to do anything else. &lt;/p&gt;  &lt;p&gt;To view the generated help page, launch your Web API service in Visual Studio and append &amp;quot;/help&amp;quot; to the url in the Address bar of the browser. The generated help page is displayed.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2500.image_5F00_1182D1AC.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4075.image_5F00_thumb_5F00_3E2B8B85.png" width="483" height="365" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Notice that it contains the name of the controller and descriptions of the two methods in the Web API service.&lt;/p&gt;  &lt;p&gt;Click on an action name to drill down. The details provide information on the parameters, if any, and the response body formats. It even contains an example response.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7120.image_5F00_487CAFE5.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3343.image_5F00_thumb_5F00_076E3081.png" width="441" height="558" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Since all of the code for these help pages are generated into your project, you can easily change them. You can style the layout and change the textual content as desired.&lt;/p&gt;  &lt;p&gt;Use the Help Page NuGet package any time you want to provide documentation to the clients of your Web API service.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1817482" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Web+API/default.aspx">Web API</category></item><item><title>Running Your Unit Tests Continuously</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/26/running-your-unit-tests-continuously.aspx</link><pubDate>Wed, 26 Sep 2012 23:56:45 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1817407</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1817407</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/26/running-your-unit-tests-continuously.aspx#comments</comments><description>&lt;p&gt;One of the new unit testing features in VS 2012 (Premium or Ultimate) is the continuous test runner. When turned on, it automatically executes your unit tests after every successful build.&lt;/p&gt;  &lt;p&gt;Digressing a moment … in the early 1990&amp;#39;s Shari Lewis and Lamb Chop would sing a version of &amp;quot;The Song that Never Ends&amp;quot; at the end of each episode of their show. In memory of Lamb Chop:&lt;/p&gt;  &lt;p align="center"&gt;&lt;font color="#f79646"&gt;It is the test that never ends.     &lt;br /&gt;It goes on and on my friends.      &lt;br /&gt;Someone starting running it not knowing what it was,      &lt;br /&gt;and they&amp;#39;ll continue running it forever just because… &amp;lt;repeat&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;To turn on the continuous test runner, select the icon in the upper left corner of the Test Explorer:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3252.image_5F00_46A7E3D6.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6013.image_5F00_thumb_5F00_37FD37F1.png" width="491" height="174" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The tests will automatically execute asynchronously after each build. They also automatically run when first opening a solution containing the tests.&lt;/p&gt;  &lt;p&gt;NOTE: The tests are not executed after a build that is part of a Start With Debugging (F5) or Start Without Debugging operation.&lt;/p&gt;  &lt;p&gt;Any failed tests from previous runs are executed first. If they pass, the other (previously passed) tests are executed. If they fail, the other (previously passed) tests are not executed.&lt;/p&gt;  &lt;p&gt;This last point has caused me problems. I made a change that would have caused a previously passed tests to fail but I was not notified because I have some other failing tests. I had to manually run the tests in order for the previously passed tests to fail appropriately.&lt;/p&gt;  &lt;p&gt;Use the search feature of Test Explorer (&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/16/searching-and-grouping-in-vs-2012-test-explorer.aspx"&gt;detailed in this prior post&lt;/a&gt;) to filter the list of tests to execute.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1817407" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Adding Simple Exception Handling to your Web API Service</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/24/adding-simple-exception-handling-to-your-web-api-service.aspx</link><pubDate>Tue, 25 Sep 2012 06:47:04 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1817277</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1817277</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/24/adding-simple-exception-handling-to-your-web-api-service.aspx#comments</comments><description>&lt;p&gt;There is nothing perfect in life, not even an ASP.NET Web API service. The service may not understand the provided parameters, or may not find the requested data, or may have trouble connecting to the database. Whatever the issue, if the service cannot return the desired data it would be nice to instead return an appropriate exception notification.&lt;/p&gt;  &lt;p&gt;[See &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/23/the-world-s-simplest-web-api-poco-example.aspx"&gt;this prior post&lt;/a&gt; for an introduction to building an ASP.NET Web API service. The service created in that post is the example service used here.]&lt;/p&gt;  &lt;p&gt;The following code is the ASP.NET Web API service controller from the example mentioned above, but with a simple exception.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;using ACMService.Models;     &lt;br /&gt;using System;      &lt;br /&gt;using System.Collections.Generic;      &lt;br /&gt;using System.Linq;      &lt;br /&gt;using System.Net;      &lt;br /&gt;using System.Net.Http;      &lt;br /&gt;using System.Web.Http;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;namespace ACMService.Controllers     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class CustomerController : ApiController      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // GET api/customer      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public IEnumerable&amp;lt;Customer&amp;gt; Get()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return Customer.Retrieve();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // GET api/customer/5     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public Customer Get(int id)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;Customer&amp;gt; customerList = Customer.Retrieve();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Customer customerInstance = customerList.FirstOrDefault(      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; c =&amp;gt; c.CustomerId == id);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (customerInstance == null)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; throw new ApplicationException(&amp;quot;Customer not found&amp;quot;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return customerInstance;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;Imports System.Net     &lt;br /&gt;Imports System.Net.Http      &lt;br /&gt;Imports System.Web.Http&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;Public Class CustomerVBController     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Inherits ApiController&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39; GET api/customerVB     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Function [Get]() As IEnumerable(Of CustomerVB)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return CustomerVB.Retrieve()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Function&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39; GET api/customerVB/2     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Function [Get](id As Integer) As CustomerVB      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim customerList = CustomerVB.Retrieve()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim customerInstance = customerList.FirstOrDefault(      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Function(c) c.CustomerId = id)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; If customerInstance Is Nothing Then      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Throw New ApplicationException(&amp;quot;Customer not found&amp;quot;)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End If      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return customerInstance      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Function      &lt;br /&gt;End Class&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Run the application. Press F12 to launch the F12 developer tools. Select the Network tab and the Start capturing button. [For more information on the F12 tools, see &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/23/using-ie-9-and-f12-to-debug-your-web-api-service.aspx" target="_blank"&gt;this prior post&lt;/a&gt;.]&lt;/p&gt;  &lt;p&gt;Then add to the address bar the following: api/customer/10 (api/customerVB/10 in the VB example).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5078.image_5F00_52CBC8CD.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3463.image_5F00_thumb_5F00_03EB036E.png" width="496" height="39" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The F12 window displays the request with a result of 500: Internal Server Error. When an exception is thrown in a Web API controller, by default the response is returned with a status code of 500.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6082.image_5F00_583A3971.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2728.image_5F00_thumb_5F00_02A66A8F.png" width="501" height="184" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Select the request and click the Go to detailed view button to see the details. Click on the Response body tab to see the error message as a JSON string.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0184.image_5F00_36DA93D5.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3362.image_5F00_thumb_5F00_2110AB78.png" width="496" height="219" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Notice that it provides the full stack trace. This can be helpful when debugging the application, but may provide more information than you want to share when your service goes live.&lt;/p&gt;  &lt;p&gt;As an alternative, you could use the provided HttpResponseException. By default, this has a header but no content. And instead of always returning a 500 status code, it returns the code you specify.&lt;/p&gt;  &lt;p&gt;Change the exception thrown in the example above to instead throw a new HttpResponseException.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound))&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Repeat the steps above to look at the result with the F12 developer tool:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4846.image_5F00_74F3AE86.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5751.image_5F00_thumb_5F00_1436555A.png" width="467" height="149" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Notice that the Result is now a 404: Not found. Looking at the detail, there is no body to display.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2664.image_5F00_539408EA.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5226.image_5F00_thumb_5F00_3D5DED98.png" width="471" height="197" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;But what if you do want to provide more information, such as a more detailed message? The HttpResponseException provides properties that allow you to specify more information.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;Content&lt;/strong&gt; property allows you to provide a response body.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;ReasonPhrase&lt;/strong&gt; property is a textual description of the status code. You can add any text you would like, such as &amp;quot;Customer Id not found&amp;quot;. This may be more useful to the client applications than getting a 404.&lt;/p&gt;  &lt;p&gt;Change the exception in the prior example as shown below.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In&amp;#160; C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)&amp;#160; &lt;br /&gt;&amp;#160; {&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160; Content = new StringContent(&amp;quot;Could not locate a customer with id: &amp;quot;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt; + id),     &lt;br /&gt;&amp;#160;&amp;#160; ReasonPhrase = &amp;quot;Customer Id not found&amp;quot;      &lt;br /&gt;&amp;#160; });&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#333333" size="2" face="Consolas"&gt;Throw New HttpResponseException(New HttpResponseMessage(HttpStatusCode.NotFound) With     &lt;br /&gt;{      &lt;br /&gt;.Content = New StringContent(&amp;quot;Could not locate a customer with id: &amp;quot; &amp;amp;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id),      &lt;br /&gt;.ReasonPhrase = &amp;quot;Customer Id not found&amp;quot;      &lt;br /&gt;})&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2" face="Consolas"&gt;Repeating the F12 process one more time... Notice that the Response Body now includes the information provided in the Content property. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3187.image_5F00_3C8587AE.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0066.image_5F00_thumb_5F00_42CC5E3C.png" width="529" height="190" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you developed the JavaScript client as shown in &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/23/building-a-javascript-client-for-a-web-api-service.aspx" target="_blank"&gt;this prior post&lt;/a&gt;, you&amp;#39;ll notice that it already has code to handle an exception. The result is shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3527.image_5F00_620F050F.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3630.image_5F00_thumb_5F00_483ACEE0.png" width="528" height="146" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Use the HttpResponseException whenever you want to control the exception information passed to your ASP.NET Web service clients.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1817277" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Web+API/default.aspx">Web API</category></item><item><title>Building a JavaScript Client for a Web API Service</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/23/building-a-javascript-client-for-a-web-api-service.aspx</link><pubDate>Mon, 24 Sep 2012 05:54:24 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1817219</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1817219</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/23/building-a-javascript-client-for-a-web-api-service.aspx#comments</comments><description>&lt;p&gt;An ASP.NET Web API service provides support for many different types of client applications. One such client is a JavaScript application. This post provides a very simple JavaScript client you can use to test your Web API service.&lt;/p&gt;  &lt;p&gt;[See &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/23/the-world-s-simplest-web-api-poco-example.aspx"&gt;this prior post&lt;/a&gt; for an introduction to building an ASP.NET Web API service. The service created in that post is the example service used here.]&lt;/p&gt;  &lt;p&gt;Here is the HTML/JavaScript code to display all of the key/value pairs for a single object returned by a Web API service.&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;lt;!DOCTYPE html&amp;gt;      &lt;br /&gt;&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;       &lt;br /&gt;&amp;lt;head&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;title&amp;gt;Customer Information&amp;lt;/title&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;script src=&amp;quot;../../Scripts/jquery-1.7.1.min.js&amp;quot;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $(document).ready(function () {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Send an AJAX request for Customer Info      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.getJSON(&amp;quot;api/customer/2&amp;quot;,      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; function (data) {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // On success, &amp;#39;data&amp;#39; contains the customer details.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.each(data, function (key, val) {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Format the text to display.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var str = key + &amp;#39;: &amp;#39; + val;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Add a paragraph for each property.      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $(&amp;#39;#info&amp;#39;).append(&amp;#39;&amp;lt;p&amp;gt;&amp;#39; + str + &amp;#39;&amp;lt;/p&amp;gt;&amp;#39;);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; })      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; })&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Handle a fail     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .fail(      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; function (jqXHR, textStatus, err) {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $(&amp;#39;#info&amp;#39;).html(&amp;#39;Error: &amp;#39; + err);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/script&amp;gt;      &lt;br /&gt;&amp;lt;/head&amp;gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;lt;body&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;div&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;h1&amp;gt;Customer Account Information&amp;lt;/h1&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;p id=&amp;#39;info&amp;#39; /&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/div&amp;gt;       &lt;br /&gt;&amp;lt;/body&amp;gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;lt;/html&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If you followed the prior post mentioned above and built the sample Web API service, you can delete all of the code from the Index.cshtml file and replace it with the above code.&lt;/p&gt;  &lt;p&gt;When you run the application, you get this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4428.image_5F00_4076F460.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3750.image_5F00_thumb_5F00_589A5EBB.png" width="479" height="234" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Let&amp;#39;s go through the JQuery script code. The example uses the 1.7.1 version of JQuery. The script itself does the following:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;$.getJSON: Gets the JSON format of the data returned when passing &amp;quot;api/customer/2&amp;quot; to the Web API service. You can change the url string passed to the service to match any url accepted by your service.&lt;/li&gt;    &lt;li&gt;$.each: Iterates over each object, executing a function for each one. In this case, it processes each name/value pair provided by the JSON format.&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;It builds a string with the name of the field, a colon, and the value.&lt;/li&gt;      &lt;li&gt;It adds the string to a paragraph element and then appends the paragraph to an element with an Id of #info.&lt;/li&gt;   &lt;/ul&gt;    &lt;li&gt;.fail: Provides error information if an error is returned by the service.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The HTML code displays the header and a paragraph placeholder that is extended by the script.&lt;/p&gt;  &lt;p&gt;If you want to display a set of business objects with their name/value pairs, you can change the script as follows:&lt;/p&gt;  &lt;p&gt;   &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; $(document).ready(function () {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Send an AJAX request for Customer Info        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.getJSON(&amp;quot;api/customer&amp;quot;,        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; function (data) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // On success, &amp;#39;data&amp;#39; contains the customers details.         &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.each(data, function (key, row) {&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $(&amp;#39;#info&amp;#39;).append(&amp;#39;&amp;lt;p&amp;gt;&amp;#39; + &amp;#39;Item: &amp;#39; + key + &amp;#39;&amp;lt;/p&amp;gt;&amp;#39;);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Process each customer (&amp;quot;row&amp;quot;)        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $.each(row, function (rowKey, rowValue) {&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Format the text to display.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; var str = rowKey + &amp;#39;: &amp;#39; + rowValue;&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Add a paragraph for each property.        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $(&amp;#39;#info&amp;#39;).append(&amp;#39;&amp;lt;p style=&amp;quot;text-indent: 5em;&amp;quot;&amp;gt;&amp;#39;        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;+&lt;/font&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt; str + &amp;#39;&amp;lt;/p&amp;gt;&amp;#39;);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; })        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; })        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; })&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Handle a fail       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .fail(        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; function (jqXHR, textStatus, err) {        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $(&amp;#39;#info&amp;#39;).html(&amp;#39;Error: &amp;#39; + err);        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });        &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });        &lt;br /&gt;&amp;lt;/script&amp;gt;&lt;/font&gt;&lt;/p&gt; &lt;/p&gt;  &lt;p&gt;This script includes two .each methods, the first one processes each customer and the second one processes each field of the customer from the JSON.&lt;/p&gt;  &lt;p&gt;The result of this script is shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0741.image_5F00_70BDC916.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2766.image_5F00_thumb_5F00_76986CAF.png" width="438" height="555" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Notice that both scripts could be used for any set of JSON objects returned from a Web API service. You just need to change the url string as appropriate for the service.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1817219" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Web+API/default.aspx">Web API</category></item><item><title>Using IE 9 and F12 to Debug your Web API Service</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/23/using-ie-9-and-f12-to-debug-your-web-api-service.aspx</link><pubDate>Mon, 24 Sep 2012 00:39:31 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1817209</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1817209</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/23/using-ie-9-and-f12-to-debug-your-web-api-service.aspx#comments</comments><description>&lt;p&gt;Internet Explorer 9 allows you to see the HTTP request and response information using the F12 developer tools. This can be useful when debugging or testing your ASP.NET Web API service.&lt;/p&gt;  &lt;p&gt;[See &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/23/the-world-s-simplest-web-api-poco-example.aspx" target="_blank"&gt;this prior post&lt;/a&gt; for an introduction to building an ASP.NET Web API service. The service created in that post is the example service used here.]&lt;/p&gt;  &lt;p&gt;Start your Web API Service in Visual Studio, viewing it in Internet Explorer 9. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6175.image_5F00_34881907.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4442.image_5F00_thumb_5F00_1394A660.png" width="495" height="423" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I always forget which key to press for the F12 developer tools, but if I recall correctly, it is F12. :-)&lt;/p&gt;  &lt;p&gt;The tool window appears as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8508.image_5F00_326B1A3E.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5074.image_5F00_thumb_5F00_669F4384.png" width="487" height="241" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Select the Network tab and click the Start Capturing button to start capturing the HTTP request and response information. Then select the browser window and add &amp;quot;api/customer&amp;quot; (or &amp;quot;api/customerVB&amp;quot; for the VB service) to the address bar. Cancel the request to open or save the result.&lt;/p&gt;  &lt;p&gt;Returning to the F12 window, you will see the HTTP request:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0525.image_5F00_110B74A2.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7558.image_5F00_thumb_5F00_77373E72.png" width="485" height="112" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Select the api/Customer entry and click the Go to detailed view button. From there, you can view the Request header to see more details on the request. Click the Response body to see the response:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4353.image_5F00_4F90C248.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1072.image_5F00_thumb_5F00_27EA461E.png" width="487" height="215" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Right-click on the body and select Word Wrap from the context menu to view the JSON in a nicer layout:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1172.image_5F00_229B5F6D.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5633.image_5F00_thumb_5F00_660360CF.png" width="493" height="218" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Use the F12 tool whenever you need to debug or test your Web API service or any client calling your Web API service.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1817209" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Web+API/default.aspx">Web API</category></item><item><title>The World's Simplest Web API/POCO Example</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/23/the-world-s-simplest-web-api-poco-example.aspx</link><pubDate>Sun, 23 Sep 2012 23:28:40 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1817203</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1817203</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/23/the-world-s-simplest-web-api-poco-example.aspx#comments</comments><description>&lt;p&gt;This post demonstrates how to use the ASP.NET Web API to access plain old custom objects (POCO) and build a service for a line of business application. No Entity Framework (EF).&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;Web API&lt;/strong&gt; is a new easy-to-use framework that allows you to build a service that can send or receive data over HTTP to a range of clients. If this sounds something like Windows Communication Foundation (WCF), you are right. But this new framework is MUCH easier to use and provides content that is much easier to consume by client applications.&lt;/p&gt;  &lt;p&gt;A Web API service can provide content to .NET clients, but also JavaScript clients and clients written in other languages such as Ruby or Python. It provides that content in different formats such as XML or JSON (JavaScript Object Notation).&lt;/p&gt;  &lt;p&gt;The example in this post is as absolutely simple as possible to help you get up and running with these technologies. To meet this goal, this first post covers how to build a service that only provides data. Later posts will cover building clients to get the data, and updating the service for insert and update operations.&lt;/p&gt;  &lt;p&gt;So first, the &lt;strong&gt;prerequisites&lt;/strong&gt;:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;If you are using Visual Studio 2012 you are ready. &lt;/li&gt;    &lt;li&gt;If you are using Visual Studio 2010, download and install &lt;a href="http://www.microsoft.com/en-us/download/details.aspx?id=30683" target="_blank"&gt;ASP.NET MVC 4 for Visual Studio 2010 SP1 and Visual Web Developer 2010 SP1&lt;/a&gt;. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Since Visual Studio 2012 is now officially released, the screen shots in this post are all of the Visual Studio 2012 tools.&lt;/p&gt;  &lt;h2&gt;STEP 1: Create the Web API project.&lt;/h2&gt;  &lt;p&gt;1) In Visual Studio, select File | New | Project&lt;/p&gt;  &lt;p&gt;2) Select the ASP.NET MVC 4 Web Application under the Visual Basic or Visual C# templates and click OK.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6253.image_5F00_73580177.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2783.image_5F00_thumb_5F00_6B605F15.png" width="443" height="308" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;3) Select Web API as the project template and click OK.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8171.image_5F00_1C7F99B6.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3312.image_5F00_thumb_5F00_5766CC7F.png" width="448" height="402" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Visual Studio creates all of the files you need to get started with your Web API service. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7462.image_5F00_61B7F0DF.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5417.image_5F00_thumb_5F00_7902F550.png" width="453" height="347" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The resulting code is complete enough to execute. If you run the application at this point (F5) it appears as follows:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3201.image_5F00_5F2EBF21.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5126.image_5F00_thumb_5F00_7752297C.png" width="451" height="386" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To see the data provided by the default service, add &amp;quot;api/values&amp;quot; to the end of the string in the address bar. The result is something like: http://localhost:2152/api/values. You will then be asked to open or save the data returned by the service. Select to Open and if asked, select to open with Notepad. The result is:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7888.image_5F00_565EB6D5.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7713.image_5F00_thumb_5F00_23227D6C.png" width="459" height="120" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;So the default pre-built service returns two values in JSON format called &amp;quot;value1&amp;quot; and &amp;quot;value2&amp;quot;. Yes, well it is a start.&lt;/p&gt;  &lt;p&gt;The key parts of code required for a Web API service are the Models and the Controllers.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;Models&lt;/strong&gt; provide the content for your service. They define which data or other content that your service will expose to client applications. For example, for the Acme Customer Management application, the models could include Customer, Purchase, and Invoice. These would expose basic customer information, customer purchasing information, and customer invoice information.&lt;/p&gt;  &lt;p&gt;No models are created for you in this case. They are created manually as defined in the next step.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;Controllers&lt;/strong&gt; basically control your service. They define the actions that your service accepts and performs the response appropriate for the requested action. For example the Acme Customer Management application would provide a Get action that would return the list of all of the customers and a Get action with a key that would provide information for a specific customer.&lt;/p&gt;  &lt;p&gt;Two controllers are created in the generated code. The HomeController is a MVC controller which controls the generated sample user interface. The ValueController is the sample Web API controller that provided the two values shown in the screen shot above. You can delete it.&lt;/p&gt;  &lt;h2&gt;STEP 2: Add your Model&lt;/h2&gt;  &lt;p&gt;The service is this example provides customer information. That information is defined in the model with a Customer class.&lt;/p&gt;  &lt;p&gt;1) Right-click on the Models folder in Solution Explorer and select Add | Class.&lt;/p&gt;  &lt;p&gt;2) Add the code for a Customer class.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;using System.Collections.Generic;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;namespace ACMService.Models      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class Customer       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public int CustomerId { get; set; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string LastName { get; set; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string FirstName { get; set; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public string EmailAddress { get; set; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;summary&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// Retrieves a list of customers.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;remarks&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// In a &amp;quot;real&amp;quot; application, this code would       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// call a data access component that retrieves       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// the data from a database.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; /// &amp;lt;/remarks&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static List&amp;lt;Customer&amp;gt; Retrieve()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;Customer&amp;gt; custList = new List&amp;lt;Customer&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {new Customer()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { CustomerId = 1,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FirstName=&amp;quot;Bilbo&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LastName = &amp;quot;Baggins&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EmailAddress = &amp;quot;bb@hob.me&amp;quot;},       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; new Customer()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { CustomerId = 2,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FirstName=&amp;quot;Frodo&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LastName = &amp;quot;Baggins&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EmailAddress = &amp;quot;fb@hob.me&amp;quot;},       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; new Customer()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { CustomerId = 3,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FirstName=&amp;quot;Samwise&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LastName = &amp;quot;Gamgee&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EmailAddress = &amp;quot;sg@hob.me&amp;quot;},       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; new Customer()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { CustomerId = 4,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FirstName=&amp;quot;Rosie&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; LastName = &amp;quot;Cotton&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EmailAddress = &amp;quot;rc@hob.me&amp;quot;}};       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return custList;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;summary&amp;gt;      &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; Manages a customer       &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;       &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39; &amp;lt;editHistory&amp;gt;&amp;lt;/editHistory&amp;gt;       &lt;br /&gt;Public Class CustomerVB       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Property CustomerId As Integer       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Property FirstName() As String       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Property LastName() As String       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Property EmailAddress() As String&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;summary&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; Retrieves a list of customers.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;remarks&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; In a &amp;quot;real&amp;quot; application, this code would       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; call a data access component that retrieves       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; the data from a database.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39;&amp;#39;&amp;#39; &amp;lt;/remarks&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Shared Function Retrieve() As List(Of CustomerVB)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim custList As New List(Of CustomerVB) From       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {New CustomerVB() With       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {.CustomerId = 1,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .FirstName = &amp;quot;Bilbo&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .LastName = &amp;quot;Baggins&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .EmailAddress = &amp;quot;bb@hob.me&amp;quot;},       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; New CustomerVB() With       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {.CustomerId = 2,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .FirstName = &amp;quot;Frodo&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .LastName = &amp;quot;Baggins&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .EmailAddress = &amp;quot;fb@hob.me&amp;quot;},       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; New CustomerVB() With       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {.CustomerId = 3,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .FirstName = &amp;quot;Samwise&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .LastName = &amp;quot;Gamgee&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .EmailAddress = &amp;quot;sg@hob.me&amp;quot;},       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; New CustomerVB() With       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {.CustomerId = 4,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .FirstName = &amp;quot;Rosie&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .LastName = &amp;quot;Cotton&amp;quot;,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .EmailAddress = &amp;quot;rc@hob.me&amp;quot;}}       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return custList       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Function       &lt;br /&gt;End Class&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: This code does not use a data access layer at this time. To keep this example as simple as possible, the Retrieve method &amp;quot;mocks&amp;quot; a retrieve that would call your data access component and retrieve the data from the database. This code will be replaced in a later post to actually access a database.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: Normally I build a Customer class (singular) with the properties and methods that mange a singe customer and a Customers class (plural) that works with a list of those customers. The functionality for both were added to one class to keep this example as simple as possible.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step 3: Add your Controller&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The controller in this example provides two operations: one to get all customers, and one to get one customer by Id.&lt;/p&gt;  &lt;p&gt;1) Right-click on the Controllers folder in Solution Explorer and select Add | Controller.&lt;/p&gt;  &lt;p&gt;2) Select Empty API Controller&lt;/p&gt;  &lt;p&gt;Visual Studio provides several scaffolding options, which define the type of code that it will automatically generate in the controller. To keep this example simple, it will only provide read actions, so select&amp;#160; Empty API Controller.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6758.image_5F00_628030FC.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3124.image_5F00_thumb_5F00_48ABFACD.png" width="485" height="331" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;3) Write the code for the controller.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;using ACMService.Models;      &lt;br /&gt;using System.Collections.Generic;       &lt;br /&gt;using System.Linq;       &lt;br /&gt;using System.Web.Http;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;namespace ACMService.Controllers      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class CustomerController : ApiController       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // GET api/customer       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public IEnumerable&amp;lt;Customer&amp;gt; Get()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return Customer.Retrieve();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // GET api/customer/2      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public Customer Get(int id)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;Customer&amp;gt; customerList = Customer.Retrieve();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Customer customerInstance = customerList.FirstOrDefault(       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; c =&amp;gt; c.CustomerId == id);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return customerInstance;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;Imports System.Net      &lt;br /&gt;Imports System.Web.Http&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;Public Class CustomerVBController      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Inherits ApiController&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39; GET api/customerVB      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Function [Get]() As IEnumerable(Of CustomerVB)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return CustomerVB.Retrieve()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Function&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" size="2" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; &amp;#39; GET api/customerVB/2      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Function [Get](id As Integer) As CustomerVB       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim customerList = CustomerVB.Retrieve()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Dim customerInstance = customerList.FirstOrDefault(       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Function(c) c.CustomerId = id)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return customerInstance       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Function       &lt;br /&gt;End Class&lt;/font&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;The controller class inherits from ApiController. This ensures that the service understands that this is a Web API controller class.&lt;/p&gt;  &lt;p&gt;The class is called CustomerController (CustomerVBController in the VB example). The name should define the type of content the controller provides and end with &amp;quot;Controller&amp;quot;. The service automatically locates the controller by name. To access the CustomerController, you would add &amp;quot;api/Customer&amp;quot; to the address bar and .NET automatically executes the Get method in the CustomerController class. (Enter api/CustomerVB to call the CustomerVBController.)&lt;/p&gt;  &lt;p&gt;Both functions are named &amp;quot;Get&amp;quot;. Note that in VB, &amp;quot;Get&amp;quot; is a keyword so it needs brackets around it to use it as a function name. But you could change the name to something more specific like GetCustomer.&lt;/p&gt;  &lt;p&gt;The functions contain code to provide the requested data. The Get without any parameters retrieves the entire list. The Get with the id parameter uses LINQ with a Lambda expression to find the requested customer in the list. (For an overview of Lambda expressions, see &lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/10/11/lambda-expressions-an-introduction.aspx" target="_blank"&gt;this link&lt;/a&gt;.)&lt;/p&gt;  &lt;p&gt;NOTE: This is not the most efficient approach to retrieve one customer. You would instead want to get the one requested customer from the database.&lt;/p&gt;  &lt;p&gt;Now when you run the application, the same Welcome page appears because we have not changed the UI. And since we are building a service, we could actually remove the default UI.&lt;/p&gt;  &lt;p&gt;To get the customer data, add &amp;quot;api/customer&amp;quot; to the address bar. (&amp;quot;api/customerVB&amp;quot; if you are running the VB example.)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4456.image_5F00_47D394E3.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7608.image_5F00_thumb_5F00_723FC600.png" width="481" height="34" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you open the results in Notepad, you will see the following:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3404.image_5F00_18A1A94C.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2437.image_5F00_thumb_5F00_1EE87FDA.png" width="484" height="100" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;If you instead add &amp;quot;api/customer/2&amp;quot; to the address bar (&amp;quot;api/customerVB/2&amp;quot; in VB), you get this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8712.image_5F00_0C338623.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4846.image_5F00_thumb_5F00_648D09F8.png" width="487" height="84" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Use this basic set of steps as a starting point for building your Web API service.&lt;/p&gt;  &lt;p style="line-height:normal;"&gt;&lt;/p&gt;  &lt;p style="line-height:normal;"&gt;&lt;font face="Times New Roman"&gt;&lt;font color="#000000"&gt;&lt;font style="font-size:12pt;"&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; Enjoy!    &lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1817203" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/.NET/default.aspx">.NET</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Web+API/default.aspx">Web API</category></item><item><title>Test Explorer in Visual Studio 2012</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/16/test-explorer-in-visual-studio-2012.aspx</link><pubDate>Mon, 17 Sep 2012 00:30:02 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1816381</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1816381</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/16/test-explorer-in-visual-studio-2012.aspx#comments</comments><description>&lt;p&gt;One of the new things about testing in Visual Studio 2012 is that it is now available in *all* editions of Visual Studio all the way to Visual Studio Express!&lt;/p&gt;  &lt;p&gt;The Test Explorer in Visual&amp;#160; Studio 2012 replaces the Test View window in Visual Studio 2010. The following posts outline the Test Explorer features:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/15/layout-of-test-explorer-in-visual-studio-2012.aspx"&gt;Layout of Test Explorer in Visual Studio 2012&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/16/searching-and-grouping-in-vs-2012-test-explorer.aspx"&gt;Searching and Grouping in VS 2012 Test Explorer&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/16/101-ways-to-run-tests-with-visual-studio-2012.aspx"&gt;101 Ways to Run Tests with Visual Studio 2012&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/26/running-your-unit-tests-continuously.aspx"&gt;Running your Unit Tests Continuously&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1816381" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Testing/default.aspx">Testing</category></item><item><title>101 Ways to Run Tests with Visual Studio 2012</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/16/101-ways-to-run-tests-with-visual-studio-2012.aspx</link><pubDate>Sun, 16 Sep 2012 20:59:09 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1816376</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1816376</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/16/101-ways-to-run-tests-with-visual-studio-2012.aspx#comments</comments><description>&lt;p&gt;OK 101 is an exaggeration, but there are many ways to run your tests in Visual Studio 2012.&lt;/p&gt;  &lt;h2&gt;From the test code file&lt;/h2&gt;  &lt;p&gt;While you are writing or editing a test method, you can right click anywhere within the method and run or debug the test.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6518.image_5F00_5C642DDC.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0753.image_5F00_thumb_5F00_261305CD.png" width="477" height="495" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;[Red rectangle added for illustration.]&lt;/p&gt;  &lt;p&gt;All of the tests in Test Explorer are displayed &amp;quot;grayed out&amp;quot; except for the executed test as shown below. Click on the test to view the result details in the right pane (or bottom pane if your Test Explorer is sized to display vertically).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5700.image_5F00_79F608DB.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0131.image_5F00_thumb_5F00_6B4B5CF6.png" width="480" height="204" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;From the code editor, you can also run all of the tests within a code file by right-clicking anywhere within the code file, but outside of a specific method. Clicking in an empty space between two methods, for example, will execute all of the tests in the code file.&lt;/p&gt;  &lt;h2&gt;From Test Explorer Toolbar&lt;/h2&gt;  &lt;p&gt;View the Test Explorer window using Test | Windows | Test Explorer. The Test Explorer window toolbar provides many ways to run your tests.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8156.image_5F00_0A8E03CA.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3113.image_5F00_thumb_5F00_296477A8.png" width="493" height="193" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Run All&lt;/strong&gt;       &lt;br /&gt;Runs all of the tests displayed in Test Explorer. If the list of tests are filtered by search criteria, only the filtered tests are executed. (See &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/16/searching-and-grouping-in-vs-2012-test-explorer.aspx"&gt;this prior blog post&lt;/a&gt; for information on searching within Test Explorer.) &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Run Failed Tests&lt;/strong&gt;       &lt;br /&gt;Runs only the failed tests displayed in Test Explorer. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Run Not Run Tests&lt;/strong&gt;       &lt;br /&gt;Only runs the tests displayed in Test Explorer which were not previously run since opening Visual Studio. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Run Passed Tests&lt;/strong&gt;       &lt;br /&gt;Runs only the passed tests displayed in Test Explorer. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Repeat Last Run&lt;/strong&gt;       &lt;br /&gt;Runs the prior test run again, but only on the files displayed in Test Explorer. If you Run All then filter the tests in Test Explorer then Repeat Last Run, only the filtered tests will be executed again. &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;From Test Explorer Context Menu&lt;/h2&gt;  &lt;p&gt;Right-clicking on a test in Test Explorer provides run options.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7026.image_5F00_5D98A0EE.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4152.image_5F00_thumb_5F00_7CDB47C1.png" width="466" height="285" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can select a single test, multiple tests using the Ctrl and Shift keys, or all tests using the Select All option from the context menu. Then you can Run or Debug the selected tests.&lt;/p&gt;  &lt;p&gt;Use these techniques to run only the tests you are interested in.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1816376" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Searching and Grouping in VS 2012 Test Explorer</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/16/searching-and-grouping-in-vs-2012-test-explorer.aspx</link><pubDate>Sun, 16 Sep 2012 19:59:50 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1816374</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1816374</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/16/searching-and-grouping-in-vs-2012-test-explorer.aspx#comments</comments><description>&lt;p&gt;Visual Studio 2012 Test Explorer has extensive searching and limited grouping capabilities. (Visual Studio 2010&amp;#39;s Test View window had more grouping options by way of its many sorting parameters.)&lt;/p&gt;  &lt;h2&gt;Searching&lt;/h2&gt;  &lt;p&gt;Entering text into the Test Explorer Search box filters the list of tests to those containing the entered text. In the example below, entering &amp;quot;customer&amp;quot; in the search box filters the list to all test names containing &amp;quot;customer&amp;quot;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1184.image_5F00_0DC5C163.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7701.image_5F00_thumb_5F00_7F1B157D.png" width="484" height="190" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;By default, the search matches within the test name, but there are other choices. To view the other options, click the down arrow to the right of the Search box in the toolbar as shown below. Even though it looks a little like one large option name, these are actually three options:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Test File Path &lt;/li&gt;    &lt;li&gt;Fully Qualified Name &lt;/li&gt;    &lt;li&gt;Test Result &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4276.image_5F00_452BD291.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0410.image_5F00_thumb_5F00_6B8DB5DC.png" width="487" height="191" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Select one of these options, then type the search parameter within the provided quotation marks. Press the Enter key to execute the search.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2480.image_5F00_6A491CFD.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3580.image_5F00_thumb_5F00_42A2A0D3.png" width="492" height="209" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Test File Path&lt;/strong&gt; searches the paths to the test code files. In this example, the tests are in two components in two different directories:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;C:\Users\Deborah\Speaking\Other\AcmeCustomerManagement_BestKeptSecrets_2012\ACM.LibraryCSharpTest &lt;/li&gt;    &lt;li&gt;C:\Users\Deborah\Speaking\Other\AcmeCustomerManagement_BestKeptSecrets_2012\ACM.BLCSharpTest &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The above example finds all of the tests in the LibraryCSharpTest component.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Fully Qualified Name&lt;/strong&gt; searches the path and file name.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Test Result&lt;/strong&gt; has several valid search parameters: &amp;quot;Not Run&amp;quot;, &amp;quot;Skipped&amp;quot;, &amp;quot;Passed&amp;quot; or &amp;quot;Failed&amp;quot;. These options filter the list to defined&amp;#160; test outcome.&lt;/p&gt;  &lt;h2&gt;Grouping&lt;/h2&gt;  &lt;p&gt;By default, the Test Explorer groups the tests by test outcome as shown in the prior screen shots. The only other group-by option is by duration. This groups by the time it took to execute the test.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3808.image_5F00_76D6CA19.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3426.image_5F00_thumb_5F00_161970ED.png" width="500" height="213" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Use these techniques to filter and group the tests in the Test Explorer window.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;  &lt;p&gt;EDITED 9/28/12 to correct typographical errors.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1816374" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Layout of Test Explorer in Visual Studio 2012</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/15/layout-of-test-explorer-in-visual-studio-2012.aspx</link><pubDate>Sun, 16 Sep 2012 01:18:47 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1816355</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1816355</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/15/layout-of-test-explorer-in-visual-studio-2012.aspx#comments</comments><description>&lt;p&gt;In Visual Studio 2012, the Visual Studio 2010 Test View window has been replaced by a new Test Explorer window.&lt;/p&gt;  &lt;p&gt;By default, it appears on the left side of the Visual Studio Interactive Development Environment (IDE) as shown below:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6232.image_5F00_34357AEE.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4520.image_5F00_thumb_5F00_16E02324.png" width="490" height="350" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;(Red box added for illustration)&lt;/p&gt;  &lt;p&gt;When you run the unit tests, the result appears in the bottom panel of the Test Explorer window:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2818.image_5F00_6337B6C5.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1307.image_5F00_thumb_5F00_7AEEEE2B.png" width="475" height="340" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Since many unit tests may have the same prefix and a long and descriptive name, docking the Test Explorer on the left often cuts off the unique portions of the names. Instead of making the window wider, consider moving it to the bottom:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3343.image_5F00_52700C17.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3487.image_5F00_thumb_5F00_2D724B9E.png" width="489" height="327" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;(Red box added for illustration)&lt;/p&gt;  &lt;p&gt;The test results now appear in the right panel of the Test Explorer window:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3302.image_5F00_257AA93C.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6567.image_5F00_thumb_5F00_64D85CCC.png" width="493" height="198" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Moving the Test Explorer window from the left side to the bottom gives you more horizontal space to view the tests and their execution times. It also gives you more space to view the test results.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1816355" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Solution Explorer in Visual Studio 2012</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/09/solution-explorer-in-visual-studio-2012.aspx</link><pubDate>Sun, 09 Sep 2012 22:53:02 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1816080</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1816080</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/09/solution-explorer-in-visual-studio-2012.aspx#comments</comments><description>&lt;p&gt;There are lots of new Solution Explorer features in Visual Studio 2012, so many that they did not all fit into one blog post. The following are posts that outline the new features:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/08/solution-explorer-sync-ing-in-visual-studio-2012.aspx"&gt;Solution Explorer Sync&amp;#39;ing in Visual Studio 2012&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/03/visual-studio-2012-did-you-call-me.aspx"&gt;Visual Studio 2012: Did You Call Me?&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/03/solution-explorer-scoping-in-visual-studio-2012.aspx"&gt;Solution Explorer Scoping in Visual Studio 2012&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/02/solution-explorer-filtering-in-visual-studio-2012.aspx"&gt;Solution Explorer Filtering in Visual Studio 2012&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/01/preventing-tab-bloat-with-visual-studio-2012.aspx"&gt;Preventing Tab Bloat with Visual Studio 2012&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/b/mvpawardprogram/archive/2012/09/05/working-with-multiple-solution-explorer-windows-in-visual-studio-2012.aspx"&gt;Working with Multiple Solution Explorer Windows in Visual Studio 2012&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1816080" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category></item><item><title>Solution Explorer Sync'ing in Visual Studio 2012</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/08/solution-explorer-sync-ing-in-visual-studio-2012.aspx</link><pubDate>Sun, 09 Sep 2012 02:08:10 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1816015</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1816015</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/08/solution-explorer-sync-ing-in-visual-studio-2012.aspx#comments</comments><description>&lt;p&gt;This is just a little feature, but a very useful one: Solution Explorer now allows &lt;strong&gt;you&lt;/strong&gt; to control the sync to the currently active tab.&lt;/p&gt;  &lt;p&gt;In prior versions of Visual Studio, Solution Explorer automatically synchronized its position to the active tab. When you clicked on a tab, Solution Explorer positioned itself to that file.&lt;/p&gt;  &lt;p&gt;This was frustrating when you were working on files in a particular component. You click on another tab to look at something and Solution Explorer automatically jumped to that file. It was possible to turn off this behavior using Tools | Options, but then you could never find where you were in Solution Explorer.&lt;/p&gt;  &lt;p&gt;In Visual Studio 2012, Solution Explorer allows you to define when it should synchronize to the current tab. Here is how it works:&lt;/p&gt;  &lt;p&gt;First, open one code file from one of your components and another code file from another component. The results will look something like the figure below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7167.image_5F00_08DC34FA.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6445.image_5F00_thumb_5F00_7F9FF9B8.png" width="470" height="505" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In the above example, the Customers.cs and the CustomerWin.cs files are opened. Solution Explorer has the CustomerWin.cs highlighted.&lt;/p&gt;  &lt;p&gt;Click on the other tab, Customers.cs in this example. Notice that Solution Explorer does not automatically sync up to the selected tab.&lt;/p&gt;  &lt;p&gt;If you do want Solution Explorer to sync up at any time, click the Sync button in the Solution Explorer toolbar.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2768.image_5F00_3E25475F.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5270.image_5F00_thumb_5F00_7114D7C6.png" width="470" height="506" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;[The red box around the sync button was added for illustration.]&lt;/p&gt;  &lt;p&gt;If you want the old behavior, where Solution Explorer tracks with the active tab, you can use Tools | Options:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5722.image_5F00_6F640BF2.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7725.image_5F00_thumb_5F00_0CF5E6F2.png" width="474" height="290" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;[The red box around the sync button was added for illustration.]&lt;/p&gt;  &lt;p&gt;Use the new Sync button any time you want to sync Solution Explorer to the active tab.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1816015" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category></item><item><title>Visual Studio 2012: Did You Call Me?</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/03/visual-studio-2012-did-you-call-me.aspx</link><pubDate>Tue, 04 Sep 2012 01:42:05 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1815813</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1815813</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/03/visual-studio-2012-did-you-call-me.aspx#comments</comments><description>&lt;p&gt;As you debug and refactor your application, you often want to know who called whom. Visual Studio has always provided features to help you with that, but Visual Studio 2012 provides more.&lt;/p&gt;  &lt;p&gt;With the following, you can determine which properties and methods called which properties and methods:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Solution Explorer features (new in VS 2012)&lt;/li&gt;    &lt;li&gt;Call Stack&lt;/li&gt;    &lt;li&gt;Call Hierarchy (new in VS 2010 for C#; VS 2012 for VB)&lt;/li&gt;    &lt;li&gt;Find all References&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Solution Explorer&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The new Solution Explorer in Visual Studio 2012 allows you to drill down from a code file to the classes, properties, and methods within that code file. From a property or method, you can view all of the properties or methods it calls. Or you can view all of the properties and methods that call it. Or you can view each line of code that uses it.&lt;/p&gt;  &lt;p&gt;In Solution Explorer, drill down from a project to a class to a property or method. Right-click on the property or method to view the context menu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2043.image_5F00_623AA390.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1307.image_5F00_thumb_5F00_6C8BC7F0.png" width="422" height="454" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Select the Calls option to see all of the properties and methods that the selected property or method calls. For example, the FindCustomers method calls the following properties and methods:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8475.image_5F00_12817847.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8103.image_5F00_thumb_5F00_54C46ABD.png" width="427" height="152" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Select Is Called By to see all of the properties and methods that call the selected property or method. For example, the FindCustomers method is called by the following methods:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3162.image_5F00_25927F26.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5228.image_5F00_thumb_5F00_52A76BF4.png" width="433" height="233" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Select Is Used By to see each line of code that uses the the selected property or method. For example, the FindCustomers method is called by the following lines of code.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1537.image_5F00_18B82908.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8726.image_5F00_thumb_5F00_5815DC98.png" width="433" height="218" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In all of these scenarios, you can click on a result to view it in the Preview Tab or double-click on a result to view it in a normal tab.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Call Stack&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The Call Stack (Debug | Windows&amp;#160; | )&amp;#160; is only available when debugging. From it, you can see all of the calls that led to the break point. Double-click on an entry in the Call Stack to jump to that location in the code.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7840.image_5F00_626700F8.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0743.image_5F00_thumb_5F00_4FB20741.png" width="435" height="132" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Call Hierarchy&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The Call Hierarchy (View | Call Hierarchy) is only available when debugging. Right-click on a property or method name in the code window when on a break point and select View Call Hierarchy.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5732.image_5F00_7CC6F40F.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7635.image_5F00_thumb_5F00_07181870.png" width="445" height="252" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The left pane displays the &amp;quot;calls&amp;#160; to&amp;quot; and the &amp;quot;calls from&amp;quot; the selected property or method. Clicking on one of the properties or methods displays the associated line(s) of code.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Find All References&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This one has been around for a while, so I probably don&amp;#39;t need to provide any instructions. Just right-click on any property or method in a code file and select Find All References from the context menu.&lt;/p&gt;  &lt;p&gt;Use these techniques any time you need to navigate the call stack.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1815813" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category></item><item><title>Solution Explorer Scoping in Visual Studio 2012</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/03/solution-explorer-scoping-in-visual-studio-2012.aspx</link><pubDate>Mon, 03 Sep 2012 17:23:46 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1815800</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1815800</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/03/solution-explorer-scoping-in-visual-studio-2012.aspx#comments</comments><description>&lt;p&gt;In prior versions of Visual Studio, the Solution Explorer has been basically static. With Visual Studio 2012, it is much more dynamic with features such as filtering and scoping.&lt;/p&gt;  &lt;p&gt;[For information on the filtering features, see &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/02/solution-explorer-filtering-in-visual-studio-2012.aspx"&gt;this prior blog post&lt;/a&gt;.]&lt;/p&gt;  &lt;p&gt;The scoping feature allows you to limit the display of Solution Explorer to one specific folder, project, code file, or class. This allows you to more easily find the code you want to work with during a particular coding session.&lt;/p&gt;  &lt;p&gt;For example, if you are building an MVVM application you could scope Solution Explorer on one monitor to your Views folder and Solution Explorer on another monitor to your ViewModels folder. [For more information on displaying Solution Explorer on a second monitor see this upcoming post.]&lt;/p&gt;  &lt;p&gt;To scope Solution Explorer to a folder, right-click on the folder and select &amp;quot;Scope To This&amp;quot; from the context menu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5355.image_5F00_0752FBE2.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7838.image_5F00_thumb_5F00_3F9172FA.png" width="386" height="276" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To return to the full list of folders and files, click the Home button in Solution Explorer&amp;#39;s toolbar.&lt;/p&gt;  &lt;p&gt;Scoping to a class provides a quick way to access any property or method&amp;#160; in the class. Right-click on a class in Solution Explorer and select &amp;quot;Scope to This&amp;quot; from the context menu.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7041.image_5F00_338F82C6.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8461.image_5F00_thumb_5F00_6BCDF9DE.png" width="387" height="269" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Use the scoping features of Solution Explorer any time you want to focus on a specific folder, code file, or class during your coding session.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1815800" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category></item><item><title>Solution Explorer Filtering in Visual Studio 2012</title><link>http://msmvps.com/blogs/deborahk/archive/2012/09/02/solution-explorer-filtering-in-visual-studio-2012.aspx</link><pubDate>Mon, 03 Sep 2012 01:39:24 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1815772</guid><dc:creator>Deborah Kurata</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/deborahk/rsscomments.aspx?PostID=1815772</wfw:commentRss><comments>http://msmvps.com/blogs/deborahk/archive/2012/09/02/solution-explorer-filtering-in-visual-studio-2012.aspx#comments</comments><description>&lt;p&gt;In prior versions of Visual Studio, the Solution Explorer has been basically static. With Visual Studio 2012, it is much more dynamic with features such as filtering and scoping.&lt;/p&gt;  &lt;p&gt;[For information on the scoping features, see &lt;a href="http://msmvps.com/blogs/deborahk/archive/2012/09/03/solution-explorer-scoping-in-visual-studio-2012.aspx"&gt;this prior blog post&lt;/a&gt;.]&lt;/p&gt;  &lt;p&gt;The filtering feature allows you to filter the contents of Solution Explorer to files containing the entered text. Depending on your settings, it will find within the file name and within the contents of any code file.&lt;/p&gt;  &lt;p&gt;This allows you to focus on specific files or files containing specific classes, properties, or methods. For example, if you are working on an MVVM application, you can filter to &amp;quot;Invoice&amp;quot; to find the model, view, and view/model for the invoice feature.&lt;/p&gt;  &lt;p&gt;The filtering uses a &amp;quot;contains&amp;quot; style of matching, so it finds the match anywhere in the file name or in the code file classes, properties, and methods. It can also match using Pascal casing. Typing CFW will match any Pascal-cased string with the entered letters, such as CustomerFindWindow.&lt;/p&gt;  &lt;p&gt;Searching for &amp;quot;Customer&amp;quot;:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2451.image_5F00_378CB7B1.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1715.image_5F00_thumb_5F00_085ACC1A.png" width="441" height="505" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In this example, &amp;quot;Customer&amp;quot; is found in both the file names, such as Customer.cs, and in the contents of the code files, such as the Customer class, the CustomerList property, and the FindCustomers method.&lt;/p&gt;  &lt;p&gt;To limit the search to only the file names, turn off the &amp;quot;Search within file contents&amp;quot; by unchecking it in the search options.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0825.image_5F00_006329B8.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/8182.image_5F00_thumb_5F00_46E019C0.png" width="436" height="207" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;You can also uncheck &amp;quot;Search within external items&amp;quot;, which turns off searching of external items, such as those in the External Dependencies folders. (I spent some time this afternoon trying to determine what this actually means and did not have a lot of luck. Best I can find, it prevents searching within the C/C++ External Dependencies folder. If anyone has found any more information on this, I&amp;#39;d love to hear about it.&amp;#160; Please post in the Comments section of this post.)&lt;/p&gt;  &lt;p&gt;Turning off &amp;quot;Search within file contents&amp;quot; provides these results:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2335.image_5F00_1F399D96.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2766.image_5F00_thumb_5F00_5A8D0354.png" width="449" height="404" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Searching for CFW results in:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0647.image_5F00_44C31AF7.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2703.image_5F00_thumb_5F00_6B24FE42.png" width="454" height="413" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In this example, any file names, classes, properties, or methods that are Pascal cased to match CFW are included in the filtered list.&lt;/p&gt;  &lt;p&gt;Notice, however, the difference between the C# project and the VB project in the above example. This difference is because the filtering does not search through hidden folders/files by default. In VB, the designer file is hidden.&lt;/p&gt;  &lt;p&gt;To search through hidden files and folders, select the project and then click the Show All Files button in the Solution Explorer toolbar. Then the VB designer file will be found.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3632.image_5F00_3135BB56.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4645.image_5F00_thumb_5F00_09230C37.png" width="454" height="478" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;To turn off the results and return to the full list of files, click the Home button on the Solution Explorer toolbar. Solution Explorer is then reset to its original file list.&lt;/p&gt;  &lt;p&gt;Use these techniques any time you want to filter Solution Explorer to specific folders, files, classes, methods, or properties in your solution. &lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1815772" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/deborahk/archive/tags/VB/default.aspx">VB</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/Visual+Studio/default.aspx">Visual Studio</category><category domain="http://msmvps.com/blogs/deborahk/archive/tags/CSharp/default.aspx">CSharp</category></item></channel></rss>