<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CEQHQX09fCp7ImA9WhFTGUU.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312</id><updated>2013-06-11T13:25:30.364-07:00</updated><category term="Resharper" /><category term="ArcGIS Server" /><category term="Continuous Integration" /><category term="MVVM" /><category term="SQL Server 2008" /><category term="SQL" /><category term="Unit Test" /><category term="Academic" /><category term="Troubleshooting" /><category term="Beginners" /><category term="Oracle" /><category term="ESRI Silverlight API" /><category term="ASP.NET MVC" /><category term="Web" /><category term="ESRI" /><category term="VS2008" /><category term="PowerShell" /><category term="Exception" /><category term="General" /><category term="Bugs" /><category term="Event Viewer" /><category term="ArcObjects" /><category term="VS2010" /><category term="Error" /><category term="Expert" /><category term="FluentMigrator" /><category term="Game Programming" /><category term="JavaScript" /><category term="SDE" /><category term="Blog" /><category term="Silverlight" /><title>Dll Shepherd.Net</title><subtitle type="html">Blogs, C#, Unit Test, ESRI, ...</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.dllshepherd.net/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://www.dllshepherd.net/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>75</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/dllshepherdDomain" /><feedburner:info uri="dllshepherddomain" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>dllshepherdDomain</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;CEQHQX09cCp7ImA9WhFTGUU.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-4383047268356637243</id><published>2013-06-11T13:19:00.001-07:00</published><updated>2013-06-11T13:25:30.368-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-06-11T13:25:30.368-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="General" /><title>Leaving a Better Place</title><content type="html">&lt;p&gt;I never actually wrote it in this blog but for the last 3 years I have been a Better Place employee (I have actually had an image of an &lt;a href="http://www.dllshepherd.net/2011/10/special-achievement-in-gis-sag-2011.html" target="_blank"&gt;award we received back in 2011&lt;/a&gt; with the words Better Place but never actually wrote them as text).&lt;/p&gt; &lt;p&gt;It’s actually been a great 3 years where I met some amazing people and learned great technologies. When I joined the team our system – GTM (Grid Topology Management) was just starting up – basically the only action available was creating Sites (in Better Place the Site entity was the main entity – it could either mean a charging Site or a Battery Switch Site (BSS)). The server side at that time had a single WCF file with all the code (logical and DB access, and with using ArcObjects meant quite a bit of code).&lt;/p&gt; &lt;p&gt;It didn’t take me (too) long to change all that so the server side (which is more my specialty) now has a separation between the service layer, the BL (Business Logic) and the DAL (Data Access Layer). The BL is fully tested using NUnit (for a time it was VSTests). The Silverlight UI had so many upgrades like:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Google Street View from the Silverlight Application  &lt;li&gt;Editing the Electric Topology (adding a Panels, Circuits, Spots ,Sockets and sometimes even communication elements since Better Place’s Grid could be remotely controlled – and in Denmark end users could set when their Electric usage was at a peak so that the Electric Vehicle will get less).  &lt;li&gt;Electric Topology validation – so that before installation all the planned hardware elements could be verified to be correct  &lt;li&gt;Routing – going from point A to B when you have to look out for your battery or switch it is not something Waze implemented (though wouldn’t it be cool if you just entered your remaining KMs until you have to fill your tank or switch your battery and have Waze do it automatically – with your preferred Gas Station (or BSS))  &lt;li&gt;Traffic Reports – basically like it is implemented in Google Maps (only we used a paid service &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The server side had many integration services build as well like making an order from SAP, communicating to the Electric Vehicle what Sites are down (maintenance or some kind of technical problem) and much more.&lt;/p&gt; &lt;p&gt;Along the way I somehow got some free software like &lt;a href="http://www.dllshepherd.net/2011/01/to-resharper-or-not-to-resharper.html" target="_blank"&gt;Resharper, dotTrace&lt;/a&gt; (maybe I should be a QA?) and NDepend. &lt;/p&gt; &lt;p&gt;My last year at Better Place was dedicated to lowering operation costs and improving the system. One of those improvements was moving from SQL Server to Oracle, which considering we were using Linq2Sql meant moving to another Framework. For a time our team used Entity Framework and another team at the department used NHibernate, than for solidarity reasons we moved to NHibernate (I might write a blog post on that because: A. we had to use Timestamp and NHibernate “supports” it by using DateTime – not DateTimeOffset. B. for some odd reason NHibernate kept adding semi random numbers to column names’ aliases and with Oracle’s query optimizations that caused problems unless we used projections). The mapping for our NHibernate usage was done using &lt;a href="http://www.fluentnhibernate.org/" target="_blank"&gt;Fluent NHibernate&lt;/a&gt; (for some odd reason I never liked writing xml where I could use plain code, is it just me?).&lt;/p&gt; &lt;p&gt;Through the downsizing and people leaving us I was put in charge of the in car computer called Oscar, unfortunately I only had enough time too learn it’s systems – not make any changes. I did find many bugs in the Media Player system (I even wrote an unofficial guide about how to operate it with the least amount of problems, like did you know playing all the songs on your DOK will be changed the next time you start your car to playing only the last artist’s songs?).&lt;/p&gt; &lt;p&gt;In the last 3 months we also had a MVC+jQuery course and had started to implement the new Self Service site (you can see it’s design &lt;a href="http://designit.com/cases/selling-something-new" target="_blank"&gt;here&lt;/a&gt;) when as the papers say “the battery has run out”… &lt;/p&gt; &lt;p&gt;Today I had to return my Electric Vehicle, yesterday I switched the battery for the last time with this vehicle (if the service continues I might just get another one sometime in the future, I really never had such good performance from any other car).&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;So after this long but partial summary of the last 3 years it is time to say I have started looking for the next Better Place. If you are looking for a Software Engineer (even if it’s not map related) then you are welcome to email me with the details. My email is written on the right.&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=7ZQ8ClABwm4:uxgyj-MAsNI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/7ZQ8ClABwm4" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/4383047268356637243?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/4383047268356637243?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/7ZQ8ClABwm4/leaving-better-place.html" title="Leaving a Better Place" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><feedburner:origLink>http://www.dllshepherd.net/2013/06/leaving-better-place.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8HQHY7cCp7ImA9WhBWFE8.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-5002176302219908328</id><published>2013-04-08T05:07:00.001-07:00</published><updated>2013-04-08T05:07:11.808-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-08T05:07:11.808-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Error" /><category scheme="http://www.blogger.com/atom/ns#" term="Oracle" /><title>ORA-03149: Invalid Oracle error code</title><content type="html">&lt;p&gt;Just got this error.&lt;/p&gt; &lt;p&gt;The only &lt;a href="http://ora-03149.db.quanti.cz/" target="_blank"&gt;thing&lt;/a&gt; I saw on the web on this was: &lt;em&gt;“This is an internal protocol error. Contact Oracle Support Services.”&lt;/em&gt;&lt;/p&gt; &lt;p&gt;As I see it, it means Oracle doesn’t know what I did wrong.&lt;/p&gt; &lt;p&gt;At the end we found out that the error was caused by entering a value of 1.7976931348623157E308 to a NUMBER(38, 8) field. The person that sent me this value meant to send NaN but at the end sent Double.MaxValue. &lt;/p&gt; &lt;p&gt;I am sure this is just one symptom of the problem but maybe it will help someone out there… &lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=wtOQVL6ChfE:tXrV8gG5q80:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/wtOQVL6ChfE" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/5002176302219908328?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/5002176302219908328?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/wtOQVL6ChfE/ora-03149-invalid-oracle-error-code.html" title="ORA-03149: Invalid Oracle error code" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><feedburner:origLink>http://www.dllshepherd.net/2013/04/ora-03149-invalid-oracle-error-code.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0IERns5cCp7ImA9WhBXE0U.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-6186461965365235603</id><published>2013-03-27T04:58:00.001-07:00</published><updated>2013-03-27T04:58:27.528-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-27T04:58:27.528-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SDE" /><category scheme="http://www.blogger.com/atom/ns#" term="ESRI" /><title>SDE: Using SQL to copy feature rows</title><content type="html">&lt;p&gt;(Or to Bulk Insert features to a feature table)&lt;/p&gt; &lt;p&gt;This only works if you are using Oracle/MS SQL geometry types (where the shape field is not an integer but an actual shape).&lt;/p&gt; &lt;p&gt;I always thought that for copying more than one row of feature data I will need to use ArcCatalog, for one row I usually hard coded the OBJECTID field and hoped that the next person using ArcCatalog won’t hate my guts…&lt;/p&gt; &lt;p&gt;Well last week I needed to duplicate rows in a feature table and found this &lt;a href="http://support.esri.com/es/knowledgebase/techarticles/detail/32657" target="_blank"&gt;link&lt;/a&gt;, and even though it says ArcSDE 9.3.1 as the latest version it works on version 10.&lt;/p&gt; &lt;p&gt;Use:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3dc8612a-f0ba-4df0-b804-dd0c82ddb29a" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;SELECT&lt;/span&gt; &lt;span style="color:#008080"&gt;table_name&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;registration_id&lt;/span&gt; &lt;span style="color:#0000ff"&gt;FROM&lt;/span&gt; &lt;span style="color:#008080"&gt;sde&lt;/span&gt;&lt;span style="color:#808080"&gt;.&lt;/span&gt;&lt;span style="color:#008080"&gt;table_registry&lt;/span&gt; &lt;span style="color:#0000ff"&gt;WHERE&lt;/span&gt; &lt;span style="color:#0000ff"&gt;owner&lt;/span&gt; &lt;span style="color:#808080"&gt;=&lt;/span&gt; &lt;span style="color:#ff0000"&gt;&amp;#39;OWNER&amp;#39;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;To find the registration number of the feature table, for example 21.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;To find the next available ObjectId:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7606743b-94f9-4ee5-bf2d-63ec2abda9de" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#008080"&gt;sde&lt;/span&gt;&lt;span style="color:#808080"&gt;.&lt;/span&gt;&lt;span style="color:#008080"&gt;version_user_ddl&lt;/span&gt;&lt;span style="color:#808080"&gt;.&lt;/span&gt;&lt;span style="color:#008080"&gt;next_row_id&lt;/span&gt;&lt;span style="color:#808080"&gt;(&lt;/span&gt;&lt;span style="color:#ff0000"&gt;&amp;#39;OWNER&amp;#39;&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; 21&lt;span style="color:#808080"&gt;)&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;To copy the rows of Table_Name (for example: from type 1 to type 2):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7d8eecd6-bfba-43a3-aab0-670a40c1b492" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;insert&lt;/span&gt; &lt;span style="color:#0000ff"&gt;into&lt;/span&gt; &lt;span style="color:#008080"&gt;Table_Name&lt;/span&gt;&lt;span style="color:#808080"&gt;(&lt;/span&gt;&lt;span style="color:#008080"&gt;objectid&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#008080"&gt;shape&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; &lt;span style="color:#0000ff"&gt;Type&lt;/span&gt;&lt;span style="color:#808080"&gt;)&lt;/span&gt; &lt;span style="color:#0000ff"&gt;select&lt;/span&gt; &lt;span style="color:#008080"&gt;sde&lt;/span&gt;&lt;span style="color:#808080"&gt;.&lt;/span&gt;&lt;span style="color:#008080"&gt;version_user_ddl&lt;/span&gt;&lt;span style="color:#808080"&gt;.&lt;/span&gt;&lt;span style="color:#008080"&gt;next_row_id&lt;/span&gt;&lt;span style="color:#808080"&gt;(&lt;/span&gt;&lt;span style="color:#ff0000"&gt;&amp;#39;OWNER&amp;#39;&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; 21&lt;span style="color:#808080"&gt;),&lt;/span&gt; &lt;span style="color:#008080"&gt;shape&lt;/span&gt;&lt;span style="color:#808080"&gt;,&lt;/span&gt; 2  &lt;span style="color:#0000ff"&gt;from&lt;/span&gt; &lt;span style="color:#008080"&gt;Table_Name&lt;/span&gt; &lt;span style="color:#008080"&gt;t&lt;/span&gt; &lt;span style="color:#0000ff"&gt;where&lt;/span&gt; &lt;span style="color:#0000ff"&gt;Type&lt;/span&gt; &lt;span style="color:#808080"&gt;=&lt;/span&gt; 1&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;And that's it.&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=K7RMAuSPqFg:jB7tJXdtm58:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/K7RMAuSPqFg" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6186461965365235603?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6186461965365235603?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/K7RMAuSPqFg/sde-using-sql-to-copy-feature-rows.html" title="SDE: Using SQL to copy feature rows" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><feedburner:origLink>http://www.dllshepherd.net/2013/03/sde-using-sql-to-copy-feature-rows.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMHQXg4cCp7ImA9WhBRE0Q.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-6075049653611576895</id><published>2013-03-04T02:32:00.001-08:00</published><updated>2013-03-04T02:37:10.638-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-04T02:37:10.638-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Web" /><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript" /><title>HTML5+MVC Course, Day 3</title><content type="html">&lt;p&gt;Continued from &lt;a href="http://www.dllshepherd.net/2013/02/html5mvc-course-day-1.html" target="_blank"&gt;day 1&lt;/a&gt;, &lt;a href="http://www.dllshepherd.net/2013/02/html5mvc-course-day-2.html" target="_blank"&gt;day 2&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;This lesson was more a review of the last lesson with the added value of looking at profiling tools. In the summary I just skipped the review part…&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;After opening a new MVC project from a template looking at the libraries installed you will find that they are old libraries. You can update them if you wish using NuGet –&amp;gt; Update:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-emxeunwNVE0/UTR3zkrWKiI/AAAAAAAACMo/JAnyv_fJzhg/s1600-h/NuGetUpdates%25255B7%25255D.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="NuGetUpdates" border="0" alt="NuGetUpdates" src="http://lh6.ggpht.com/--mM_z4Sbwug/UTR30pFrBHI/AAAAAAAACMw/jWIgcvAI3lc/NuGetUpdates_thumb%25255B4%25255D.png?imgmax=800" width="631" height="378"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;NuGet knows which libraries it needs to update by looking at the packages.config file that describes the installed packages and their versions. For example:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d198c6b0-ce52-4eaa-a876-0ec8b9931bac" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;xml&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;version&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;1.0&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;encoding&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;utf-8&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;?&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;packages&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;   &lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;package&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;EntityFramework&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;version&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;5.0.0&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;targetFramework&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;net45&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;br&gt;   &lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;package&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;jQuery&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;version&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;1.7.1.1&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;targetFramework&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;net45&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;br&gt;   &lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;package&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;jQuery.UI.Combined&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;version&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;1.8.20.1&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;targetFramework&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;net45&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h3&gt;Web Programming must have:&lt;/h3&gt; &lt;ol&gt; &lt;li&gt;Browser Sniffer with a capability to see the HTML – Chrome F12  &lt;li&gt;Client side Sniffer that displays the data as it passes (optional: with JSON parser, with debugging, comparison) – Fiddler  &lt;li&gt;Server side: DB profiler for queries to the DB – SQL Server Profiler&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h3&gt;Fiddler&lt;/h3&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-KWrVu4wKABE/UTR31gtUAhI/AAAAAAAACM4/YuBZ-Etx6IY/s1600-h/FiddlerOverview%25255B7%25255D.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="FiddlerOverview" border="0" alt="FiddlerOverview" src="http://lh3.ggpht.com/-YBR5sCsRcfQ/UTR327obrJI/AAAAAAAACNA/gc6ewMlAnzA/FiddlerOverview_thumb%25255B4%25255D.png?imgmax=800" width="716" height="478"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Clicking on the “Capturing” in the bottom left corner (pink arrow) will stop and start the capturing.&lt;/p&gt; &lt;p&gt;Clicking on the X (orange arrow) will give you in it’s first option: Remove all. Clears the screen.&lt;/p&gt; &lt;p&gt;HTTP Results: &lt;/p&gt; &lt;ul&gt; &lt;li&gt;HTTP 100-199 are for information  &lt;li&gt;HTTP 200-299 are for successful result, for example: 200 is for success (green arrow)  &lt;li&gt;HTTP 300-399 are for redirect, for example: 304 (blue arrow) indicates the result is in browser’s cache  &lt;li&gt;HTTP 400-499 are for client errors, for example: 404 page not found  &lt;li&gt;HTTP 500-599 are for server errors, for example: 503 server unavailable&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;On the top-right side of the screen Inspectors-&amp;gt;raw we can see the request with it’s http headers&lt;/p&gt; &lt;p&gt;On the bottom-right side of the screen: raw if the message is encoded you will see gibberish (and the Content-Encoding will be gzip):&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;HTTP/1.1 200 OK&lt;br&gt;…&lt;br&gt;&lt;strong&gt;Content-Encoding: gzip&lt;/strong&gt;&lt;br&gt;…&lt;br&gt;Content-Length: 44892&lt;/p&gt; &lt;p&gt;��������`I�%&amp;amp;/m�{J�J��t��`$ؐ@������iG#)�*��eVe]f@�흼��{���{���;�N'���?\fdl��J�ɞ!���?~|?"��O�&amp;lt;y���&amp;lt;M��&amp;lt;���������ⳏ��&lt;/p&gt; &lt;p&gt;*** FIDDLER: RawDisplay truncated at 128 characters. Right-click to disable truncation. ***&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Then:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-hwFt7hzFYOY/UTR334WB9UI/AAAAAAAACNI/EuRK7isWrMM/s1600-h/FiddlerBinary%25255B7%25255D.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="FiddlerBinary" border="0" alt="FiddlerBinary" src="http://lh6.ggpht.com/-6FYHgfgQIVk/UTR34rkDBRI/AAAAAAAACNQ/vMN_pbWlcqQ/FiddlerBinary_thumb%25255B4%25255D.png?imgmax=800" width="616" height="422"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Click on “Response is encoded and may need to be decoded before inspection. Click here to transform” (blue arrow). Or do it by hand by going to the Transformer tab and select “No Compression” in HTTP Compression.&lt;/p&gt; &lt;h4&gt;Ajax+JSON Calls:&lt;/h4&gt; &lt;p&gt;You can identify Ajax calls by:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-APGRfSCHq58/UTR35Wc5MZI/AAAAAAAACNY/XEPAdISFcRk/s1600-h/FiddlerAjaxJson%25255B7%25255D.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="FiddlerAjaxJson" border="0" alt="FiddlerAjaxJson" src="http://lh3.ggpht.com/-yCcdli0FWsQ/UTR36ZdVudI/AAAAAAAACNg/CSQKVry8058/FiddlerAjaxJson_thumb%25255B4%25255D.png?imgmax=800" width="444" height="393"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Ajax calls will have: X-Requested-With: XMLHttpRequest (blue arrow).&lt;/p&gt; &lt;p&gt;JSON calls will have: Accept: application/json (green arrow), we can also see that the response has the Content-Type we requested application/json (bottom row).&lt;/p&gt; &lt;p&gt;The JSON response can be read several ways:&lt;/p&gt; &lt;h5&gt;1. Text/Raw view:&lt;/h5&gt; &lt;blockquote&gt; &lt;p&gt;[{"value":"ALFKI","label":"Alfreds Futterkiste"},{"value":"ANATR","label":"Ana Trujillo Emparedados y helados"},{"value":"ANTON","label":"Antonio Moreno Taquería"},{"value":"AROUT","label":"Around the Horn"}]&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Raw will also show the headers. &lt;/p&gt; &lt;h5&gt;2. JSON view:&lt;/h5&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-JQ4cu0iD9FI/UTR37LsLhrI/AAAAAAAACNk/MYbZ4pzHzVo/s1600-h/FiddlerResponseJsonView%25255B6%25255D.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="FiddlerResponseJsonView" border="0" alt="FiddlerResponseJsonView" src="http://lh6.ggpht.com/-c-tFqH2qoSw/UTR37zGChJI/AAAAAAAACNw/Ou6K3J2uNLo/FiddlerResponseJsonView_thumb%25255B3%25255D.png?imgmax=800" width="527" height="298"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Views the JSON as a data structure – more readable.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h3&gt;Chrome F12 Profiler&lt;/h3&gt; &lt;h4&gt;Console&lt;/h4&gt; &lt;p&gt;From the Console you can run jQuery queries like you can run code in the Immediate of VS:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-P7G764TiVbA/UTR38mr39-I/AAAAAAAACN4/ucWJmrgDCSA/s1600-h/ChromeF12Console%25255B6%25255D.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="ChromeF12Console" border="0" alt="ChromeF12Console" src="http://lh6.ggpht.com/-HIdxcgESfis/UTR39hSzMpI/AAAAAAAACOA/M7HL2xvuMRA/ChromeF12Console_thumb%25255B3%25255D.png?imgmax=800" width="635" height="117"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Console will also show JavaScript errors:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-VzIqvWbqjjw/UTR3-JdKWII/AAAAAAAACOI/7oaZTQPR1VA/s1600-h/ChromeF12ConsoleException%25255B11%25255D.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="ChromeF12ConsoleException" border="0" alt="ChromeF12ConsoleException" src="http://lh5.ggpht.com/-KSHU_sey3NU/UTR3-4OVXcI/AAAAAAAACOQ/WQ65EvdT2-o/ChromeF12ConsoleException_thumb%25255B8%25255D.png?imgmax=800" width="518" height="160"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;We will know there is an error by the error icon at the bottom-right corner (red arrow).&lt;/p&gt; &lt;p&gt;We will get the exception details like: from where it was thrown and the description at the center (orange arrow).&lt;/p&gt; &lt;p&gt;And most importantly we will get a link to the actual location in the code the error was thrown from (blue arrow), clicking on it will lead us to _ window:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-_sOVWzyuI84/UTR3_61h93I/AAAAAAAACOY/k0JcPH_cI2k/s1600-h/ChromeSourcesDebugException%25255B8%25255D.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="ChromeSourcesDebugException" border="0" alt="ChromeSourcesDebugException" src="http://lh5.ggpht.com/-Fp6M7KfGb7k/UTR4A4x5AnI/AAAAAAAACOc/jGHFJY8lBzk/ChromeSourcesDebugException_thumb%25255B5%25255D.png?imgmax=800" width="686" height="203"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;As you can see the error icon appears on all screens (red arrow).&lt;/p&gt; &lt;p&gt;You can see the location of the error (yellow arrow).&lt;/p&gt; &lt;p&gt;And you can watch the local variables at the right side (blue arrow).&lt;/p&gt; &lt;p&gt;You can also add more functionality with extensions (for example &lt;a href="https://chrome.google.com/webstore/detail/pagespeed-insights-by-goo/gplegfbjlmmehdoakndmohflojccocli?hl=en" target="_blank"&gt;PageSpeed&lt;/a&gt;).&lt;/p&gt; &lt;h4&gt;Timeline&lt;/h4&gt; &lt;p&gt;very important!&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-ldNtBWWGpMI/UTR4BhlWoMI/AAAAAAAACOk/NssKqbK9PmE/s1600-h/ChromeF12Timeline%25255B12%25255D.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="ChromeF12Timeline" border="0" alt="ChromeF12Timeline" src="http://lh5.ggpht.com/-UzX6qK95etM/UTR4CteGijI/AAAAAAAACOs/3DBMRh8UCeE/ChromeF12Timeline_thumb%25255B9%25255D.png?imgmax=800" width="735" height="244"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;At the bottom there is a button for starting the profiler (red arrow).&lt;/p&gt; &lt;p&gt;At the top you can select the timeframe, my browser default for some unknown reason was the first 1 second – so the default is not seeing anything (use the lines at the blue arrows to adjust the time frame).&lt;/p&gt; &lt;h4&gt;Profiles: Memory leak checker&lt;/h4&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-I_tRXbW67qI/UTR4DlwUjCI/AAAAAAAACO4/4OS4nD1BjbI/s1600-h/ChromeF12ProfileTakeSnapshot%25255B10%25255D.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="ChromeF12ProfileTakeSnapshot" border="0" alt="ChromeF12ProfileTakeSnapshot" src="http://lh5.ggpht.com/-WJeD1o4Sj8o/UTR4EbxH8TI/AAAAAAAACPA/bOpCP04ALpI/ChromeF12ProfileTakeSnapshot_thumb%25255B7%25255D.png?imgmax=800" width="574" height="220"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Take heap snapshot at the start and you get the current memory profile:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-81oNb8G6zCI/UTR4FNsvrBI/AAAAAAAACPI/v1ZnIHRHVXE/s1600-h/ChromeF12ProfilesSnap1%25255B8%25255D.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="ChromeF12ProfilesSnap1" border="0" alt="ChromeF12ProfilesSnap1" src="http://lh3.ggpht.com/-GmjYGdr7pG0/UTR4GL5qMkI/AAAAAAAACPQ/0-v5epALgNA/ChromeF12ProfilesSnap1_thumb%25255B5%25255D.png?imgmax=800" width="644" height="252"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;As with most memory profiling tools you can sort (blue arrow) by object count, shallow size (the size of the element by itself), retained size (the size of the element including links to other classes). You can read more on the size differences &lt;a href="https://developers.google.com/chrome-developer-tools/docs/memory-analysis-101#object_sizes" target="_blank"&gt;here&lt;/a&gt;, but we will use retained size.&lt;/p&gt; &lt;p&gt;You can also drill down to the actual function/line that takes the memory (green arrow).&lt;/p&gt; &lt;p&gt;Take another snapshot and you can compare snapshots:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-oxnXhMEhTxw/UTR4G8pnxAI/AAAAAAAACPY/y2MJq3zt0Ac/s1600-h/ChromeF12ProfilesCompare%25255B8%25255D.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="ChromeF12ProfilesCompare" border="0" alt="ChromeF12ProfilesCompare" src="http://lh5.ggpht.com/-y2pXQAHMXCw/UTR4H84NqXI/AAAAAAAACPg/y0o25H9Lv70/ChromeF12ProfilesCompare_thumb%25255B5%25255D.png?imgmax=800" width="664" height="240"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;At the bottom change from Summery to Comparison (blue arrow) and all the view changes to a delta between the runs.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;u&gt;Note:&lt;/u&gt; IE has it’s own profiler but it seems to be for running time and not for memory leaks.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;Entity vs. Class&lt;/h4&gt; &lt;p&gt;Entity has to have a unique identifier – Key.&lt;/p&gt; &lt;p&gt;Data/Class is without an identifier, JSON uses data not entities (only Silverlight has entities in the client)&lt;/p&gt; &lt;p&gt;If we were to return an Entity with JSON:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:dde734d0-38b2-4c72-8e5c-771769a0d3fd" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonResult&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; GetCustomersCircularError(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; term)&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; results = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;from&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;in&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; db.Customers&lt;/span&gt;&lt;br&gt;                   &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;where&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c.CompanyName.StartsWith(term)&lt;/span&gt;&lt;br&gt;                   &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;select&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c;&lt;/span&gt;&lt;br&gt; &lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Json(results.ToList(), &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonRequestBehavior&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.AllowGet);&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The parser might fail with a circular reference exception:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-Bs2JQ1y9S10/UTR4Ige3xgI/AAAAAAAACPo/X2oiomnUVVc/s1600-h/JsonCircularReferenceError%25255B6%25255D.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="JsonCircularReferenceError" border="0" alt="JsonCircularReferenceError" src="http://lh3.ggpht.com/-kMM-qjJ8-7w/UTR4JiqM_NI/AAAAAAAACPw/A2cjxaVA5yc/JsonCircularReferenceError_thumb%25255B3%25255D.png?imgmax=800" width="630" height="213"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Instead we have 2 options:&lt;/p&gt; &lt;p&gt;1. POCO: Create a class (View Model) for the return value – one without circular references.&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ead24f19-e549-4c2b-8a95-ce8f57a4cef6" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonCustomer&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; value { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; label { &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;get&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;set&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; }&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonResult&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; GetCustomersClass(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; term)&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; results = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;from&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;in&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; db.Customers&lt;/span&gt;&lt;br&gt;                   &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;where&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c.CompanyName.StartsWith(term)&lt;/span&gt;&lt;br&gt;                   &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;select&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonCustomer&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; { value = c.CustomerID, label = c.CompanyName };&lt;/span&gt;&lt;br&gt; &lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Json(results.ToList(), &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonRequestBehavior&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.AllowGet);&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;2. Use Linq+Anonymous Classes to return that data from the DB entities:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3edfc4f5-19da-4e42-9e58-82546316592f" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonResult&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; GetCustomers(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; term)&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; results = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;from&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;in&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; db.Customers&lt;/span&gt;&lt;br&gt;                   &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;where&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c.CompanyName.StartsWith(term)&lt;/span&gt;&lt;br&gt;                   &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;select&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; { value = c.CustomerID, label = c.CompanyName };&lt;/span&gt;&lt;br&gt; &lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Json(results.ToList(), &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonRequestBehavior&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.AllowGet);&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Yair believes the second option is best because the class will only be used for returning values (you can’t use it in the client because the client is in JavaScript – not C#).&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;Demo: AutoComplete+Redirect&lt;/h4&gt; &lt;p&gt;AutoComplete box that when an item is selected the page is redirected to another and the value of the AutoComplete is passed to the new page.&lt;/p&gt; &lt;h5&gt;Server side:&lt;/h5&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:46c86b72-3b12-4f11-a93d-1b6ec397ad64" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ActionResult&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; OrdersForCustomers(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; id)&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; orders = db.Orders.Where(ord =&amp;gt; ord.CustomerID == id).Include(o =&amp;gt; o.Customer);&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; View(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, orders.ToList());&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;   &lt;h5&gt;Client side:&lt;/h5&gt; &lt;p&gt;We will use the &lt;a href="http://api.jqueryui.com/autocomplete/#event-select" target="_blank"&gt;select event&lt;/a&gt; of AutoComplete box. Since we don’t really know the event arguments lets debug them to see their values:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1fd59f43-073c-4357-97bf-c48f70d6bf9f" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;body&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;input&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;txtCustomer&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;script&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;$(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;#txtCustomer&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;).autocomplete({&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;source: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;orders/GetCustomers&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;select: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (event, ui) {&lt;/span&gt;&lt;br&gt;                 &lt;span style="background:#ffffff;color:#000000"&gt;alert(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Breakpoint here!&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;script&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;body&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;em&gt;&lt;u&gt;Note:&lt;/u&gt; putting the script tag inside the HTML body is another way to write $(document).ready(function(){…&lt;/em&gt; &lt;/p&gt; &lt;p&gt;We will add a breakpoint at the alert to see the argument values:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-hZWMUhzft4M/UTR4KLyOhAI/AAAAAAAACP4/YCEVVBOqXw4/s1600-h/ChromeF12DebugSelect%25255B7%25255D.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="ChromeF12DebugSelect" border="0" alt="ChromeF12DebugSelect" src="http://lh6.ggpht.com/-kx6iI7Yayy8/UTR4LIEJ3jI/AAAAAAAACQA/S-5-XkJIA4k/ChromeF12DebugSelect_thumb%25255B4%25255D.png?imgmax=800" width="615" height="419"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;As we can see the event argument contains information on the event itself: who called it, from where on the screen, the control name…&lt;/p&gt; &lt;p&gt;The ui argument is what we need it contains both the value and the label of the item selected.&lt;/p&gt; &lt;p&gt;Now the only thing left is to do the redirect:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e66972be-007c-45c8-be50-c46145d954c7" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;script&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;$(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;#txtCustomer&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;).autocomplete({&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;source: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;orders/GetCustomers&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;select: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (event, ui) {&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; url = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;#39;Orders/OrdersForCustomers/&amp;#39;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + ui.item.value;&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;window.location = url;&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;script&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;     &lt;p&gt;And the page will change to the correct URL.&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=MiaMP908egI:LL6SZoDM3Q4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/MiaMP908egI" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6075049653611576895?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6075049653611576895?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/MiaMP908egI/html5mvc-course-day-3.html" title="HTML5+MVC Course, Day 3" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/--mM_z4Sbwug/UTR30pFrBHI/AAAAAAAACMw/jWIgcvAI3lc/s72-c/NuGetUpdates_thumb%25255B4%25255D.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2013/03/html5mvc-course-day-3.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkEGR3o4eSp7ImA9WhBSGE0.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-7187448160702759152</id><published>2013-02-25T05:57:00.001-08:00</published><updated>2013-02-25T05:57:06.431-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-25T05:57:06.431-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript" /><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC" /><title>HTML5+MVC Course, Day 2</title><content type="html">&lt;p&gt;Continued from &lt;a href="http://www.dllshepherd.net/2013/02/html5mvc-course-day-1.html" target="_blank"&gt;day 1&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Last class we learned about the client side, today we are going to go over the server and talking to the server. In the past it was done with Forms and the method Post. Today there is Ajax.&lt;/p&gt; &lt;p&gt;If you want to skip the history lesson you can just go straight to &lt;a href="#Practical-Mvc"&gt;“ASP.NET MVC 4” title&lt;/a&gt;.&lt;/p&gt; &lt;h3&gt;General&lt;/h3&gt; &lt;h4&gt;There are 3 option to build Web Applications:&lt;/h4&gt; &lt;h5&gt;1. Html rendering in the Server side&lt;/h5&gt; &lt;p&gt;Every action from changing the color of the text to filtering a table is done by calling the server and getting the result to the client. If you wanted to see the Current Movies, Current Traffic, something from the DB/File system the server renders it.&lt;/p&gt; &lt;p&gt;The server is a “Factory” for Html.&lt;/p&gt; &lt;p&gt;Technological History: CGI, ASP (allowed saving data in the server using the Session object), Sun did something similar with Java.&lt;/p&gt; &lt;p&gt;The Code is build into a Dll, you get to write in a real language (.Net or Java), you get memory management, variables, …&lt;/p&gt; &lt;p&gt;You want to do something, you fill out a Form and data goes to the server. But doing something like Filtering required going to the server as well. Microsoft added a lot of libraries to help this pragma: Rendering, Caching, Database, Controls. All of them for the server side. &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The Browsers became stronger, so they moved to option 2: &lt;/p&gt; &lt;h5&gt;2. Ajax: Html Rendering in the Server but some parts call the server for updates&lt;/h5&gt; &lt;p&gt;In the past there was a Frame that you could use to receive updates to just part of the page (most of the Portals inside organizations are still built like this). But Frames are in the past and HTML5 doesn’t include them. Frames are windows that work independently – like opening a different browser per frame, but with frames you can have one frame ask another to do some action. Every frame has a different DOM.&lt;/p&gt; &lt;p&gt;Inner objects in the Html page are calling the server with Ajax to receive updates. The whole page is not updated just the inner part. &lt;/p&gt; &lt;p&gt;Ajax Call – Microsoft has invented a component called XML Http (later&lt;strong&gt; &lt;/strong&gt;the other Browsers implemented it as well) that is&amp;nbsp; an Object that lives in the DOM (it is actually part of the DOM), it resembles a Frame, it has an inner Form, it sends a request and gets back a response asynchronously (without asking – it’s default way). XML Http was later renamed Ajax, they first believed that you will just transfer XML data and in the client transform it using XSL – joining them both will result in HTML (it was called B2C - Business to Consumer). For a long time no one used that object because ASP got in and made use of option 1, only a few people actually worked with it. &lt;/p&gt; &lt;p&gt;Then Mozilla-Firefox and Google-Chrome adopted this object and gave it the name Ajax - Asynchronously JavaScript And Xml: Asynchronously because that’s how it worked, JavaScript because that the language that consumed it, And Xml that was back then. Today the only part left is asynchronously (JavaScript is a given) no one uses Xml… &lt;/p&gt; &lt;p&gt;ASP.NET Ajax is Microsoft adoption of option 2: it uses a hidden field named ViewState to pass data from the server to the client, they built the ViewState in the Client and passed it to the Server, then built in the Server and passed it to the Client… It worked well: Render in the server and update increments. Sorting some table for example sent Ajax to the server, the server returned a small Html part, then you took a “knife” and cut out the old Html and put instead the new Html. All you had to do was mark which Control you wanted and the system would disable the submit for those controls, do an Ajax request, receive an Ajax response with just the Html needed and replace the control.The problem is it was all done automatically, architecturally wrong: just “drag and drop” and the system patched all the component together. This system was easy for starting users but annoying to advanced users: even changing the design of a button might cause headaches. &lt;/p&gt; &lt;p&gt;ASP.NET came in 2001 to solve the then problem of memory. The Session was a problematic object (the Enemy) that was kept for 20 minutes (by default). So to solve that problem ASP.NET transformed the session to an object that was passed from the server to the client called the ViewState. Since that time memory became less of an enemy, storage has became cheaper but Microsoft was stuck with the ViewState (not using it was an equitant to going back to ASP). &lt;/p&gt; &lt;p&gt;Then came &lt;a href="http://en.wikipedia.org/wiki/PHP" target="_blank"&gt;PHP&lt;/a&gt; that &lt;a href="http://blog.facebook.com/blog.php?post=2356432130" target="_blank"&gt;Facebook was built using a spinoff of PHP&lt;/a&gt;. PHP came with the attitude of not using the ViewState hidden field. After that in 2010 Microsoft came up with &lt;a href="http://en.wikipedia.org/wiki/ASP.NET_MVC_Framework" target="_blank"&gt;ASP.NET MVC&lt;/a&gt;.&lt;/p&gt; &lt;h5&gt;2.1. ASP.NET MVC&lt;/h5&gt; &lt;p&gt;The Controller (written in C# and can be debugged and unit tested) creates/puts data into the View and renders the Html in the Server. The controller also allows returning JSON to the client without rendering the Html (the + 0.1). As opposed to ASP.NET Web Forms: &lt;/p&gt; &lt;ul&gt; &lt;li&gt;No more Ajax  &lt;li&gt;Works with jQuery (in it’s orientation)  &lt;li&gt;Total separation between the client side and the server side &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;No longer uses the ViewState, instead uses the Session. &lt;/p&gt; &lt;p&gt;In 2012 Microsoft adds &lt;a href="http://www.asp.net/web-api" target="_blank"&gt;ASP.NET Web API&lt;/a&gt;, &lt;a href="http://www.asp.net/mobile" target="_blank"&gt;Mobile&lt;/a&gt;, &lt;a href="http://www.asp.net/vnext/overview/fall-2012-update/facebook-application-template-tutorial" target="_blank"&gt;Facebook extension&lt;/a&gt;,… &lt;/p&gt; &lt;h5&gt;3. Html Rendered in the Client, the Server supplies the data&lt;/h5&gt; &lt;p&gt;The application is written with a static Html page, the Server supplies the data with the Business Model. No Html is rendered in the Server. The rendering is done in the Client. The first template might come statically from the server but nothing is rendered in the server. &lt;/p&gt; &lt;p&gt;jQuery was build in the same time as ASP.NET Ajax by &lt;a href="http://ejohn.org/" target="_blank"&gt;John Resig&lt;/a&gt;, started as a &lt;a href="http://ejohn.org/blog/selectors-in-javascript/" target="_blank"&gt;library that supplied selectors&lt;/a&gt; by Id, Class name, Element name, etc. (&lt;a href="http://ejohn.org/apps/jselect/selector.js" target="_blank"&gt;Original JavaScript code&lt;/a&gt;). Minimal code that rely on CSS3. Supports all the Browsers (from IE8 and on, Firefox, Chrome…). Then he added some elementary actions like toggle, style, etc. And (of course) provided support for Ajax (in a property that has a url to which you can GET or POST with a name-value array). &lt;/p&gt; &lt;p&gt;jQuery became a &lt;strong&gt;Must Have&lt;/strong&gt; for every Web Developer in the industry. On top of that came the jQueryUI group that build it’s control on top of jQuery as an alternative to Microsoft’s ASP.NET Ajax (like the AutoComplete box that is available at both libraries).&lt;/p&gt; &lt;p&gt;At around that time JavaScript Framework started appearing that enabled OOP JavaScript, with MVVM or MV* (MV Something): Model you always need, View you always need, now you need something that connects them – in MVC it’s the controller and in MVVM it’s the View Model. The Frameworks were built in &lt;a href="https://github.com/" target="_blank"&gt;GitHub&lt;/a&gt; where entire communities were built around those projects. One of those is &lt;a href="http://knockoutjs.com/" target="_blank"&gt;Knockout&lt;/a&gt; by &lt;a href="http://en.wikipedia.org/wiki/KnockoutJS" target="_blank"&gt;Steve Sanderson&lt;/a&gt; who is now a Microsoft employee (though the code is not owned by Microsoft). Knockout gives Templates and is very similar to Silverlight.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h3 id="Practical-Mvc"&gt;ASP.NET MVC 4&lt;/h3&gt; &lt;p&gt;We will start with ASP.NET MVC of option 2 (fully rendering in the server side: looking briefly at the Controllers of MVC, the routing mechanism, the view, the Razor engine that help the view. The model will be built using Entity Framework. First by hand then using a wizard) and upgrade it to option 3 (with a html page that calls the server for JSON data, with jQueryUI AutoComplete). &lt;/p&gt; &lt;p&gt;Create empty MVC Project with Empty Project Template (or just use the one from last lesson):&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-tiQjBBHGsxY/USttPXoXwSI/AAAAAAAACHc/LZxgFPlY5mY/s1600-h/CreateEmptyMvcProject%25255B7%25255D.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="CreateEmptyMvcProject" border="0" alt="CreateEmptyMvcProject" src="http://lh4.ggpht.com/-o1Ewe0qaaRE/USttQIYwoLI/AAAAAAAACHk/-YHJ6lnmJPg/CreateEmptyMvcProject_thumb%25255B4%25255D.png?imgmax=800" width="390" height="353"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Add Controller named HomeController – by right clicking the Controllers folder-&amp;gt; Add-&amp;gt; Controller… (or Ctrl+M,Ctrl+C):&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-miIPJe19xdA/USttQSHfM7I/AAAAAAAACHs/kT_CMhWtQTc/s1600-h/AddingHomeController%25255B6%25255D.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="AddingHomeController" border="0" alt="AddingHomeController" src="http://lh6.ggpht.com/-JxCPXlYfvLA/USttRIQONMI/AAAAAAAACH0/SCFQO-agqpM/AddingHomeController_thumb%25255B3%25255D.png?imgmax=800" width="398" height="260"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Template: Empty MVC controller&lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;u&gt;Note:&lt;/u&gt; Controller names must end with Controller, MVC at the server works with naming conventions.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;In HomeController we get a default method of Index():&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-xNdzVM5f30I/USttRgA1zJI/AAAAAAAACH8/CI9FCF8-_rQ/s1600-h/MvcBasicUrlFormat%25255B7%25255D.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="MvcBasicUrlFormat" border="0" alt="MvcBasicUrlFormat" src="http://lh5.ggpht.com/-XQ46lrKVQKc/USttSAGZSsI/AAAAAAAACIE/OWJOnGdwjYg/MvcBasicUrlFormat_thumb%25255B4%25255D.png?imgmax=800" width="451" height="203"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Trying to run it will return an error “The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched…”:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-J9mzXIMQLzc/USttS3fVRnI/AAAAAAAACIM/bCltifsOArw/s1600-h/MvcErrorNoViewCreated%25255B8%25255D.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="MvcErrorNoViewCreated" border="0" alt="MvcErrorNoViewCreated" src="http://lh3.ggpht.com/--EvWYBiDc0E/USttTtlZQAI/AAAAAAAACIU/H4zt0ol1xGQ/MvcErrorNoViewCreated_thumb%25255B5%25255D.png?imgmax=800" width="738" height="426"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The method:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e6b985b-97a4-41a9-8b07-cb3dda15c520" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ActionResult&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Index()&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; View();&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;leads us to the default View of the method named Index. MVC looks for the view Home-Index at a lot of location but doesn’t find it, because it doesn’t exist we get an Error. We have a Controller Home with Index that returns View() – which is the default view for that action. &lt;/p&gt; &lt;p&gt;&lt;em&gt;Another way of thinking about it is: The Controller is C# code, the View is HTML script. The code we have cannot be translated to HTML.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;The View method has several overrides:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;View() – default view: the same name as the method that calls View(), in our case Index  &lt;li&gt;View(object) – object that he can shove into the default view as it’s data (in the future it will be the Model)  &lt;li&gt;View(IView) – using a custom view object  &lt;li&gt;View(IView, object) - using a custom view object with object data  &lt;li&gt;View(string) – the value of the string is the name of a different view that will be the View  &lt;li&gt;View(string, object) – view name with object data  &lt;li&gt;View(string, string) – view name with master name  &lt;li&gt;View(string, string, object) - view name with master name and object data &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Adding a View is as easy as right clicking the Index method and clicking Add view (or Ctrl+M, Ctrl+V):&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-C_Cr7tPtXbA/USttUJ03OlI/AAAAAAAACIc/HKksj9Fqz6o/s1600-h/BasicMvcAddViewDialog%25255B6%25255D.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="BasicMvcAddViewDialog" border="0" alt="BasicMvcAddViewDialog" src="http://lh5.ggpht.com/-iyiQlW7CFWw/USttU7I61kI/AAAAAAAACIk/4zpGx2Vnbos/BasicMvcAddViewDialog_thumb%25255B3%25255D.png?imgmax=800" width="406" height="401"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;For now we will uncheck the “Use a layout or master page”, because we don’t have one. The view was added at:&lt;/p&gt; &lt;p&gt;View\Home\Index.cshtml&lt;/p&gt; &lt;p&gt;(the location is a very important part)&lt;/p&gt; &lt;p&gt;Now running the application won’t cause any error. But the View is static, the Controller doesn’t do anything.&lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;u&gt;Note:&lt;/u&gt; CSHTML (the extension of the view file) doesn’t have a built in designer. You can use a designer to build the HTML and just copy paste that to the CSHTML.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Passing data from the Controller to the View:&lt;/h5&gt; &lt;p&gt;For that we will use a &lt;a href="http://msdn.microsoft.com/en-us/library/vstudio/dd264741.aspx" target="_blank"&gt;dynamic&lt;/a&gt; object named &lt;a href="http://rachelappel.com/when-to-use-viewbag-viewdata-or-tempdata-in-asp.net-mvc-3-applications" target="_blank"&gt;ViewBag&lt;/a&gt; that is defined in MVC.&lt;/p&gt; &lt;p&gt;In the Controller writing:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f9c0e43a-4e91-4c1c-9efc-a58be2098561" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;ViewBag.Msg = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Hello&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;In the View:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b6d4690d-4bfd-45b4-bb2a-02b61d7b3681" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;body&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;div&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffff00;color:#000000"&gt;@&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;ViewBag.Msg&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;div&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;body&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The result is a page displaying Hello.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Configuring the default page in MVC:&lt;/h5&gt; &lt;p&gt;AppStart\RouteConfig.cs&lt;/p&gt; &lt;p&gt;Contains the code that tell MVC that the default Controller is Home and the default Action is Index:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2794947e-bf71-4703-b756-3d63bcf092dc" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;RouteConfig&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;static&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;void&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; RegisterRoutes(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;RouteCollection&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; routes)&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;routes.IgnoreRoute(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;{resource}.axd/{*pathInfo}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;br&gt; &lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;routes.MapRoute(&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;name: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Default&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;url: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;{controller}/{action}/{id}&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;defaults: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; { controller = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Home&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, action = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, id = &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;UrlParameter&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.Optional }&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The first row just tells the server to ignore all requests with .axd. &lt;a href="http://stackoverflow.com/q/9016650/262099" target="_blank"&gt;Because ASP.NET uses urls with .axd extension internally&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;The second row tells us what the default url is – Home\Index. it also tells us that it receives an Id and that it is optional.&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;em&gt;Note:&lt;/em&gt;&lt;/u&gt; &lt;em&gt;the Home Controller is the default Controller (it isn’t because we added a Controller named Home, it was like this before hand). And Index is the default action.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Passing Id to an Action:&lt;/h5&gt; &lt;p&gt;In the Controller:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c311f463-b9ba-4d7c-9404-82f1c1270797" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ActionResult&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Test(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;int&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;? id)&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;ViewBag.Msg = id.HasValue ? id.Value.ToString() : &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Hello test&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; View(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;View(“Index”) tells MVC to use the Index view for this action.&lt;/p&gt; &lt;p&gt;Calling from the Browser:&lt;/p&gt; &lt;p&gt;\Home\Test\123&lt;/p&gt; &lt;p&gt;(Better for GET request if you need the extra length of GET)&lt;/p&gt; &lt;p&gt;or&lt;/p&gt; &lt;p&gt;\Home\Test?id=123&lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;u&gt;Note:&lt;/u&gt; Passing something that isn’t an int (like ABC) to Test will be the same as not passing a value, i.e. passing null.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;What is better Get or Post?&lt;/h4&gt; &lt;p&gt;&lt;strong&gt;&lt;a href="http://en.wikipedia.org/wiki/GET_(HTTP)#Request_methods" target="_blank"&gt;GET&lt;/a&gt;&lt;/strong&gt; wakes the server and does the request at the same time. &lt;/p&gt; &lt;ul&gt; &lt;li&gt;Limited in it’s length.  &lt;li&gt;Security: The talk about being insecure is wrong since POST without encryption is just as insecure as GET (passing a user+password in the url is the same as passing it in POST since using any sniffer you can see the variables, it should be preferred to put it in the url so that it could be fixed).  &lt;li&gt;If you can get – GET: Much better at the performance. Google uses GET. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;strong&gt;&lt;a href="http://en.wikipedia.org/wiki/POST_(HTTP)" target="_blank"&gt;POST&lt;/a&gt;&lt;/strong&gt; calls the server, the server opens a socket, the server returns HTTP 100 response and then start passing the data. &lt;/p&gt; &lt;ul&gt; &lt;li&gt;Security: Data can be encrypted. But if it doesn’t then just use GET.  &lt;li&gt;We used POST in ASP.NET because of the ViewState – just saying “hello” caused the GET data to be filled.  &lt;li&gt;Not limited in length &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;MVC with Entity Framework Model&lt;/h4&gt; &lt;p&gt;Create a new MVC 4 project with a template of Internet Application:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-6IXykVHKD0o/USttVmY3ChI/AAAAAAAACIs/iQkTBes47lw/s1600-h/AddProjectMvcWithInternet%25255B7%25255D.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="AddProjectMvcWithInternet" border="0" alt="AddProjectMvcWithInternet" src="http://lh5.ggpht.com/-1UcLNMZzn3o/USttXEFhOLI/AAAAAAAACIw/LL2dhScjWhw/AddProjectMvcWithInternet_thumb%25255B4%25255D.png?imgmax=800" width="518" height="469"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h5&gt;Exercise: changing the default layout:&lt;/h5&gt; &lt;ul&gt; &lt;li&gt;Add a tag of test in the home controller  &lt;li&gt;Add a tag of test2 in the WhatEver controller &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The default layout is configured at _ViewStart.cshtml:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5eaa11ae-4fc8-47fd-8389-e4940a645cef" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffff00;color:#000000"&gt;@{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;Layout = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;~/Views/Shared/_Layout.cshtml&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;In Razor the file _ViewStart.cshtml determines what is the default layout. You can define a different layout when adding a view:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-CDi4agBRqFs/USttXniyILI/AAAAAAAACI8/jq0sLusI0qU/s1600-h/MvcChoosingLayout%25255B6%25255D.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="MvcChoosingLayout" border="0" alt="MvcChoosingLayout" src="http://lh6.ggpht.com/-tkLh9O4zeIw/USttYrQEylI/AAAAAAAACJE/KRCy3xZNofc/MvcChoosingLayout_thumb%25255B3%25255D.png?imgmax=800" width="412" height="407"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;(what I wrote is the same as leaving it empty, both point to the same file)&lt;/p&gt; &lt;p&gt;The code added will contain the layout specified:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:138c5a5c-fded-47e5-bfbb-61cd86469e80" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffff00;color:#000000"&gt;@{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;ViewBag.Title = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;Layout = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;~/Views/Shared/_Layout.cshtml&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt; &lt;br&gt; &lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;h2&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;Test&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;h2&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The code for leaving the text box empty (using the default layout):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d0a8b479-759f-489f-a3d0-71151ef06216" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffff00;color:#000000"&gt;@{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;ViewBag.Title = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The code for not checking the checkbox (not using a layout):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:46ca9603-2cd1-4225-8210-6bae0d5c262a" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffff00;color:#000000"&gt;@{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;Layout = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;null&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;Self study:&lt;/strong&gt;&lt;/u&gt;&amp;nbsp;&lt;a href="http://www.mikesdotnetting.com/Article/105/ASP.NET-MVC-Partial-Views-and-Strongly-Typed-Custom-ViewModels" target="_blank"&gt;Partial views&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;Installing Northwinds DB:&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt; &lt;li&gt;&lt;a href="http://northwinddatabase.codeplex.com/releases/view/71634" target="_blank"&gt;Download Northwinds.sql.zip&lt;/a&gt;  &lt;li&gt;Using SQL Server Management and a SA account add a new database named: Northwind  &lt;li&gt;Run the script Northwinds.sql using SQL Server Management and the SA account  &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Under Model folder add ADO.NET Entity Data Model and connect it to the Northwind DB with:&lt;/p&gt; &lt;li&gt;Table: Customers  &lt;li&gt;Table: Orders  &lt;li&gt;Stored Procedure: CustOrderHist  &lt;p&gt;&lt;em&gt;&lt;u&gt;Note:&lt;/u&gt; it is advised to separate the Model from the ORM (when there are many-to-one or many-to-many relationships a JSON parser might cause an infinite loop, separating it to simple classes without outside relations solves the problem), but for this demo we won’t.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;u&gt;Reference:&lt;/u&gt;&lt;/strong&gt; &lt;/em&gt;&lt;a href="https://github.com/AutoMapper/AutoMapper" target="_blank"&gt;&lt;em&gt;AutoMapper&lt;/em&gt;&lt;/a&gt;&lt;em&gt; that helps mapping between the ORM Model to MVC Model.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Add new controller:&lt;/p&gt; &lt;li&gt;Template: MVC controller with read/write actions TODO using EF  &lt;li&gt;Model: Customer  &lt;li&gt;Data Context NorthwindEntities  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-bN6fYdyXzos/USttZ13Fb1I/AAAAAAAACJI/LXX-cBhEch4/s1600-h/AddMvcControllerWithEF%25255B8%25255D.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="AddMvcControllerWithEF" border="0" alt="AddMvcControllerWithEF" src="http://lh3.ggpht.com/-6M4QgJ5BVrY/USttakmN2vI/AAAAAAAACJU/WVSL_e-50bw/AddMvcControllerWithEF_thumb%25255B5%25255D.png?imgmax=800" width="494" height="322"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Just adding an EF Controller gives out of the box a controller and view for actions such as Index with a list of customers that allows viewing, editing, creating and deleting of rows. Though some of the functionality doesn’t work- for example create.&lt;/p&gt; &lt;p&gt;For example the Index view looks like this:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-kQkumzIbZPc/USttbHyrKqI/AAAAAAAACJc/aaRhK4RILG0/s1600-h/MvcWithEfIndexView%25255B11%25255D.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="MvcWithEfIndexView" border="0" alt="MvcWithEfIndexView" src="http://lh5.ggpht.com/-ldNCwqMBv4s/USttb7WCwKI/AAAAAAAACJk/CPNuLQsCDR0/MvcWithEfIndexView_thumb%25255B8%25255D.png?imgmax=800" width="633" height="334"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;(clicking on each link passes you to the different views, for example clicking on the first row details the browser redirects to BaseUrl/Customer/Details/ALFKI)&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;The Create action is divided to two methods: &lt;/h5&gt; &lt;p&gt;GET for a blank page(the default is an attribute of HttpGet):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:57fee0de-6cc2-473c-b49f-f32ff4799743" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ActionResult&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Create()&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; View();&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Http Post that after the submit saves the data (it is like in &lt;a href="http://www.evagoras.com/2011/02/10/how-postback-works-in-asp-net/" target="_blank"&gt;ASP.NET Web Forms PostBack&lt;/a&gt;):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:92d232de-63f8-4adb-92b6-2bda2b26e1c8" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;[&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;HttpPost&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;]&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;ActionResult&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Create(&lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;Customer&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; customer)&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (ModelState.IsValid)&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;db.Customers.Add(customer);&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;db.SaveChanges();&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; RedirectToAction(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Index&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt; &lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; View(customer);&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;ModelState.IsValid makes sure that all the fields are correct by checking the data types and more advanced the Data Annotations of the model: one property below another, one is times two another, checking the data against data in the DB… For all of those there will be a nice validation error shown to the user.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Reference Data Validation:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;li&gt;&lt;a href="http://www.asp.net/mvc/tutorials/older-versions/models-(data)/validation-with-the-data-annotation-validators-cs" target="_blank"&gt;With UI&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.dotnet-tricks.com/Tutorial/mvc/D8I4270712-MVC-Data-Annotations-for-Model-Validation.html" target="_blank"&gt;More on Validations&lt;/a&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;After submitting the Create form an Error “pops”:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-hvHpmpWETdo/USttdO0cC-I/AAAAAAAACJo/gXDMiLBAIw8/s1600-h/MvcEfCreateError%25255B7%25255D.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="MvcEfCreateError" border="0" alt="MvcEfCreateError" src="http://lh5.ggpht.com/-zPIle7s_gHc/USttd-h-8fI/AAAAAAAACJ0/HcKkpd4qORM/MvcEfCreateError_thumb%25255B4%25255D.png?imgmax=800" width="651" height="311"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The Create method failed in saving to the DB. It doesn’t work because the view is missing the CustomerID field (which the system “thought” that in the DB that field is Auto Increment – it isn’t!).&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Exercise:&lt;/u&gt;&lt;/strong&gt; Make create work by adding the CustomerID field to the UI.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;em&gt;Side note on Entity Framework:&lt;/em&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;NorthwindEntities should inherit from DbContext (and not from ObjectContext)&lt;/em&gt;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3f338449-f038-4a5b-818d-959d6167dfca" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;partial&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;NorthwindEntities&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; : &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;DbContext&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;em&gt;Using ObjectContext means that the entities inherit from ObjectData, are not &lt;/em&gt;&lt;a href="http://en.wikipedia.org/wiki/Plain_Old_CLR_Object" target="_blank"&gt;&lt;em&gt;POCO&lt;/em&gt;&lt;/a&gt;&lt;em&gt; and has a lot of extra code (like INotifyChanges that WPF loved). &lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Yair advised to start from the code and let EF generate the DB (unless you are in good terms with the DBA).&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Returning JSON results: &lt;/h5&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2b9a6858-bd82-46c1-8663-4872c31bef90" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonResult&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; GetCustomersDetail(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; term)&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; results = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;from&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;in&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; db.Customers&lt;/span&gt;&lt;br&gt;                   &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;where&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c.CustomerID.StartsWith(term)&lt;/span&gt;&lt;br&gt;                   &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;select&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;new&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; { Id = c.CustomerID, name = c.ContactTitle, other = c.CompanyName};&lt;/span&gt;&lt;br&gt; &lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Json(results.ToList(), &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonRequestBehavior&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.AllowGet);&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;JsonRequestBehaviour enum:&lt;/p&gt; &lt;li&gt;DenyGet – the default option from a security point view, though using Fiddler you can quite easily see the POST request/response.  &lt;li&gt;&lt;strong&gt;AllowGet&lt;/strong&gt; – usually not turning this on causes the system to not work. &lt;strong&gt;&lt;u&gt;Just turn it on!&lt;/u&gt;&lt;/strong&gt;&amp;nbsp; &lt;p&gt;Calling it:&lt;/p&gt; &lt;p&gt;/Customer/GetCustomersDetail?term=a&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-oxFpdHMtOag/USttelmC_GI/AAAAAAAACJ8/CE3voloLPkE/s1600-h/JsonNotPretty%25255B6%25255D.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="JsonNotPretty" border="0" alt="JsonNotPretty" src="http://lh5.ggpht.com/-SZfV-BTDG3E/USttfY_IErI/AAAAAAAACKE/XYetybCWUgU/JsonNotPretty_thumb%25255B3%25255D.png?imgmax=800" width="422" height="93"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The results can be made more readable using the &lt;a href="https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc?hl=en" target="_blank"&gt;Chrome Extension JSONView from Developer Tools&lt;/a&gt;:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-qe9ZJVxBem4/USttf0595eI/AAAAAAAACKM/dn9ZPjo9YgQ/s1600-h/JsonChromeExtension%25255B7%25255D.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="JsonChromeExtension" border="0" alt="JsonChromeExtension" src="http://lh4.ggpht.com/-QzP7dj2pxvg/USttgpOS6uI/AAAAAAAACKU/41_h-z0uYyc/JsonChromeExtension_thumb%25255B4%25255D.png?imgmax=800" width="354" height="362"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;u&gt;Note:&lt;/u&gt; We can’t use /Customer/GetCustomersDetail/a because we want to pass the term parameter not the id parameter.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/u&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;JSON Syntax:&lt;/h5&gt; &lt;li&gt;[…] array  &lt;li&gt;{…} a type  &lt;li&gt;Instead of = we use :  &lt;li&gt;Commas to separate types/properties  &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;Exercise:&lt;/strong&gt;&lt;/u&gt; Add a text box that creates a combo box of auto complete using a JSON method. Using the event OnChange when 2 seconds pass we will request the data from the server with a GET, receive the data asynchronously, create a type out of the data returned, and set the result in the view as a list items below the TextBox. The only missing information we need is how to &lt;a href="http://api.jquery.com/jQuery.ajax/" target="_blank"&gt;make an Ajax call using jQuery&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The JSON method:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:65a2ef73-8b51-43bd-bd3e-bde045032ec6" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;public&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonResult&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; GetCustomers(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;string&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; term)&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;{&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; results = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;from&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;in&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; db.Customers&lt;/span&gt;&lt;br&gt;                   &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;where&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c.CustomerID.StartsWith(term)&lt;/span&gt;&lt;br&gt;                   &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;select&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; c.CustomerID;&lt;/span&gt;&lt;br&gt; &lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;return&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; Json(results.ToList(), &lt;/span&gt;&lt;span style="background:#ffffff;color:#2b91af"&gt;JsonRequestBehavior&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;.AllowGet);&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;In the &lt;a href="http://api.jquery.com/jQuery.ajax/#jqXHR" target="_blank"&gt;Documentation&lt;/a&gt; we will use the following demo as our base:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2103b7ab-7569-4531-ad1c-01f139e1a2cd" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;$.ajax({&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;url: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;http://fiddle.jshell.net/favicon.png&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;beforeSend: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (xhr) {&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;xhr.overrideMimeType(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;text/plain; charset=x-user-defined&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;}).done(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (data) {&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;if&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (console &amp;amp;&amp;amp; console.log) {&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;console.log(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Sample of data:&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;, data.slice(0, 100));&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;We will change it to:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e2ebe204-6853-4780-a6e7-e997783bdeb1" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;$(document).ready(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; () {&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;$(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;#btnGetCustomers&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;).click(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; () {&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; strUrl = &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Customer/GetCustomers?term=&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; + $(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;#txtCustomer&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;).val();&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;$.ajax({&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;url: strUrl,&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;beforeSend: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (xhr) {&lt;/span&gt;&lt;br&gt;                 &lt;span style="background:#ffffff;color:#000000"&gt;alert(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Good Luck&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;}).done(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (data) {&lt;/span&gt;&lt;br&gt;             &lt;span style="background:#ffffff;color:#000000"&gt;alert(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Done&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The Body looks like:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3e08a439-67d3-4c88-9d67-e94b65cc9641" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;input&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;txtCustomer&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;button&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;btnGetCustomers&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;Click Me&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;button&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;em&gt;&lt;u&gt;Note:&lt;/u&gt; The first example from &lt;/em&gt;&lt;a href="http://api.jquery.com/jQuery.ajax/#entry-examples" target="_blank"&gt;&lt;em&gt;here&lt;/em&gt;&lt;/a&gt;&lt;em&gt; show using jQuery Ajax with POST. If you want to use the data parameter you must work with a POST. GET doesn’t know how to work with the data parameter.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Now lets debug it to see what the data returns.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Debugging JavaScript:&lt;/h5&gt; &lt;p&gt;1. Using IE:&lt;/p&gt; &lt;p&gt;Add break point in VS2012&lt;/p&gt; &lt;p&gt;Set the current browser to IE (on the HTML page right click –&amp;gt; Browse With…):&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-Ti9y7YOeZTM/UStthkPv7TI/AAAAAAAACKc/I3Lvxyk0b3E/s1600-h/Vs2012BrowseWith%25255B8%25255D.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="Vs2012BrowseWith" border="0" alt="Vs2012BrowseWith" src="http://lh4.ggpht.com/-PH-3QMZt7vw/USttid2PwbI/AAAAAAAACKk/0Epxns2XtW4/Vs2012BrowseWith_thumb%25255B5%25255D.png?imgmax=800" width="385" height="291"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Choose Internet Explorer and set it as the default browser.&lt;/p&gt; &lt;p&gt;And then just start debugging:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-AnIrfOTObnw/UStti6cH9rI/AAAAAAAACKs/mCxHE9ul9gY/s1600-h/DebuggingJavaScriptIE%25255B6%25255D.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="DebuggingJavaScriptIE" border="0" alt="DebuggingJavaScriptIE" src="http://lh4.ggpht.com/-BLM0yFrgV9E/USttjoPiDEI/AAAAAAAACK0/Z6qW8sA4NNg/DebuggingJavaScriptIE_thumb%25255B3%25255D.png?imgmax=800" width="514" height="134"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;2. Using Chrome F12: Open Sources tab&lt;/p&gt; &lt;p&gt;When you open it it will be empty simply click on this thingy (“Show navigator”):&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-JTEzE-LpzSc/USttkVWTFKI/AAAAAAAACK8/lMxJ6kfaVsk/s1600-h/ChromeF12SourcesTab%25255B6%25255D.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="ChromeF12SourcesTab" border="0" alt="ChromeF12SourcesTab" src="http://lh4.ggpht.com/-fjUL9unAv_I/USttkzJJo4I/AAAAAAAACLE/aO3ZoheFBhk/ChromeF12SourcesTab_thumb%25255B3%25255D.png?imgmax=800" width="574" height="208"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Choose the file you want to debug:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-BamR8bDj7Ro/USttlnf7LXI/AAAAAAAACLM/2Nq9IQzCvAc/s1600-h/ChromeF12SourcesHtml%25255B5%25255D.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="ChromeF12SourcesHtml" border="0" alt="ChromeF12SourcesHtml" src="http://lh6.ggpht.com/-K-SraAfSQFI/USttm__PYRI/AAAAAAAACLU/1iSeohgmYtA/ChromeF12SourcesHtml_thumb%25255B2%25255D.png?imgmax=800" width="244" height="242"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;In our case the HTML page and right click to add break points (you might have to refresh the page).&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-G5CeFa86nzo/USttoDaMnMI/AAAAAAAACLY/-MnDlmbmh2M/s1600-h/ChromeDebuggerBreakpoint%25255B7%25255D.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="ChromeDebuggerBreakpoint" border="0" alt="ChromeDebuggerBreakpoint" src="http://lh6.ggpht.com/-_baA4N2AwGU/UStto8XLhEI/AAAAAAAACLk/QrCC54RCGH8/ChromeDebuggerBreakpoint_thumb%25255B4%25255D.png?imgmax=800" width="525" height="460"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Now the only thing left as homework is changing the Done alert to display the results as HTML list items below txtCustomer.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;jQuery Tip:&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e732c873-8fb6-432f-b2e1-add5a4e21e52" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;$(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;() {&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;is a shortcut to:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4f5dd126-0c61-4be7-b12c-9599312518fa" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;$(document).ready(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; () {&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;jQueryUI&lt;/h4&gt; &lt;p&gt;Instead of doing all that work we will use jQueryUI for AutoComplete.&lt;/p&gt; &lt;p&gt;You can see at &lt;a href="http://jqueryui.com/" target="_blank"&gt;jQueryUI.com&lt;/a&gt; an interactive demo of the different Widgets and Effects available at jQueryUI. One of the Widget available is the &lt;a href="http://jqueryui.com/autocomplete/" target="_blank"&gt;Autocomplete&lt;/a&gt;, you should start by looking at the source code.&lt;/p&gt; &lt;p&gt;The application has only one important line of code – the input tag:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9a6a9652-67f6-48e8-ac33-60f804c3ab3f" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;label&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;for&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;tags&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;Tags: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;label&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;input&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;tags&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;em&gt;&lt;u&gt;&lt;/u&gt;&lt;/em&gt; &lt;p&gt;&lt;em&gt;&lt;u&gt;Note:&lt;/u&gt; the for="tags" in the label is a HTML5 effect that when the tags is unavailable the label becomes unavailable as well.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Updating our Customers example jQuery code to use jQueryUI:&lt;/p&gt; &lt;p&gt;Step 1: AutoComplete from a constant array (just like the &lt;a href="http://jqueryui.com/autocomplete/" target="_blank"&gt;example on the site&lt;/a&gt;): &lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e3d96332-da2c-4eaa-ab0d-7aaecbd6bc7d" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;$(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; () {&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;var&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; customers = [&lt;/span&gt;&lt;br&gt;       &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;ActionScript&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;br&gt;       &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;AppleScript&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;br&gt;       &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Asp&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;br&gt;       &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;BASIC&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;,&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;];&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;$(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;#txtCustomer&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;).autocomplete({&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;source: customers&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Running it with “a” and we get:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-r8Z8KHF5IvA/USttptrK06I/AAAAAAAACLs/Di-iMv7l3Qk/s1600-h/jQueryUiAutoCompleteWithoutCss%25255B7%25255D.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="jQueryUiAutoCompleteWithoutCss" border="0" alt="jQueryUiAutoCompleteWithoutCss" src="http://lh6.ggpht.com/-EUCakiAeH2o/USttqY5RVfI/AAAAAAAACL0/cJkjXp11JSk/jQueryUiAutoCompleteWithoutCss_thumb%25255B4%25255D.png?imgmax=800" width="212" height="161"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Clicking on a list item will cause the text to “Magically” appear in the textbox. But the UI is a bit ugly.&lt;/p&gt; &lt;p&gt;Looking at the tag in Chrome F12, we see that when we used .autocomplete on our textbox jQueryUI changed our HTML to:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0693916d-afc5-41e8-b99c-4b2af493c093" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;input&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;txtCustomer&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-autocomplete-input&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;autocomplete&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;off&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;role&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;textbox&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;aria-autocomplete&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;list&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;aria-haspopup&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;true&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;ul&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;role&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;listbox&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;aria-activedescendant&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-active-menuitem&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;style&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;z-index&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;1&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;top&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;0px&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;left&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;0px&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;display&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;none&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;ul&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;class=”ui-autocomplete-input” - if we used a CSS then the autocomplete would have looked nice&lt;/p&gt; &lt;p&gt;autocomplete="off" - jQueryUI uses this variable and set it to “on” when it is working, so that when it is on it “knows” not to work. &lt;/p&gt; &lt;p&gt;When results arrive (for example by entering “a”):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ecdffd90-c97c-4bfb-a49e-18a3918f0e82" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;ul&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;role&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;listbox&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;aria-activedescendant&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-active-menuitem&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;style&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;z-index&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;1&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;top&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;29.88888931274414px&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;left&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;8.88888931274414px&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;display&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;none&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;width&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;136.78472208976746px&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;li&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-menu-item&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;role&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;menuitem&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;a&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-corner-all&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;tabindex&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;-1&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;ActionScript&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;a&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;li&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;li&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-menu-item&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;role&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;menuitem&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;a&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-corner-all&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;tabindex&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;-1&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;AppleScript&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;a&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;li&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;li&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-menu-item&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;role&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;menuitem&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;a&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-corner-all&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;tabindex&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;-1&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;Asp&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;a&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;li&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;li&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-menu-item&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;role&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;menuitem&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;a&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;ui-corner-all&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; &lt;/span&gt;&lt;span style="background:#ffffff;color:#ff0000"&gt;tabindex&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;=&amp;quot;-1&amp;quot;&amp;gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;BASIC&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;a&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;li&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="background:#ffffff;color:#800000"&gt;ul&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;To add CSS to the application simply drag Content/themes/base/jQuery-Ui.css above the &amp;lt;script&amp;gt; in &amp;lt;head&amp;gt;. When developing a real application you should use just the css that you need, in this case we could have just used Content\themes\base\jquery.ui.autocomplete.css. &lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;u&gt;Note:&lt;/u&gt; There are tools that analyze your page and give it a score that test you among other things on your CSS usage. For example &lt;a href="http://validator.w3.org/" target="_blank"&gt;W3C Validation Service&lt;/a&gt; checks for markup validity and &lt;/em&gt;&lt;a href="https://github.com/geuis/helium-css" target="_blank"&gt;&lt;em&gt;helium-css&lt;/em&gt;&lt;/a&gt;&lt;em&gt; tests for unused CSS classes.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;When using the AutoComplete we only used the source property, but there are others which can be viewed at the &lt;a href="http://api.jqueryui.com/autocomplete/" target="_blank"&gt;documentation&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;If we wanted an event such as &lt;a href="http://api.jqueryui.com/autocomplete/#event-search" target="_blank"&gt;search&lt;/a&gt;:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d19561c9-68e9-4b98-bd85-6ac956bbf8b3" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;$(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;#txtCustomer&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;).autocomplete({&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;source: customers,&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;search: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (event, ui) {&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;alert(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Go&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;);&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;We can also interfere with the regular function by &lt;a href="http://api.jquery.com/event.isDefaultPrevented/" target="_blank"&gt;changing the event&lt;/a&gt; (for example if we don’t want to allow the user to search for a certain term):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6a27468b-4e16-49f0-913e-a884a678199b" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;$(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;#txtCustomer&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;).autocomplete({&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;source: customers,&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;search: &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; (event, ui) {&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;event.isDefaultPrevented = &lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;true&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;}&lt;/span&gt;&lt;br&gt; &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;In the &lt;a href="http://api.jqueryui.com/autocomplete/#option-source" target="_blank"&gt;source parameter&lt;/a&gt; you can pass:&lt;/p&gt; &lt;li&gt;an array of values: [ "Choice1", "Choice2" ]  &lt;li&gt;an array of objects with value+label pairs: [ { label: "Choice1", value: "value1" }, ... ]  &lt;li&gt;a string url to a service with a parameter of term: SomeUrl?term=X that return an array of values or an array of objects with value+label pairs &lt;li&gt;a function that returns the data  &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;So using the JSON action we already defined (how lucky was that &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://lh4.ggpht.com/-0IDaf83FCB0/USttrIj03eI/AAAAAAAACL8/CWxUQEVpTWo/wlEmoticon-smile%25255B2%25255D.png?imgmax=800"&gt;):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c3b5b379-c6e1-449a-bf06-aeb9b72c9dc5" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="background:#ffffff;color:#000000"&gt;$(&lt;/span&gt;&lt;span style="background:#ffffff;color:#0000ff"&gt;function&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt; () {&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;$(&lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;#txtCustomer&amp;quot;&lt;/span&gt;&lt;span style="background:#ffffff;color:#000000"&gt;).autocomplete({&lt;/span&gt;&lt;br&gt;         &lt;span style="background:#ffffff;color:#000000"&gt;source: &lt;/span&gt;&lt;span style="background:#ffffff;color:#a31515"&gt;&amp;quot;Customer/GetCustomers&amp;quot;&lt;/span&gt;&lt;br&gt;     &lt;span style="background:#ffffff;color:#000000"&gt;});&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;And the end result:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-zkefbLyXVLc/USttrlInh-I/AAAAAAAACME/9tlQPDSKNmQ/s1600-h/jQueryUiAutoCompleteResult%25255B5%25255D.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="jQueryUiAutoCompleteResult" border="0" alt="jQueryUiAutoCompleteResult" src="http://lh5.ggpht.com/-IkreQ6x99Xo/USttsDFBYoI/AAAAAAAACMM/4nqVKUqNpYc/jQueryUiAutoCompleteResult_thumb%25255B2%25255D.png?imgmax=800" width="193" height="195"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Homework:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;1. Use a Textbox AutoComplete with a JSON method that returns an array of objects with value+label pairs&lt;/p&gt; &lt;p&gt;2. Textbox with AutoComplete with select event that goes to the server and gets data. Then put that control in the existing view.&lt;/p&gt; &lt;p&gt;3. Two Controllers with a hierarchy: Customer and Orders. Form Order add AutoComplete against Customer.&lt;/p&gt; &lt;p&gt;4. From Customer add AutoComplete of Orders with select event that opens the Customer&lt;/p&gt;&lt;/li&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=FFZpiccU3g4:EIeFqNgVNlY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/FFZpiccU3g4" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/7187448160702759152?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/7187448160702759152?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/FFZpiccU3g4/html5mvc-course-day-2.html" title="HTML5+MVC Course, Day 2" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-o1Ewe0qaaRE/USttQIYwoLI/AAAAAAAACHk/-YHJ6lnmJPg/s72-c/CreateEmptyMvcProject_thumb%25255B4%25255D.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2013/02/html5mvc-course-day-2.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0YCSHw7eCp7ImA9WhBSEks.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-6489368112207655475</id><published>2013-02-19T02:19:00.000-08:00</published><updated>2013-02-19T02:19:29.200-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-19T02:19:29.200-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ESRI Silverlight API" /><title>ESRI Silverlight MapTip</title><content type="html">&lt;p&gt;Today, while working on a sever bug I have checked to see if the bug doesn’t occur in our Silverlight application as well – it doesn’t. But unfortunately (for me) I found another bug: our MapTip didn’t display some of the components names. After fixing the bug in the server I decided to go after the Silverlight one.&lt;/p&gt; &lt;p&gt;On our previous version our name field was named Name but we had another field named NameEng (for the English name). The MapTip simply displayed the Name field to all elements. On our current version we ported our DB to Oracle and decided to have standardized names such as LOCAL_NAME (previously Name) and NAME (previously NameEng). Hence the problem those component without their name just don’t have a field named LOCAL_NAME – and for some strange reason ESRI doesn’t throw an exception of missing key.&lt;/p&gt; &lt;p&gt;Well I tried searching the web but apparently the feature of a fallback value if the first value is null was &lt;a href="http://stackoverflow.com/a/7392688/262099" target="_blank"&gt;only implemented in WPF&lt;/a&gt;. I have tried using TargetNullValue (crossing my fingers):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6bb85e10-6018-47c6-a720-0ef2c2e94e0e" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt; [LOCAL_NAME],&lt;/span&gt;&lt;span style="color:#ff0000"&gt; TargetNullValue&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=[NAME]}&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;11&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;SemiBold&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;But that just printed [NAME]. I have also tried to use {Binding [NAME]} but that just threw an exception.&lt;/p&gt; &lt;p&gt;I couldn’t change the View Model because the ESRI MapTip works on an inner object in ESRI (which I later found out is an internal sealed class) so adding something like:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e5e4c6bd-fdb5-49e0-9046-8d70df5e434e" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt; [LOCAL_NAME]}&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Visibility&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; IsLocal}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;11&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;SemiBold&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt; [NAME]}&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Visibility&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; IsNotLocal}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;11&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;SemiBold&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;was out.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;As I see it I had two options:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;1. Create a NullToVisibilityConvertor and a NotNullToVisibilityConvertor that when the value is null hides the TextBlock.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bbefc31c-6e49-42ac-86e2-2017fac556fa" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;NullToVisibilityConverter&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;IValueConverter&lt;/span&gt;&lt;br&gt; {&lt;br&gt;     &lt;span style="color:#0000ff"&gt;#region&lt;/span&gt; IValueConverter Members&lt;br&gt; &lt;br&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; Convert(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; value, &lt;span style="color:#2b91af"&gt;Type&lt;/span&gt; targetType, &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; parameter, &lt;span style="color:#2b91af"&gt;CultureInfo&lt;/span&gt; culture)&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; value == &lt;span style="color:#0000ff"&gt;null&lt;/span&gt; ? &lt;span style="color:#2b91af"&gt;Visibility&lt;/span&gt;.Collapsed : &lt;span style="color:#2b91af"&gt;Visibility&lt;/span&gt;.Visible;&lt;br&gt;     }&lt;br&gt; &lt;br&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; ConvertBack(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; value, &lt;span style="color:#2b91af"&gt;Type&lt;/span&gt; targetType, &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; parameter, &lt;span style="color:#2b91af"&gt;CultureInfo&lt;/span&gt; culture)&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;;&lt;br&gt;     }&lt;br&gt;     &lt;span style="color:#0000ff"&gt;#endregion&lt;/span&gt;&lt;br&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;(the opposite for NotNullToVisibilityConvertor)&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:be3bcea7-fe18-4845-8745-23b4c1a4a04d" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt; [LOCAL_NAME]}&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Visibility&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt; [LOCAL_NAME],&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Converter&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#a31515"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; NullToVisibilityConverter}}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;11&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;SemiBold&amp;quot;/&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt; [NAME]}&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Visibility&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt; [LOCAL_NAME],&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Converter&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#a31515"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; NotNullToVisibilityConverter}}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;11&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;SemiBold&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;2. Create a Convertor that if one value is null returns the other.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;I first tried to use the ConvertorParameter to pass the second value but that came out as simple text. So I have decided to pass the two fields I needed as the ConvertorParameter ('LOCAL_NAME,NAME') and the ESRI class as the binding value:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5f5fcab7-83e0-491f-8f08-941cdfa2aea0" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBlock&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt; .,&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Converter&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#a31515"&gt;StaticResource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; DictionaryValuePickerConverter}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;,&lt;/span&gt;&lt;span style="color:#ff0000"&gt; ConverterParameter&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;#39;LOCAL_NAME,NAME&amp;#39;}&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontSize&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;11&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; FontWeight&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;SemiBold&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Now what I found (through Debugging and &lt;a href="http://www.jetbrains.com/decompiler/" target="_blank"&gt;JetBrains dotPeek&lt;/a&gt;) is that though ESRI passes an internal sealed class named ObservableDictionary (and I cannot cast to it in my convertor) that class implements IDictionary&amp;lt;string, object&amp;gt; so I can just cast the value to that:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2dd2977c-a737-4cc9-b43c-2d2ac33d7218" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;DictionaryValuePickerConverter&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;IValueConverter&lt;/span&gt;&lt;br&gt; {&lt;br&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; Convert(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; value, &lt;span style="color:#2b91af"&gt;Type&lt;/span&gt; targetType, &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; parameter, &lt;span style="color:#2b91af"&gt;CultureInfo&lt;/span&gt; culture)&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; dictionary = value &lt;span style="color:#0000ff"&gt;as&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IDictionary&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;object&lt;/span&gt;&amp;gt;;&lt;br&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; stringPrameters = parameter &lt;span style="color:#0000ff"&gt;as&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;;&lt;br&gt; &lt;br&gt;         &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (dictionary == &lt;span style="color:#0000ff"&gt;null&lt;/span&gt; || stringPrameters == &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;)&lt;br&gt;         {&lt;br&gt;             &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#2b91af"&gt;String&lt;/span&gt;.Empty;&lt;br&gt;         }&lt;br&gt;         &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; parameters = stringPrameters.Split(&lt;span style="color:#a31515"&gt;&amp;quot;,&amp;quot;&lt;/span&gt;.ToCharArray());&lt;br&gt; &lt;br&gt;         &lt;span style="color:#0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; key &lt;span style="color:#0000ff"&gt;in&lt;/span&gt; parameters)&lt;br&gt;         {&lt;br&gt;             &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (dictionary.ContainsKey(key))&lt;br&gt;                 &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; dictionary[key];&lt;br&gt;         }&lt;br&gt;         &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#2b91af"&gt;String&lt;/span&gt;.Empty;&lt;br&gt;     }&lt;br&gt; &lt;br&gt;     &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; ConvertBack(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; value, &lt;span style="color:#2b91af"&gt;Type&lt;/span&gt; targetType, &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; parameter, &lt;span style="color:#2b91af"&gt;CultureInfo&lt;/span&gt; culture)&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#00008b"&gt;NotImplementedException&lt;/span&gt;();&lt;br&gt;     }&lt;br&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I actually hate both options and had to ask my team leader what he thought. At the end we decided to go with option 2, if somewhere down the line we will need (&lt;em&gt;and God help us if we do&lt;/em&gt;) another fallback name field we can just add another using “,YET_ANOTHER_NAME” and it will work…&lt;/p&gt; &lt;p&gt;I hope no one needs this…&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=jAU5-NngZ3I:sX2Ta9Zexaw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/jAU5-NngZ3I" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6489368112207655475?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6489368112207655475?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/jAU5-NngZ3I/esri-silverlight-tooltip.html" title="ESRI Silverlight MapTip" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><feedburner:origLink>http://www.dllshepherd.net/2013/02/esri-silverlight-tooltip.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYMQXozeSp7ImA9WhBSEU8.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-6238130140239382146</id><published>2013-02-17T10:03:00.001-08:00</published><updated>2013-02-17T10:03:00.481-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-17T10:03:00.481-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JavaScript" /><title>HTML5+MVC Course, Day 1</title><content type="html">&lt;p&gt;My company is having a HTML5 and MVC course by &lt;a href="http://e4d.co.il/" target="_blank"&gt;E4D&lt;/a&gt;. As is my habit I like to write things down – for review and prosperity…&lt;/p&gt; &lt;p&gt;The course is presented by &lt;a href="http://blogs.microsoft.co.il/Blogs/yairs/" target="_blank"&gt;Yair Siwek&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The first day was more an overview on HTML5, JavaScript and quick uses of jQuery.&lt;/p&gt; &lt;h3&gt;Overview&lt;/h3&gt; &lt;p&gt;The course started with an overview about what we are going to go over:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-ZMsEVBLlm_U/USEbPanVW3I/AAAAAAAACA4/v6PHcktmEZs/s1600-h/Html5MvcCourseOverview8.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="Html5MvcCourseOverview" border="0" alt="Html5MvcCourseOverview" src="http://lh3.ggpht.com/-cX2rmg75tco/USEbQITlRpI/AAAAAAAACBA/qZHLasnoBDM/Html5MvcCourseOverview_thumb5.png?imgmax=800" width="644" height="285"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;JavaScript is the language we use in the Browser, it advantage is in the fact that it is text so it passes the Firewall. Firewalls hate everyone, but text somehow passes… &lt;/p&gt; &lt;p&gt;JavaScript gives events on: the DOM, button click, data loaded, etc.&lt;/p&gt; &lt;p&gt;But it’s script that might cause Memory Leaks.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jquery.com/" target="_blank"&gt;jQuery&lt;/a&gt; is a JavaScript library that started as a simple selector library to search for elements in the DOM tree. Then you can change those elements: text, CSS classes, events, etc. A lot of inline code, anonymous types/functions.&lt;/p&gt; &lt;p&gt;&lt;a href="http://jqueryui.com/" target="_blank"&gt;jQueryUI&lt;/a&gt; is a JavaScript library that uses jQuery as it’s base and adds gadget code like AutoComplete text box, calendar, tabs, accordion, drag &amp;amp; drop, etc. &lt;/p&gt; &lt;p&gt;The problem in jQueryUI is that the process of creating a new control is very long (gets out once per year), so other people started creating &lt;a href="http://plugins.jquery.com/" target="_blank"&gt;open source plugins&lt;/a&gt; in &lt;a href="https://github.com/jquery/plugins.jquery.com" target="_blank"&gt;GitHub&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;a href="http://knockoutjs.com/" target="_blank"&gt;Knockout&lt;/a&gt; is a MVVM framework for JavaScript. There are other frameworks that are better for other usages (such as &lt;a href="http://documentcloud.github.com/backbone/" target="_blank"&gt;Backbone&lt;/a&gt;, &lt;a href="http://angularjs.org/" target="_blank"&gt;Angular&lt;/a&gt;, &lt;a href="http://emberjs.com/" target="_blank"&gt;Ember&lt;/a&gt;…).&lt;/p&gt; &lt;p&gt;The mobile world is different. For example in Facebook they have a Java (Android) team, Objective C (IOS) team and HTML5 for all the rest.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Tools:&lt;/h5&gt; &lt;p&gt;Visual Studio 2012 – has intellisense for HTML5&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;With NuGet installed: insures all the dependencies and references are working together. Can be set so that the source of the files sits inside the organization.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Browsers: Chrome, Firefox, IE9&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;MVC&lt;/h5&gt; &lt;p&gt;MVC = Model View Controller&lt;/p&gt; &lt;p&gt;The course is going to use Controller and (maybe) Model from MVC and the view in the client will be receiving JSON data from MVC.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h5&gt;Why not use WCF?&lt;/h5&gt; &lt;p&gt;WCF uses SOAP which include a lot of metadata in the header (like security, transaction, reliable messaging, etc. ).&lt;/p&gt; &lt;p&gt;The browsers allow xml of type POX (Plain Old Xml) but not SOAP.&lt;/p&gt; &lt;p&gt;Microsoft implemented WCF-Ajax that returns JSON but that causes Cross Side Scripting problems. There is a pipeline in WCF that in the end cuts all the data to JSON – you are doing a lot of work but in the end just take a pips of the data. JSONP solved the problem but not all the controls know how to work with it.&lt;/p&gt; &lt;p&gt;The final point: it’s too much work when MVC is so much simpler.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h3&gt;HTML games&lt;/h3&gt; &lt;p&gt;Open a new ASP.NET MVC4 project&lt;/p&gt; &lt;p&gt;Open a new HTML page&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:56625d6f-bff0-4582-8ab1-10934f1f9737" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="color:#800000"&gt;DOCTYPE&lt;/span&gt; &lt;span style="color:#ff0000"&gt;html&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The tag means this is HTML5&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:aee33c1e-551e-4950-ba82-18c476527a2c" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;html&lt;/span&gt; &lt;span style="color:#ff0000"&gt;lang&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;en&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Can be and should be cleaned up to just &amp;lt;html&amp;gt;.  &lt;p&gt;In Chrome – F12 for Developer Tools, the best tool to play with the HTML and CSS of the page.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-q5VtcICFKQg/USEbQgULEaI/AAAAAAAACBI/bDqcuV4V0OE/s1600-h/ChromeDeveloperToolsStyles8.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="ChromeDeveloperToolsStyles" border="0" alt="ChromeDeveloperToolsStyles" src="http://lh6.ggpht.com/-SISdrn5pdhg/USEbRGVoyOI/AAAAAAAACBQ/WimiTr00YWs/ChromeDeveloperToolsStyles_thumb5.png?imgmax=800" width="285" height="289"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Under Styles are the CSS values we specified in the page.&lt;/p&gt; &lt;p&gt;Under Computed Style are the actual values in the browser.&lt;/p&gt; &lt;p&gt;For example: font-size: 1.5em is 1.5 of the default font size in the operating system, but in the browser that value means 24px.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;Options of writing styles:&lt;/h4&gt; &lt;h5&gt;1. inline&lt;/h5&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0da89494-3d27-4507-a3d9-a63354c56693" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;p&lt;/span&gt; &lt;span style="color:#ff0000"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt;font-family&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:Aharoni&amp;quot;&amp;gt;&lt;/span&gt;Bad inline: Hello World2&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;p&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;h5&gt;2. header&lt;/h5&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ec2f9af9-6d7e-4e14-a77d-8265ef3d311d" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;head&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="color:#800000"&gt;.MyClass1&lt;/span&gt;&lt;br&gt;         {&lt;br&gt;             &lt;span style="color:#ff0000"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;gray&lt;/span&gt;;&lt;br&gt;             &lt;span style="color:#ff0000"&gt;color&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;white&lt;/span&gt;;&lt;br&gt;             &lt;span style="color:#ff0000"&gt;font-size&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;1.5em&lt;/span&gt;&lt;br&gt;         }&lt;br&gt;         &lt;br&gt;         &lt;span style="color:#800000"&gt;p.MyClass1&lt;/span&gt;&lt;br&gt;         {&lt;br&gt;             &lt;span style="color:#ff0000"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;gray&lt;/span&gt;;&lt;br&gt;             &lt;span style="color:#ff0000"&gt;color&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;yellow&lt;/span&gt;;&lt;br&gt;             &lt;span style="color:#ff0000"&gt;font-size&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;1.5em&lt;/span&gt;&lt;br&gt;         }        &lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;head&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9cbf3b8b-6d4e-4b08-a033-deb08cb16979" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;MyClass1&amp;quot;&amp;gt;&lt;/span&gt;I am div 1&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Got the class MyClass1&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:addbe09b-f4eb-4766-b24c-988bb88b8eca" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;p&lt;/span&gt; &lt;span style="color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;MyClass1&amp;quot;&amp;gt;&lt;/span&gt;Hello World1&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;p&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Got the class p.MyClass1. Because it was explicitly created for &amp;lt;p&amp;gt; tags it is stronger than just MyClass1.&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:06c3a448-33eb-4886-89a6-8b25054616a5" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;p&lt;/span&gt; &lt;span style="color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;MyClass1 MyClass2&amp;quot;&amp;gt;&lt;/span&gt;Hello World3&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;p&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Got both MyClass1 and MyClass2 styles.&lt;/p&gt; &lt;p&gt;&lt;u&gt;ID specific styles&lt;/u&gt;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a8a3667f-6e8f-47b7-9d66-c669bb638b93" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#800000"&gt;#pId&lt;/span&gt;&lt;br&gt; {&lt;br&gt;     &lt;span style="color:#ff0000"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;maroon&lt;/span&gt;&lt;br&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Only relevant for the tag with the id pId:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:49b91635-519b-4252-9834-b04e5c6f5e2e" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;p&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;pId&amp;quot;&amp;gt;&lt;/span&gt;pId&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;p&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;h5&gt;3. Style for outside CSS file:&lt;/h5&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a378c668-d794-4821-814e-b9ef372e4862" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;head&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;link&lt;/span&gt; &lt;span style="color:#ff0000"&gt;href&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;Application.css&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000"&gt;rel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;stylesheet&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;head&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Using it is the same as using header styles.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Rule: &lt;/u&gt;&lt;/strong&gt;inline style is stronger than header style who in turn stronger than an outside CSS file.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;Solution order conventions:&lt;/h4&gt; &lt;p&gt;Content folder for application styles.&lt;/p&gt; &lt;p&gt;Scripts folder already contains NuGet scripts.&lt;/p&gt; &lt;p&gt;Scripts\App folder for application scripts&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;Demo Core JavaScript: Playing with the Page’s Layout&lt;/h4&gt; &lt;p&gt;From 3 DIVs &lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7f0e1487-c8e9-437e-87c6-1598273fa5b6" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;body&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;Div1&amp;quot;&amp;gt;&lt;/span&gt;header&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;Div2&amp;quot;&amp;gt;&lt;/span&gt;left&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;Div3&amp;quot;&amp;gt;&lt;/span&gt;main&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;body&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;To (just using styles):&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-FLhWaqSqiDs/USEbRzS0_NI/AAAAAAAACBY/on6zHzQbLNQ/s1600-h/HtmlCourseDemoExerciseLayout7.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="HtmlCourseDemoExerciseLayout" border="0" alt="HtmlCourseDemoExerciseLayout" src="http://lh3.ggpht.com/-Iju2HOjJsdI/USEbSdwYoaI/AAAAAAAACBg/zRA4cE0WKk8/HtmlCourseDemoExerciseLayout_thumb4.png?imgmax=800" width="408" height="373"&gt;&lt;/a&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;No white in the margins only have the 3 colors.  &lt;li&gt;Header should be 40px in height  &lt;li&gt;Left should be 20% of the width and Main should be the other 80%  &lt;li&gt;Left and Main should have all the rest of the screen&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;The next step is for the Header and the Left not to move when scrolling.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;In Chrome the body tag has a default margin of 8px, to have no white in the page we need to change that to a margin of 0px. In other browsers the defaults might be different. &lt;/p&gt; &lt;p&gt;To make Main be on the right of left and not be a line below it we need to use the float style.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The end result is:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:03590525-9b1f-4dd4-9c13-0ec5e4abb042" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#800000"&gt;body&lt;/span&gt;&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#ff0000"&gt;margin&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;0px&lt;/span&gt;; &lt;br&gt;     }&lt;br&gt;     &lt;span style="color:#800000"&gt;#Div1&lt;/span&gt;&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#ff0000"&gt;background-color&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;green&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;height&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;40px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;width&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;100%&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;float&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;left&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;position&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;fixed&lt;/span&gt;;&lt;br&gt;     }&lt;br&gt;     &lt;span style="color:#800000"&gt;#Div2&lt;/span&gt;&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#ff0000"&gt;background-color&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;blue&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;width&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;20%&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;float&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;left&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;position&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;fixed&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;top&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;40px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;height&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;100%&lt;/span&gt;;&lt;br&gt;     }&lt;br&gt;     &lt;span style="color:#800000"&gt;#Div3&lt;/span&gt;&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#ff0000"&gt;background-color&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;orange&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;width&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;80%&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;float&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;left&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;left&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;20%&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;top&lt;/span&gt;:  &lt;span style="color:#0000ff"&gt;40px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;position&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;fixed&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;height&lt;/span&gt;: &lt;span style="color:#0000ff"&gt;100%&lt;/span&gt;&lt;br&gt;     }&lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-IaLRYvhk5-c/USEbSwbx6FI/AAAAAAAACBo/RHb3lN0A8bI/s1600-h/HtmlCourseDemoLayoutResult7.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="HtmlCourseDemoLayoutResult" border="0" alt="HtmlCourseDemoLayoutResult" src="http://lh4.ggpht.com/-wreLQreZXto/USEbThZASfI/AAAAAAAACBw/hzd92AZizCA/HtmlCourseDemoLayoutResult_thumb4.png?imgmax=800" width="410" height="298"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h4&gt;&amp;nbsp;&lt;/h4&gt; &lt;h4&gt;Demo in Core JavaScript: playing with z-index&lt;/h4&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d8185141-d979-498c-8ba5-d8ee620495ba" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#800000"&gt;#div1&lt;/span&gt;&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#ff0000"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;red&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;width&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;200px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;height&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;100px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;position&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;absolute&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;top&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;50px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;left&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;50px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;z-index&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;101&lt;/span&gt;;&lt;br&gt;     }&lt;br&gt;     &lt;span style="color:#800000"&gt;#div2&lt;/span&gt;&lt;br&gt;     {&lt;br&gt;         &lt;span style="color:#ff0000"&gt;background-color&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;blue&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;width&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;200px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;height&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;100px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;position&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;absolute&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;top&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;100px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;left&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;100px&lt;/span&gt;;&lt;br&gt;         &lt;span style="color:#ff0000"&gt;z-index&lt;/span&gt;:&lt;span style="color:#0000ff"&gt;102&lt;/span&gt;;&lt;br&gt;     }&lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;style&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ca4b7901-609e-42c7-a28d-f260c9ace41f" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;div1&amp;quot;&amp;gt;&lt;/span&gt;div1&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;div2&amp;quot;&amp;gt;&lt;/span&gt;div2&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-XkyKBp2URKQ/USEbUFeBDBI/AAAAAAAACB4/a0tZRH94kcg/s1600-h/HtmlCourseZIndexDemo7.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="HtmlCourseZIndexDemo" border="0" alt="HtmlCourseZIndexDemo" src="http://lh5.ggpht.com/-P17FB9iUYPE/USEbUo6ZeNI/AAAAAAAACCA/IZ5-DYW0_sA/HtmlCourseZIndexDemo_thumb4.png?imgmax=800" width="425" height="264"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;One DIV is above the other, events such as on click for div2 will not fire when clicked on the area that div1 takes.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;If we want to change the z-index on click then we have several options of writing methods:&lt;/p&gt; &lt;p&gt;1. The simplest option:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ed0250f2-7479-4454-88af-dc73cd93235e" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#ff0000"&gt;onclick&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;Div2_OnClick()&amp;quot;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;2. For if we want to escape the function with return false:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:556be595-aeea-4b4b-8072-b9cebb256c9d" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#ff0000"&gt;onclick&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;return Div1_OnClick()&amp;quot;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;3. With a timer (only mentioned not shown)&lt;/p&gt; &lt;p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The script Tag should be after the the style tag if you want to use styles in the script.&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:29e71132-d151-4080-91fb-ed87014a94aa" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;script&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;function&lt;/span&gt; WindowOnLoad() {&lt;br&gt;         &lt;span style="color:#006400"&gt;//div1. - Might not work in all browsers &lt;/span&gt;&lt;br&gt;         &lt;span style="color:#006400"&gt;//should have been:&lt;/span&gt;&lt;br&gt;         &lt;span style="color:#006400"&gt;//document.getElementById(&amp;quot;div1&amp;quot;).style.zIndex = 102;&lt;/span&gt;&lt;br&gt;         &lt;span style="color:#006400"&gt;//because its cross browsers&lt;/span&gt;&lt;br&gt;         div1.style.zIndex = 102;&lt;br&gt;         div2.style.zIndex = 101;&lt;br&gt;     }&lt;br&gt; &lt;br&gt;     &lt;span style="color:#0000ff"&gt;function&lt;/span&gt; Div1_OnClick() {&lt;br&gt;         div1.style.zIndex = 102;&lt;br&gt;         div2.style.zIndex = 101;&lt;br&gt;     }&lt;br&gt;     &lt;span style="color:#0000ff"&gt;function&lt;/span&gt; Div2_OnClick() {&lt;br&gt;         div2.style.zIndex = 102;&lt;br&gt;         div1.style.zIndex = 101;&lt;br&gt;     }&lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;script&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d2c57ace-b4eb-4dda-b0ca-b92e3496c450" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;body&lt;/span&gt; &lt;span style="color:#ff0000"&gt;onload&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;WindowOnLoad()&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;div1&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000"&gt;onclick&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;return Div1_OnClick()&amp;quot;&amp;gt;&lt;/span&gt;div1&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;div2&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000"&gt;onclick&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;Div2_OnClick()&amp;quot;&amp;gt;&lt;/span&gt;div2&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The setting of the zIndex in the WindowOnLoad method is an alternative way to set the styles but should &lt;strong&gt;not&lt;/strong&gt; be used. The body onload will only fire when all the page loads – that includes downloading all the images.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;Demo Hello jQuery&lt;/h4&gt; &lt;p&gt;Showing manipulation of the following HTML:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1d8c820a-5a10-4c0e-9e83-9ec71be6f378" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;body&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;button&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;btn1&amp;quot;&amp;gt;&lt;/span&gt;Click me&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;button&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;MyClass&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;div1&amp;quot;&amp;gt;&lt;/span&gt;this is div1&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;div2&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;         this is div2&lt;br&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;MyClass&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;div3&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;             this is div3&lt;br&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt; &lt;span style="color:#ff0000"&gt;class&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;MyClass&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;div4&amp;quot;&amp;gt;&lt;/span&gt;&lt;br&gt;             this is div4&lt;br&gt;         &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;div&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt; &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;body&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Adding the jQuery library by drag and drop from the Scripts folder to the &amp;lt;head&amp;gt; tag (after getting it from NuGet or from the &lt;a href="http://jquery.com/" target="_blank"&gt;jQuery site&lt;/a&gt;), or by writing:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a16068da-cb7a-4e6f-9ce2-3eacde70e06d" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;script&lt;/span&gt; &lt;span style="color:#ff0000"&gt;src&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;Scripts/jquery-1.9.1.js&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000"&gt;script&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;When working with jQuery you have the option of working with:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;The min version (jquery-#.#.#.min.js) which weights a lot less, has no documentation and better performance.  &lt;li&gt;The regular version (jquery-#.#.#.js) which has documentation and is generally better for debug.  &lt;li&gt;The intellisense version (jquery-#.#.#.intellisense.js) for people working with the min version , they can add intellisense using this file (if you are working with the regular version you don’t need the intellisense version).&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;jQuery has several selector options (i.e. $() ):&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Using object: $(document) returns the DOM object  &lt;li&gt;Tag name: $(‘div’) selects all the DIV tags  &lt;li&gt;Tag ID: $'(‘#Tag_Id’) selects the tag that has the Id Tag_Id  &lt;li&gt;Tag Class: $(‘.Tag_Class’) selects all the tags that use the class Tag_Class&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;There are more selectors which can be read &lt;a href="http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;jQuery has an event for OnLoad minus, for when the DOM has loaded but the images haven’t:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:90253094-4d0b-4fcb-9675-c9cfb8a02a7b" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000"&gt;script&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;     $(document).ready(&lt;span style="color:#0000ff"&gt;function&lt;/span&gt;() {&lt;br&gt;         alert(&lt;span style="color:#800000"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;); &lt;span style="color:#006400"&gt;//Will jump before images&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;All the operation in jQuery are done with functions. The event ready receive an anonymous function that does the action (you can also write a regular JavaScript function but it is usually done with Anonymous types):&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Set the value into html:&lt;/li&gt;&lt;/ul&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:568907f9-e716-422a-be55-670997970335" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;$(&lt;span style="color:#800000"&gt;&amp;quot;#div3&amp;quot;&lt;/span&gt;).html(&lt;span style="color:#800000"&gt;&amp;quot;can you see me?&amp;quot;&lt;/span&gt;)&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;ul&gt; &lt;li&gt;Returns the html text:&lt;/li&gt;&lt;/ul&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:eaadb7df-18b8-4e7b-a336-8c4b67cf1e2f" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;$(&lt;span style="color:#800000"&gt;&amp;quot;#div3&amp;quot;&lt;/span&gt;).html()&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The previous example of:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:31c3f63f-47bc-4d33-989b-ac77e7c274e5" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;div1.style.zIndex = 102;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Is bad code because it might not work in all browsers, the right code should be:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:81a0b73b-60c1-4d9b-9c9c-47b234208d21" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;document.getElementById(&lt;span style="color:#800000"&gt;&amp;quot;div1&amp;quot;&lt;/span&gt;).style.zIndex = 102;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;In jQuery we can simply do $(“div1”) and it will work in all browsers because jQuery insures it. &lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2fd1d2e1-a0b1-40ff-a483-3d8c626de255" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#006400"&gt;//bad code (will go over the tree a few times to get div3):&lt;/span&gt;&lt;br&gt; $(&lt;span style="color:#800000"&gt;&amp;quot;#div3&amp;quot;&lt;/span&gt;).addClass(&lt;span style="color:#800000"&gt;&amp;quot;redStyle&amp;quot;&lt;/span&gt;);&lt;br&gt; $(&lt;span style="color:#800000"&gt;&amp;quot;#div3&amp;quot;&lt;/span&gt;).html(&lt;span style="color:#800000"&gt;&amp;quot;can you see me?&amp;quot;&lt;/span&gt;);&lt;br&gt; alert($(&lt;span style="color:#800000"&gt;&amp;quot;#div3&amp;quot;&lt;/span&gt;).html());&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;If you open debugger and step into all the $(“#div3”) you will see that jQuery iterates through the DOM tree for each call of $(“#div3”) and after each action returns the original selection (i.e. Fluent Interface). &lt;/p&gt; &lt;p&gt;The good ways:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Using a temporary variable:&lt;/li&gt;&lt;/ul&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:303e57a3-caf9-4453-848a-3456e488932d" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; $div3 = $(&lt;span style="color:#800000"&gt;&amp;quot;#div3&amp;quot;&lt;/span&gt;);&lt;br&gt; $div3.addClass(&lt;span style="color:#800000"&gt;&amp;quot;redStyle&amp;quot;&lt;/span&gt;);&lt;br&gt; $div3.html(&lt;span style="color:#800000"&gt;&amp;quot;can you see me?&amp;quot;&lt;/span&gt;);&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Using the variable name $div3 is a jQuery convention of saying this variable is from jQuery.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Better way of doing everything inline:&lt;/li&gt;&lt;/ul&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e8080683-b12a-4b58-998c-9146a1117814" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;$(&lt;span style="color:#800000"&gt;&amp;quot;#div3&amp;quot;&lt;/span&gt;)&lt;br&gt;     .addClass(&lt;span style="color:#800000"&gt;&amp;quot;redStyle&amp;quot;&lt;/span&gt;)&lt;br&gt;     .html(&lt;span style="color:#800000"&gt;&amp;quot;can you see me?&amp;quot;&lt;/span&gt;);&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Demo – Change Class&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Register to the click event of the button so the class is changed on every click of div3:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a417166e-ddc5-4d09-baaa-a6474f869ffb" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;$(&lt;span style="color:#800000"&gt;&amp;quot;#btn1&amp;quot;&lt;/span&gt;).click(&lt;span style="color:#0000ff"&gt;function&lt;/span&gt;() {&lt;br&gt;     $(&lt;span style="color:#800000"&gt;&amp;quot;#div3&amp;quot;&lt;/span&gt;)&lt;br&gt;         .removeClass(&lt;span style="color:#800000"&gt;&amp;quot;redStyle&amp;quot;&lt;/span&gt;)&lt;br&gt;         .addClass(&lt;span style="color:#800000"&gt;&amp;quot;boldStyle&amp;quot;&lt;/span&gt;)&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;But on the next click nothing will happen, another option is using toggle (which uses the current state):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b186361c-401e-440c-8aef-eef641866005" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;$(&lt;span style="color:#800000"&gt;&amp;quot;#btn1&amp;quot;&lt;/span&gt;).click(&lt;span style="color:#0000ff"&gt;function&lt;/span&gt;() {&lt;br&gt;     $(&lt;span style="color:#800000"&gt;&amp;quot;#div3&amp;quot;&lt;/span&gt;)&lt;br&gt;         .toggleClass(&lt;span style="color:#800000"&gt;&amp;quot;boldStyle&amp;quot;&lt;/span&gt;)&lt;br&gt;         .toggleClass(&lt;span style="color:#800000"&gt;&amp;quot;redStyle&amp;quot;&lt;/span&gt;)&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Adding a style to a given class (if the class already contained a color than this definition will override it):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2aa56f76-6815-4104-9bc0-abdb9a6ad7f3" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;$(&lt;span style="color:#800000"&gt;&amp;quot;.MyClass&amp;quot;&lt;/span&gt;)&lt;br&gt;     .css(&lt;span style="color:#800000"&gt;&amp;quot;color&amp;quot;&lt;/span&gt;, &lt;span style="color:#800000"&gt;&amp;quot;red&amp;quot;&lt;/span&gt;);&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Hiding an element slowly and in the end change the text of the button to “Done”:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:dfc4658b-0391-4638-a0b2-d2f7f8fe1068" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;$(&lt;span style="color:#800000"&gt;&amp;quot;#div4&amp;quot;&lt;/span&gt;).toggle(&lt;span style="color:#800000"&gt;&amp;quot;slow&amp;quot;&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;function&lt;/span&gt;() {&lt;br&gt;     $(&lt;span style="color:#800000"&gt;&amp;quot;#btn1&amp;quot;&lt;/span&gt;).html(&lt;span style="color:#800000"&gt;&amp;quot;Done&amp;quot;&lt;/span&gt;);&lt;br&gt; });&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;jQuery behind the scenes changes the style of the display to none (and if clicked again to block).&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Multiple Selectors:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://api.jquery.com/multiple-selector/" target="_blank"&gt;Or&lt;/a&gt;:&lt;/li&gt;&lt;/ul&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3885e72c-1a28-4b71-9188-7f8659ede217" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;$(&lt;span style="color:#800000"&gt;&amp;quot;.MyClass, #div2&amp;quot;&lt;/span&gt;)&lt;br&gt;     .css(&lt;span style="color:#800000"&gt;&amp;quot;font-family&amp;quot;&lt;/span&gt;, &lt;span style="color:#800000"&gt;&amp;quot;serif&amp;quot;&lt;/span&gt;);&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;All the tags that their Id is div2 or have the class MyClass.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://api.jquery.com/descendant-selector/" target="_blank"&gt;Ancestor descendant&lt;/a&gt;:&lt;/li&gt;&lt;/ul&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:65c8894c-94ac-43bd-ae0f-d81b0514eda4" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;$(&lt;span style="color:#800000"&gt;&amp;quot;#div2 .MyClass&amp;quot;&lt;/span&gt;)&lt;br&gt;     .css(&lt;span style="color:#800000"&gt;&amp;quot;color&amp;quot;&lt;/span&gt;, &lt;span style="color:#800000"&gt;&amp;quot;blue&amp;quot;&lt;/span&gt;);&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;All the tags that their ancestor is div2 and have the class MyClass.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://stackoverflow.com/questions/1041344/jquery-multiple-class-selector" target="_blank"&gt;And&lt;/a&gt;:&lt;/li&gt;&lt;/ul&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:441abcfb-9b9c-49d3-b521-7858ed5fe25a" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;$(&lt;span style="color:#800000"&gt;&amp;quot;.MyClass.redStyle&amp;quot;&lt;/span&gt;)&lt;br&gt;     .css(&lt;span style="color:#800000"&gt;&amp;quot;color&amp;quot;&lt;/span&gt;, &lt;span style="color:#800000"&gt;&amp;quot;purple&amp;quot;&lt;/span&gt;);&lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;All the tags that have the both class MyClass and redStyle.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://jquery.com/" target="_blank"&gt;jQuery&lt;/a&gt;, and &lt;a href="http://api.jquery.com/" target="_blank"&gt;API Documentation&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/" target="_blank"&gt;The 30 CSS Selectors you Must Memorize&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://jqfundamentals.com/" target="_blank"&gt;jQuery Fundamentals&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.w3schools.com/css3/default.asp" target="_blank"&gt;W3School CSS3&lt;/a&gt; – not very useful&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=VkOt7kp3ovI:UHVqyIpQeOE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/VkOt7kp3ovI" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6238130140239382146?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6238130140239382146?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/VkOt7kp3ovI/html5mvc-course-day-1.html" title="HTML5+MVC Course, Day 1" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-cX2rmg75tco/USEbQITlRpI/AAAAAAAACBA/qZHLasnoBDM/s72-c/Html5MvcCourseOverview_thumb5.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2013/02/html5mvc-course-day-1.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8NQnk4cCp7ImA9WhNRE0Q.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-4420915139364102044</id><published>2012-11-08T09:48:00.000-08:00</published><updated>2012-11-08T09:48:13.738-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-08T09:48:13.738-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="VS2010" /><category scheme="http://www.blogger.com/atom/ns#" term="Exception" /><title>VS2010: “The project type is not supported by this installation.”</title><content type="html">&lt;p&gt;Before I found the extension for Windows Live Writer – Paste as Visual Studio code I had (for 3 days) used &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/656f8df1-13ae-47b3-8f9a-89bf107c3b2a"&gt;Code4Blog&lt;/a&gt; Extension but I was dismayed by it’s &lt;a href="http://code4blog.codeplex.com/workitem/list/basic"&gt;bugs&lt;/a&gt; (I opened some of them). I had this draft lying around and decided to just post it because it seems many people suffer from this exception.&lt;/p&gt; &lt;p&gt;In the extension’s page the author wrote:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;“Code4Blog is now published on &lt;a href="http://code4blog.codeplex.com/"&gt;CodePlex&lt;/a&gt;. You are welcome to work with the source code directly!”&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;So I have decided to do just that.&lt;/p&gt; &lt;p&gt;Opening the solution I got the following error in the output window:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;C:\…\Code4Blog\Code4Blog\Code4Blog.csproj : &lt;/p&gt; &lt;p&gt;error&amp;nbsp; : The project file 'C:\…\Code4Blog\Code4Blog\Code4Blog.csproj' cannot be opened.&lt;/p&gt; &lt;p&gt;The project type is not supported by this installation.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_SU7V9sPwn1o/TSWazxAFwWI/AAAAAAAAAhE/OIVUb4IBIWs/s1600-h/image%5B2%5D.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://lh4.ggpht.com/_SU7V9sPwn1o/TSWa0Y2JyOI/AAAAAAAAAhI/ZqUkZ4ZLOiM/image_thumb.png?imgmax=800" width="262" height="111"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;So I kinda guessed it has to do with a project for extending VS. But why doesn’t VS2010 give me what project type is missing?&lt;/p&gt; &lt;p&gt;Looking inside the project file (good thing that the project was down &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://lh5.ggpht.com/_SU7V9sPwn1o/TSWa1EiD7JI/AAAAAAAAAhM/TG7m99HcxNk/wlEmoticon-winkingsmile%5B2%5D.png?imgmax=800"&gt;):&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_SU7V9sPwn1o/TSWa1v3RjxI/AAAAAAAAAhQ/04B_AI-8S5A/s1600-h/image%5B5%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 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://lh4.ggpht.com/_SU7V9sPwn1o/TSWa2nHENpI/AAAAAAAAAhU/QrhVt7cii6Q/image_thumb%5B1%5D.png?imgmax=800" width="369" height="158"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;I found the project type here:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_SU7V9sPwn1o/TSWa3FhNm3I/AAAAAAAAAhY/zXPeIwWoNGU/s1600-h/image%5B10%5D.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://lh5.ggpht.com/_SU7V9sPwn1o/TSWa4Du7q2I/AAAAAAAAAhc/fx8y8s1M-Zo/image_thumb%5B4%5D.png?imgmax=800" width="719" height="127"&gt;&lt;/a&gt;&lt;/p&gt;&lt;pre style="margin: 0em"&gt; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;span style="color: #a31515"&gt;ProjectTypeGuids&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #000000"&gt; &lt;span style="color: #000000"&gt;{&lt;/span&gt;82b43b9b-a64c-4715-b499-d71e9ca2bd60&lt;span style="color: #000000"&gt;}&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0em"&gt;&lt;span style="color: #0000ff"&gt;&lt;span style="color: #a31515"&gt;&lt;span style="color: #000000"&gt;                    &lt;span style="color: #000000"&gt;{&lt;/span&gt;60dc8134-eba5-43b8-bcc9-bb4bc16c2548&lt;span style="color: #000000"&gt;}&lt;/span&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0em"&gt;&lt;span style="color: #0000ff"&gt;&lt;span style="color: #a31515"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #0000ff"&gt;&lt;span style="color: #a31515"&gt;&lt;span style="color: #000000"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&lt;span style="color: #a31515"&gt;&lt;span style="color: #000000"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&lt;span style="color: #a31515"&gt;&lt;span style="color: #000000"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #000000"&gt;                    {&lt;/span&gt;FAE04EC0-301F-11D3-BF4B-00C04F79EFBC&lt;span style="color: #000000"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin: 0em"&gt;&lt;span style="color: #0000ff"&gt;&lt;span style="color: #a31515"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;span style="color: #a31515"&gt;ProjectTypeGuids&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;Searching for the first Guid on the list, I found &lt;a href="http://forums.silverlight.net/forums/p/170183/383386.aspx"&gt;this forum&lt;/a&gt;. From there I got to the &lt;a href="http://msdn.microsoft.com/en-us/vstudio/vextend"&gt;Extending Visual Studio page&lt;/a&gt; and from there to the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=47305cf4-2bea-43c0-91cd-1b853602dcc5&amp;amp;displaylang=en"&gt;Visual Studio 2010 SDK&lt;/a&gt;. After installing that (you should close VS even though it doesn’t ask you to, because otherwise you won’t be able to open the project) the project worked.&lt;/p&gt;
&lt;p&gt;I later found &lt;a href="http://www.mztools.com/Articles/2008/MZ2008017.aspx"&gt;this site&lt;/a&gt; with a list of Guid and what they mean some of it is still relevant for VS2010. The only Guid not there was the first I searched for (damn you Murphy) &lt;span style="color: #000000"&gt;{&lt;/span&gt;82b43b9b-a64c-4715-b499-d71e9ca2bd60&lt;span style="color: #000000"&gt;} &lt;font color="#333333"&gt;(the others mean WPF project and C# project respectively).&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #000000"&gt;&lt;font color="#333333"&gt;Well it might have worked but building failed because one of the resources didn’t work (icon) and changing it to another caused my VS to hang on the build – maybe I should have uninstalled the extension first? Killed the devenv, uninstalled the extension and the build passed. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #000000"&gt;In the end I decided the hassle was just to great and just used “Paste as Visual Studio code”. If you want to read about all the options I went through you can read them &lt;a href="http://www.dllshepherd.net/2011/01/writing-code-in-blog-post.html" target="_blank"&gt;here&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #000000"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #000000"&gt;&lt;/span&gt;Resources:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/656f8df1-13ae-47b3-8f9a-89bf107c3b2a"&gt;Code4Blog Extension page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://code4blog.codeplex.com/"&gt;Code4Blog CodePlex page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/vextend"&gt;Extending Visual Studio page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=47305cf4-2bea-43c0-91cd-1b853602dcc5&amp;amp;displaylang=en"&gt;Visual Studio 2010 SDK&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.mztools.com/Articles/2008/MZ2008017.aspx"&gt;VS2010 Project Type Guids&lt;/a&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=rrThqrU6wvE:5VC8LoxA9RI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/rrThqrU6wvE" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/4420915139364102044?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/4420915139364102044?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/rrThqrU6wvE/vs2010-project-type-is-not-supported-by.html" title="VS2010: “The project type is not supported by this installation.”" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_SU7V9sPwn1o/TSWa0Y2JyOI/AAAAAAAAAhI/ZqUkZ4ZLOiM/s72-c/image_thumb.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2012/11/vs2010-project-type-is-not-supported-by.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUcEQHY6eCp7ImA9WhVbFEg.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-4030330931717971748</id><published>2012-05-31T02:36:00.000-07:00</published><updated>2012-05-31T02:36:41.810-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-31T02:36:41.810-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight" /><title>Silverlight: TextBox binding only works when control not in focus</title><content type="html">&lt;p&gt;Yesterday I got to the point that most of my priority one tasks were done ahead of schedule so I have decided to go back to old controls and rewrite them to work with the MVVM pattern. I even got to an old argument with my co-worker Felix about using code behind for UI purposes (he is a firm believer in Expression Blend but for implementing Watermarks he decided to use code behind – I refactored it using &lt;a href="http://weblogs.asp.net/jdanforth/archive/2010/09/17/silverlight-watermark-textbox-behavior.aspx" target="_blank"&gt;this&lt;/a&gt;).&lt;/p&gt; &lt;p&gt;So after fixing the Watermark and the AutoCompleteBox that used a service to populate the items in the code behind (using &lt;a href="http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx" target="_blank"&gt;this&lt;/a&gt;) I got down to the actual minor functionality tweaks. Like when the user presses enter in AutoCompleteBox or TextBox some Action is triggered. For the AutoCompleteBox I used the &lt;a href="http://stackoverflow.com/a/5267495/262099" target="_blank"&gt;Attached Property Approach&lt;/a&gt; (I changed it a bit to be for KeyUp instead of KeyDown) just without the CommandArgument since the selected item was already with Data Binding. And it worked just fine.&lt;/p&gt; &lt;p&gt;But with TextBox this approach just didn’t work – because TextBox binds the data only when it is out of focus!&lt;/p&gt; &lt;p&gt;I found some more people with the same problem:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;a href="http://go4answers.webhost4life.com/Example/textbox-textchanged-event-doesnt-cause-156751.aspx" target="_blank"&gt;Go4Answers: TextBox TextChanged event doesn't cause data binding to update&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://forums.silverlight.net/t/51100.aspx/1" target="_blank"&gt;Silverlight Forum: TextBox TextChanged event doesn't cause data binding to...&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;They used the &lt;a href="http://zoltanarvai.com/2009/07/22/binding-update-on-textbox-textchanged-event-using-behaviors/" target="_blank"&gt;behavior solution&lt;/a&gt; (which while browsing for solutions I missed (I guess I am turning lazy because in &lt;a href="http://stackoverflow.com/" target="_blank"&gt;StackOverflow&lt;/a&gt; I would have gotten the right answer in the first page/answer)). I just decided to use the CommandArgument from &lt;a href="http://stackoverflow.com/a/5267495/262099" target="_blank"&gt;Attached Property Approach&lt;/a&gt; (the same one I didn’t need for AutoCompleteBox):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7615cb22-953d-4eba-8d2c-7ae5944b927d" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;TextBox&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Text&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Path&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=SomeText,&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Mode&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=TwoWay}&amp;quot;&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Components&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;EnterKeyUp.Command&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Path&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=EnterSomeTextCommand}&amp;quot;&lt;/span&gt;&lt;br&gt;            &lt;span style="color:#ff0000"&gt; Components&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#ff0000"&gt;EnterKeyUp.CommandArgument&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&amp;quot;{&lt;/span&gt;&lt;span style="color:#a31515"&gt;Binding&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Path&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=Text,&lt;/span&gt;&lt;span style="color:#ff0000"&gt;RelativeSource&lt;/span&gt;&lt;span style="color:#0000ff"&gt;={&lt;/span&gt;&lt;span style="color:#a31515"&gt;RelativeSource&lt;/span&gt;&lt;span style="color:#ff0000"&gt; Self}}&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;quot;&amp;gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The View Model:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:13f9b826-9da6-4509-b5c0-af11c3ec1f9d" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; max-height: 400px; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;RelayCommand&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt; EnterSomeTextCommand&lt;br&gt; {&lt;br&gt;     &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;;&lt;br&gt;     &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;;&lt;br&gt; }&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;(using &lt;a href="http://www.galasoft.ch/mvvm/" target="_blank"&gt;GalaSoft MvvmLight&lt;/a&gt;)&lt;/p&gt; &lt;p&gt;Now you can just use the value.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;Update:&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://twitter.com/yesez5"&gt;@yesez5 &lt;/a&gt;in the comments have added his &lt;a href="http://jsaenzr.com/blog/2012/05/07/actualizar-binding-de-textbox-cuando-el-valor-cambia/" target="_blank"&gt;blog post&lt;/a&gt; (in Spanish, or &lt;a href="http://translate.google.com/translate?u=http://jsaenzr.com/blog/2012/05/07/actualizar-binding-de-textbox-cuando-el-valor-cambia/" target="_blank"&gt;in English&lt;/a&gt; (using Google Translate)) about using a built-in behavior from the &lt;a href="http://compositewpf.codeplex.com/" target="_blank"&gt;Prism Library&lt;/a&gt; (that way you don’t even have to add code implementations for Action triggers or Behaviors in your project).&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://weblogs.asp.net/jdanforth/archive/2010/09/17/silverlight-watermark-textbox-behavior.aspx" target="_blank"&gt;IBlog&amp;lt;Johan&amp;gt;: Silverlight Watermark TextBox Behavior&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.silverlightshow.net/items/Using-the-AutoCompleteBox.aspx" target="_blank"&gt;Peter Kuhn: Using the AutoCompleteBox&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://stackoverflow.com/q/4834227/262099" target="_blank"&gt;StackOverflow: Invoke Command When “ENTER” Key Is Pressed In XAML&lt;/a&gt; (and &lt;a href="http://stackoverflow.com/a/5267495/262099" target="_blank"&gt;Answer&lt;/a&gt;)&lt;/p&gt; &lt;p&gt;&lt;a href="http://go4answers.webhost4life.com/Example/textbox-textchanged-event-doesnt-cause-156751.aspx" target="_blank"&gt;Go4Answers: TextBox TextChanged event doesn't cause data binding to update&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://forums.silverlight.net/t/51100.aspx/1" target="_blank"&gt;Silverlight Forum: TextBox TextChanged event doesn't cause data binding to...&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://zoltanarvai.com/2009/07/22/binding-update-on-textbox-textchanged-event-using-behaviors/" target="_blank"&gt;Zoltan's Dev Corner: Binding update on TextBox.TextChanged event using Behaviors&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.galasoft.ch/mvvm/" target="_blank"&gt;GalaSoft MvvmLight&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://jsaenzr.com/blog/2012/05/07/actualizar-binding-de-textbox-cuando-el-valor-cambia/" target="_blank"&gt;Lightside: Update TextBox binding when the value changes&lt;/a&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=WMUGhNlNLeE:syfawyULvgY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/WMUGhNlNLeE" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/4030330931717971748?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/4030330931717971748?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/WMUGhNlNLeE/silverlight-textbox-binding-only-works.html" title="Silverlight: TextBox binding only works when control not in focus" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><feedburner:origLink>http://www.dllshepherd.net/2012/05/silverlight-textbox-binding-only-works.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8HRH04eyp7ImA9WhVUFU4.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-6934310712746585740</id><published>2012-05-20T11:00:00.001-07:00</published><updated>2012-05-20T11:00:35.333-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-20T11:00:35.333-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="VS2010" /><category scheme="http://www.blogger.com/atom/ns#" term="Bugs" /><title>Default Browsers bug in VS2010</title><content type="html">&lt;p&gt;If you don't know (or haven't encountered it yet) there is a &lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/568469" target="_blank"&gt;bug in VS&lt;/a&gt; that causes the settings of the default browser to not save.  &lt;p&gt;For example: I am using Firefox as my default Windows browser but prefer debugging using IE (mainly because if IE dies my browser is still alive). And I have to change the browser much too often.  &lt;p&gt;There isn't a fix for this but there is a workaround:  &lt;p&gt;From VS -&amp;gt; Tools -&amp;gt; Extension Manager  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-qgnYf_uWU2I/T7kxHGf9y8I/AAAAAAAAB8k/5B2VJ303N-c/s1600-h/VsExtensionManager%25255B10%25255D.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="VsExtensionManager" border="0" alt="VsExtensionManager" src="http://lh3.ggpht.com/-z0I_u7-tCVw/T7kxIbx0L8I/AAAAAAAAB8s/_QMsstDMS8g/VsExtensionManager_thumb%25255B7%25255D.png?imgmax=800" width="391" height="349"&gt;&lt;/a&gt;  &lt;p&gt;-&amp;gt; Online Gallery -&amp;gt; Search:  &lt;p&gt;WoVS Default Browser Switcher  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-lBnqu7JHBwc/T7kxJR5dYnI/AAAAAAAAB80/E9O-3K_e0II/s1600-h/WoVSDefaultBrowserSwitcher%25255B7%25255D.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="WoVSDefaultBrowserSwitcher" border="0" alt="WoVSDefaultBrowserSwitcher" src="http://lh5.ggpht.com/-gbvTJ-MoLEM/T7kxKdQqTsI/AAAAAAAAB88/bcqiptmZ8I8/WoVSDefaultBrowserSwitcher_thumb%25255B4%25255D.png?imgmax=800" width="644" height="446"&gt;&lt;/a&gt;  &lt;p&gt;Download and install the extension and when prompt restart VS.  &lt;p&gt;Now in VS: View -&amp;gt; Toolbar -&amp;gt; enable: Default Browser Switcher  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-UME29PfuBLI/T7kxLo5cMJI/AAAAAAAAB9E/ot72sEfkkRc/s1600-h/ToolbarEnableDefaultBrowserSwitch%25255B8%25255D.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="ToolbarEnableDefaultBrowserSwitch" border="0" alt="ToolbarEnableDefaultBrowserSwitch" src="http://lh3.ggpht.com/-FfnUhBv8sH4/T7kxMnZrR5I/AAAAAAAAB9M/AsdaYj8GtYw/ToolbarEnableDefaultBrowserSwitch_thumb%25255B5%25255D.png?imgmax=800" width="513" height="484"&gt;&lt;/a&gt;  &lt;p&gt;And you will get:  &lt;p&gt;&lt;img src="http://lh5.ggpht.com/_HEJQ2qGqr4U/TH2Bx-xQhlI/AAAAAAAAAA8/lm7rRZL4azo/DBSToolbar_thumb%5B2%5D.png?imgmax=800"&gt;  &lt;p align="center"&gt;&lt;font size="1"&gt;(image from &lt;/font&gt;&lt;a href="http://visualstudiogallery.msdn.microsoft.com/bb424812-f742-41ef-974a-cdac607df921" target="_blank"&gt;&lt;font size="1"&gt;WoVS Default Browser Switcher extension page&lt;/font&gt;&lt;/a&gt;&lt;font size="1"&gt;)&lt;/font&gt;  &lt;p&gt;And you will see what default browser is turned on.  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-Cm7dscHnH84/T7kxPUjsCCI/AAAAAAAAB9U/q11sEWpZlGs/s1600-h/DefaultBrowserSwitcherToolbar%25255B9%25255D.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="DefaultBrowserSwitcherToolbar" border="0" alt="DefaultBrowserSwitcherToolbar" src="http://lh6.ggpht.com/-CT6WGCAjOak/T7kxQRkfwEI/AAAAAAAAB9c/rxnS_17IG1Y/DefaultBrowserSwitcherToolbar_thumb%25255B4%25255D.png?imgmax=800" width="194" height="81"&gt;&lt;/a&gt;  &lt;p&gt;I prefer putting it just below the debug toolbar so that it will be in front of my eyes but you can place it where ever you may like…  &lt;p&gt;&amp;nbsp; &lt;p&gt;There is also a context menu for viewing web pages but it is not as useful as the toolbar.  &lt;p&gt;You can read more about it &lt;a href="http://visualstudiogallery.msdn.microsoft.com/bb424812-f742-41ef-974a-cdac607df921" target="_blank"&gt;here&lt;/a&gt;.  &lt;p&gt;&amp;nbsp; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Resources:&lt;/p&gt; &lt;p&gt;&lt;a href="https://connect.microsoft.com/VisualStudio/feedback/details/568469" target="_blank"&gt;Microsoft connect: VS2010 forgets default browser settings&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://visualstudiogallery.msdn.microsoft.com/bb424812-f742-41ef-974a-cdac607df921" target="_blank"&gt;Extension: WoVS Default Browser Switcher&lt;/a&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=xRp7NJ-qxI4:Cl5iPkb0H2k:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/xRp7NJ-qxI4" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6934310712746585740?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6934310712746585740?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/xRp7NJ-qxI4/default-browsers-bug-in-vs2010.html" title="Default Browsers bug in VS2010" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-z0I_u7-tCVw/T7kxIbx0L8I/AAAAAAAAB8s/_QMsstDMS8g/s72-c/VsExtensionManager_thumb%25255B7%25255D.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2012/05/default-browsers-bug-in-vs2010.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MDRXc-eSp7ImA9WhVVFUs.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-4598332792255750758</id><published>2012-05-09T06:16:00.000-07:00</published><updated>2012-05-09T06:17:54.951-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-09T06:17:54.951-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="VS2010" /><title>A day without the Debugger</title><content type="html">&lt;p&gt;On Sunday morning I found out the Visual Studio 2010 Debugger has stopped working for me. It wasn’t isolated to a single project or technology. Attach to process didn’t work in Silverlight and running Unit Tests in debug mode gave the usual “The breakpoint will not be hit. No symbols have been loaded for this document.”:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-vd16QcFjXj0/T6puZyJBimI/AAAAAAAAB7s/ox8m0KPjOM0/s1600-h/BreakpointWillNotHit6.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="BreakpointWillNotHit" border="0" alt="BreakpointWillNotHit" src="http://lh3.ggpht.com/-sPL4TV9dhsY/T6puaxPZKpI/AAAAAAAAB70/yZiC4WxXmxc/BreakpointWillNotHit_thumb3.png?imgmax=800" width="644" height="97"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Visual Studio was in Debug mode just didn’t pass through any breakpoint (just to check that the Unit Tests used the latest build I added Assert.Fail and the Unit Test failed).&lt;/p&gt; &lt;p&gt;So, first I thought to give myself a challenge and try to work without a debugger. All was of the good until I had a small and stupid bug that I was sure I could just solve using Unit Tests, but the server side worked and I could see the data passing from the client using Fiddler. It didn’t help that in the front of my mind I just knew that with a Debugger this will be solved in minutes. So I dropped the challenge and started investigating the problem. &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;First I went through the usual suspects:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Made sure I was building in debug mode (Solution Configuration toolbar –&amp;gt; Debug)  &lt;li&gt;Deleted the Bin\Debug files and rebuilt  &lt;li&gt;&lt;a href="http://blog.gfader.com/2011/08/vs2010-debugging-not-working.html" target="_blank"&gt;Changed the Build Platform from “Any CPU” to x86&lt;/a&gt;  &lt;li&gt;Made sure the &lt;a href="http://stackoverflow.com/a/6938342/262099" target="_blank"&gt;project build’s debug info was on full&lt;/a&gt; (Project properties –&amp;gt; Build –&amp;gt; Advanced… –&amp;gt; Debug Info should be full):&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;a href="http://lh5.ggpht.com/-Bg7mSAfR6Bg/T6pucPzK3bI/AAAAAAAAB78/wKy08vD2OoM/s1600-h/DebugInfoSettings8.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="DebugInfoSettings" border="0" alt="DebugInfoSettings" src="http://lh4.ggpht.com/-JdTernJlivE/T6pudbegxnI/AAAAAAAAB8E/U5eoZi4S7TY/DebugInfoSettings_thumb5.png?imgmax=800" width="644" height="400"&gt;&lt;/a&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Restarted the computer  &lt;li&gt;Enabled Just My Code (Options-&amp;gt; Debugging –&amp;gt; General), since I like having symbol debugging it was turned off  &lt;li&gt;Reset the setting using &lt;a href="http://social.msdn.microsoft.com/Forums/nl-BE/vssetup/thread/bb23dcd0-fca4-4b16-b7d6-c98c4963629a" target="_blank"&gt;Devenv.exe /resetsettings&lt;/a&gt;&amp;nbsp; &lt;li&gt;I decided against using &lt;a href="http://social.msdn.microsoft.com/Forums/nl-BE/vssetup/thread/bb23dcd0-fca4-4b16-b7d6-c98c4963629a" target="_blank"&gt;Devenv.exe /SafeMode&lt;/a&gt; (but next time I will use it)&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;I was very close to trying the repair on the windows Control Panel. But then I noticed that while the debugger didn’t break on any breakpoint it did show a few BadImageFormatException exceptions being thrown, setting Visual Studio to break on those exceptions (Debug menu –&amp;gt; Exceptions… (or Ctrl+D+E) –&amp;gt; Find: “BadImageFormatException” and checking the thrown:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-mLk_HnWTj48/T6puerfcjWI/AAAAAAAAB8I/rAlzv-WeOm0/s1600-h/DebugExceptionThrown7.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="DebugExceptionThrown" border="0" alt="DebugExceptionThrown" src="http://lh3.ggpht.com/-OLkaPB1xOwA/T6pufztBiTI/AAAAAAAAB8U/wkAqA9HGPd8/DebugExceptionThrown_thumb4.png?imgmax=800" width="644" height="324"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Running it again:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;System.BadImageFormatException occurred&lt;br&gt;&amp;nbsp; Message=Could not load file or assembly 'dbghelp.dll' or one of its dependencies. The module was expected to contain an assembly manifest.&lt;br&gt;&amp;nbsp; Source=mscorlib&lt;br&gt;&amp;nbsp; FileName=dbghelp.dll&lt;br&gt;&amp;nbsp; FusionLog=""&lt;br&gt;&amp;nbsp; StackTrace:&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Reflection.AssemblyName.nGetFileInformation(String s)&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at System.Reflection.AssemblyName.GetAssemblyName(String assemblyFile)&lt;br&gt;&amp;nbsp; InnerException: System.BadImageFormatException&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Message=Could not load file or assembly 'dbghelp.dll' or one of its dependencies. The module was expected to contain an assembly manifest.&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FileName=dbghelp.dll&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FusionLog=""&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InnerException: &lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Or just the Dlls:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;dbghelp.dll  &lt;li&gt;DDConfig.dll  &lt;li&gt;LanguagePackage.dll  &lt;li&gt;Microsoft.VisualStudio.Coverage.Symbols.dll  &lt;li&gt;Microsoft.VisualStudio.ProgressionIcons.dll  &lt;li&gt;Microsoft.VisualStudio.QualityTools.RecorderBarBHO100.dll  &lt;li&gt;pidgenx.dll  &lt;li&gt;SqlTDiagN.dll  &lt;li&gt;SqlToolsVSNativeHelpers.dll  &lt;li&gt;symsrv.dll&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Searching the file system for one of them dbghelp.dll,the icon for the DLLs was for dotPeek which got me thinking about uninstalling JetBrains early access tools dotPeek and dotCover (after closing VS) – just to be sure it wasn’t them…&lt;/p&gt; &lt;p&gt;Trying Debug again and everything worked.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The weird part is trying to reinstall those apps (with the exact same MSIs) didn’t reproduce the problem. Looking back I remember restarting my computer before all this started but even restart won’t reproduce the problem. &lt;/p&gt; &lt;p&gt;Another case for the “computer's nondeterministic nature”…&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://blog.gfader.com/2011/08/vs2010-debugging-not-working.html" target="_blank"&gt;Peter Gfader 's .NET Blog: VS2010 - Debugging not working&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://stackoverflow.com/a/6938342/262099" target="_blank"&gt;StackOverflow: debugging is not working in my visual studio 2010&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/nl-BE/vssetup/thread/bb23dcd0-fca4-4b16-b7d6-c98c4963629a" target="_blank"&gt;MSDN Forums: Debugger not working on Visual Studio 2010&lt;/a&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=fGZmFbgzelM:DN69wE_Kns0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/fGZmFbgzelM" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/4598332792255750758?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/4598332792255750758?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/fGZmFbgzelM/day-without-debugger.html" title="A day without the Debugger" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-sPL4TV9dhsY/T6puaxPZKpI/AAAAAAAAB70/yZiC4WxXmxc/s72-c/BreakpointWillNotHit_thumb3.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2012/05/day-without-debugger.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkQMQnYzeSp7ImA9WhVXEUg.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-5567672492407766773</id><published>2012-04-11T06:18:00.000-07:00</published><updated>2012-04-11T06:19:43.881-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-11T06:19:43.881-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Oracle" /><category scheme="http://www.blogger.com/atom/ns#" term="ArcObjects" /><category scheme="http://www.blogger.com/atom/ns#" term="Exception" /><category scheme="http://www.blogger.com/atom/ns#" term="ESRI" /><title>COMException: Abstract Data Types not supported</title><content type="html">&lt;p&gt;&lt;u&gt;&lt;strong&gt;“Full” Exception:&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;System.Runtime.InteropServices.COMException: Abstract Data Types not supported [SHEMA.LAYER][STATE_ID = 0]&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;The real problem:&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;When calling:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:448d4f12-4221-425a-b3c9-6ad1747ab72b" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; overflow: auto; padding: 2px 5px;"&gt;workspace.OpenFeatureClass(layerName)&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;(where workspace is IFeatureWorkspace)&lt;/p&gt; &lt;p&gt;with a layer that was not defined in the SDE. You will get the given error.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;Why did it happen to me?&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;When we moved to Oracle we decided to create our tables using plain SQL and define our shape columns as SDO_GEOMETRY. This was done so other teams working on our DB on their computer won’t need to install SDE and could run Unit Tests using non geography data. Obviously we forgot to run the register command on one of our tables and I got this lovely exception…&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/u&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;&lt;strong&gt;The fix:&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt; &lt;p&gt;Registering the&amp;nbsp; layer using:&lt;/p&gt; &lt;p&gt;sdelayer -o register –s &lt;font color="#ff0000"&gt;SERVER&lt;/font&gt; –u &lt;font color="#ff0000"&gt;DB&lt;/font&gt; p &lt;font color="#ff0000"&gt;PASSWORD&lt;/font&gt; –i &lt;font color="#ff0000"&gt;SDE_INSTANCE&lt;/font&gt; -t &lt;font color="#0000ff"&gt;SDO_GEOMETRY&lt;/font&gt; -e p –l&amp;nbsp; &lt;font color="#ff0000"&gt;LAYER&lt;/font&gt;,&lt;font color="#0000ff"&gt;shape&lt;/font&gt; -R 2 -C &lt;font color="#0000ff"&gt;OBJECTID,SDE&lt;/font&gt;&lt;/p&gt; &lt;p&gt;(in red what you must change, blue should be according to your DB).&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;font color="#000000"&gt;One ESRI exception mapped, an &lt;font size="5"&gt;∞&lt;/font&gt; to go…&lt;/font&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=5iJZ3SK7LYA:bVsILsJQyhA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/5iJZ3SK7LYA" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/5567672492407766773?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/5567672492407766773?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/5iJZ3SK7LYA/comexception-abstract-data-types-not.html" title="COMException: Abstract Data Types not supported" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><feedburner:origLink>http://www.dllshepherd.net/2012/04/comexception-abstract-data-types-not.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkcAQ3g6cCp7ImA9WhVTGEU.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-3273966095395103759</id><published>2012-03-04T08:54:00.001-08:00</published><updated>2012-03-04T08:54:02.618-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-04T08:54:02.618-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Beginners" /><category scheme="http://www.blogger.com/atom/ns#" term="SQL" /><title>Selecting Distinct Rows</title><content type="html">&lt;p&gt;Or how the definition of the request can get us confused?&lt;/p&gt; &lt;p&gt;One of my team members asked me today to help her in a SQL query and although I hate SQL I tried to help her. She wanted to select a row by a &lt;strong&gt;&lt;u&gt;distinct&lt;/u&gt;&lt;/strong&gt; field – ColumnA and to view other columns in that row, so I started the query with the distinct keyword:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:18e2677c-eb12-43f7-8092-bed167cf1dc3" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;SELECT&lt;/span&gt; &lt;span style="color:#0000ff"&gt;DISTINCT&lt;/span&gt; &lt;span style="color:#008080"&gt;ColumnA&lt;/span&gt; &lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#0000ff"&gt;FROM&lt;/span&gt; &lt;span style="color:#008080"&gt;SomeTable&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;But run into the problem that she wanted those other columns of the row which weren’t distinct.&lt;/p&gt; &lt;p&gt;So I Googled Distinct and got lost. After taking a coffee break I changed my search to “sql select id of first distinct” the first link was of StackOverFlow: &lt;a href="http://stackoverflow.com/q/1326473/262099" target="_blank"&gt;SQL SELECT DISTINCT ID from copies ORDER BY CID&lt;/a&gt; &lt;/p&gt; &lt;p&gt;Which told me of course that I was using the wrong keyword and should have used the Group by keyword.&lt;/p&gt; &lt;p&gt;The end result query:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:660af7d2-657c-4054-ad01-9ef14a68d483" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;SELECT&lt;/span&gt; &lt;span style="color:#808080"&gt;*&lt;/span&gt; &lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#0000ff"&gt;FROM&lt;/span&gt; &lt;span style="color:#008080"&gt;SomeTable&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;WHERE&lt;/span&gt; &lt;span style="color:#008080"&gt;OBJECTID&lt;/span&gt; &lt;span style="color:#808080"&gt;IN&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#808080"&gt;(&lt;/span&gt; &lt;span style="color:#0000ff"&gt;SELECT&lt;/span&gt; &lt;span style="color:#ff00ff"&gt;MIN&lt;/span&gt;&lt;span style="color:#808080"&gt;(&lt;/span&gt;&lt;span style="color:#008080"&gt;OBJECTID&lt;/span&gt;&lt;span style="color:#808080"&gt;)&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;                    &lt;span style="color:#0000ff"&gt;FROM&lt;/span&gt; &lt;span style="color:#008080"&gt;SomeTable&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                    &lt;span style="color:#0000ff"&gt;GROUP&lt;/span&gt; &lt;span style="color:#0000ff"&gt;BY&lt;/span&gt; &lt;span style="color:#008080"&gt;ColumnA&lt;/span&gt;&lt;span style="color:#808080"&gt;)&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Was what she wanted.&lt;/p&gt; &lt;p&gt;God bless coffee (and StackOverFlow)…&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://stackoverflow.com/q/1326473/262099" target="_blank"&gt;StackOverFlow - SQL SELECT DISTINCT ID from copies ORDER BY CID&lt;/a&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=l62X6W5jNLE:SB231jtW8TQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/l62X6W5jNLE" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/3273966095395103759?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/3273966095395103759?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/l62X6W5jNLE/selecting-distinct-rows.html" title="Selecting Distinct Rows" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><feedburner:origLink>http://www.dllshepherd.net/2012/03/selecting-distinct-rows.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0INSH4_fCp7ImA9WhVTGE0.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-5196658626397916919</id><published>2012-03-03T13:17:00.000-08:00</published><updated>2012-03-03T13:19:59.044-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-03T13:19:59.044-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008" /><title>SQL Server 2008: Forget a user/password</title><content type="html">&lt;p&gt;For a long time now I am stuck with a saved user in SQL Server 2008 that I just didn’t want to use:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_SU7V9sPwn1o/TSlzGPewOMI/AAAAAAAAAl0/-2J2taKAgQY/s1600-h/image%5B2%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 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://lh4.ggpht.com/_SU7V9sPwn1o/TSlzGy8fKdI/AAAAAAAAAl4/flm6TxtMUac/image_thumb.png?imgmax=800" width="369" height="279"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Once upon a time I used that user (that has almost no permissions) for just one action – unfortunately I checked the “Remember password” and whenever I choose that server in the servers combo box I got that damn user. Well I finally had enough!&lt;/p&gt; &lt;p&gt;So I Googled “remove sql server 2008 user password Remember password” and found &lt;a href="http://stackoverflow.com/q/349668/262099" target="_blank"&gt;this StackOverFlow post&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;The solution is fairly easy, just rename: C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin to SqlStudio.bin0 (as a rule I never delete a file I don’t have a backup to). And now SQL Server doesn’t remember anything (not even the servers I was on):&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_SU7V9sPwn1o/TSlzHh6zEHI/AAAAAAAAAl8/bLthhE5YNrM/s1600-h/image%5B5%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 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://lh3.ggpht.com/_SU7V9sPwn1o/TSlzIjyXFDI/AAAAAAAAAmA/3GjUoSeK-Ms/image_thumb%5B1%5D.png?imgmax=800" width="369" height="279"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;But that is just a hundred times better than the previous headache…&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://stackoverflow.com/q/349668/262099" target="_blank"&gt;StackOverFlow: Removing the remembered login and password list in SQL Management Studio&lt;/a&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=HrHPjmzT2so:FbeoesRqI6Y:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/HrHPjmzT2so" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/5196658626397916919?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/5196658626397916919?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/HrHPjmzT2so/sql-server-2008-forget-userpassword.html" title="SQL Server 2008: Forget a user/password" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_SU7V9sPwn1o/TSlzGy8fKdI/AAAAAAAAAl4/flm6TxtMUac/s72-c/image_thumb.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2012/03/sql-server-2008-forget-userpassword.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIMSH4zeCp7ImA9WhRbGEw.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-761017977148424866</id><published>2012-02-09T10:34:00.000-08:00</published><updated>2012-02-09T10:36:29.080-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-09T10:36:29.080-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Event Viewer" /><category scheme="http://www.blogger.com/atom/ns#" term="PowerShell" /><title>PowerShell: Event Viewer saver</title><content type="html">&lt;p&gt;Two weeks ago I was helping out at my old company (it is part of my old contract with them). When one of my friends there told me they just can’t look at the Event Viewer anymore. Why? Well it seems another friend got a little overboard in logging stuff and the Event Viewer turned from logging Errors and important events to “real time logging” (their words). So being the helpful guy that I am I told them about PowerShell. I even pointed them to some blogs in the web. &lt;/p&gt; &lt;p&gt;Today I decided to follow my own advice and check out PowerShell (and maybe write something they could use). So I went through some basic tutorials (&lt;a title="PowerShell Tutorial 1: Configuring the PowerShell Console" href="http://www.powershellpro.com/powershell-tutorial-introduction/tutorial-windows-powershell-console/" target="_blank"&gt;1&lt;/a&gt;, &lt;a title="PowerShell Tutorial 2: PowerShell Commands &amp;ndash; Cmdlet" href="http://www.powershellpro.com/powershell-tutorial-introduction/tutorial-powershell-cmdlet/" target="_blank"&gt;2&lt;/a&gt;, &lt;a title="PowerShell Tutorial 3: PowerShell Aliases" href="http://www.powershellpro.com/powershell-tutorial-introduction/tutorial-powershell-aliases/" target="_blank"&gt;3&lt;/a&gt; reading briefly, &lt;a title="PowerShell Tutorial 4: Using Cmdlet Options" href="http://www.powershellpro.com/powershell-tutorial-introduction/powershell-parameters-objects-and-formatting/" target="_blank"&gt;4&lt;/a&gt;, &lt;a title="PowerShell Tutorial 5: Windows PowerShell Providers" href="http://www.powershellpro.com/powershell-tutorial-introduction/powershell-providers/" target="_blank"&gt;5&lt;/a&gt;, &lt;a title="PowerShell Tutorial 6: PowerShell Scripting &amp;ndash; Introduction to Script Writing" href="http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-scripting/" target="_blank"&gt;6&lt;/a&gt; (can be skipped), &lt;a title="PowerShell Tutorial 7: Accumulate, Recall, and Modify Data" href="http://www.powershellpro.com/powershell-tutorial-introduction/variables-arrays-hashes/" target="_blank"&gt;7&lt;/a&gt;, &lt;a title="PowerShell Tutorial 8: Conditional Logic (if, elseif, else, and switch)" href="http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-conditional-logic/" target="_blank"&gt;8&lt;/a&gt;, &lt;a title="PowerShell Tutorial 9: Getting Loopy" href="http://www.powershellpro.com/powershell-tutorial-introduction/logic-using-loops/" target="_blank"&gt;9&lt;/a&gt;, there are more tutorials but they are not needed for this simple task). When following tutorials I sometimes like to use my own example, that way I can be sure I am understanding things like a human and not like a monkey (“&lt;a href="http://en.wikipedia.org/wiki/Monkey_see,_monkey_do" target="_blank"&gt;Monkey see, monkey do&lt;/a&gt;”).&lt;/p&gt; &lt;p&gt;On the second tutorial I already knew I had to use ‘get-eventlog’ or the newer ‘get-winevent’ command (by using ‘get-command -Verb Get’ and looking at the options). By looking at the help for these commands (by using ‘get-help get-eventlog’) I found out that get-winevent needs newer operating systems (minimum Windows Vista) which are not available to my friends…&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h3&gt;&lt;u&gt;So what do I want my script to do?&lt;/u&gt;&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;1. Display only the errors from Event Viewer’s Application log (and filter by the application name).&lt;/strong&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Looking at the examples was enough for this:&lt;/li&gt;&lt;/ul&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:adbbbf67-1e8d-49bb-8750-19ce067a47af" class="wlWriterSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="padding-bottom: 0px; margin: 0px; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px"&gt; &lt;li&gt;get-eventlog -logname System -EntryType Error &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;Wanting something more advanced (I learned that you shouldn’t use TimeWritten in the where since it is a string object, see sorting below):&lt;/li&gt;&lt;/ul&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3e9db3dd-caf9-49fe-8600-eaa433158f36" class="wlWriterSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="padding-bottom: 0px; margin: 0px; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px"&gt; &lt;li&gt;Get-Eventlog Application -After ([datetime]::Parse("2012-02-08 17:00")) | where {($_.entryType -eq "Error")} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;This way you can “add” warnings not just errors:&lt;/li&gt;&lt;/ul&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2d0740a1-fdab-4eb3-b26a-0091656839bf" class="wlWriterSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="padding-bottom: 0px; margin: 0px; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px"&gt; &lt;li&gt;Get-Eventlog Application -After ([datetime]::Parse("2012-02-08 17:00")) | where {(($_.entryType -eq "Error") -or ($_.entryType -eq "Warning"))} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;Adding sorting to view the errors from old to new, added difficulty because TimeWritten is a string with a problematic format (M/d/yyyy h:m:s AM/PM) that doesn’t work with string comparison:&lt;/li&gt;&lt;/ul&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:338ff0de-4491-4935-aa7e-7f4118d52a2a" class="wlWriterSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="padding-bottom: 0px; margin: 0px; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px"&gt; &lt;li&gt;Get-Eventlog Application -After ([datetime]::Parse("2012-02-08 17:00")) | where {($_.entryType -eq "Error")} | select EntryType,InstanceId,Message,Category,Source, @{Name="TimeWritten";Expression={&amp;nbsp; ([datetime]::Parse($_.TimeWritten)).ToString("yyyy-MM-dd HH:mm:ss") }}&amp;nbsp; | sort -Property TimeWritten &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;ul&gt; &lt;li&gt;Wanting to actually see the message (since PowerShell by default limits the column size):&lt;/li&gt;&lt;/ul&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a3124568-b7f4-423b-b104-c92c51b82a99" class="wlWriterSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="padding-bottom: 0px; margin: 0px; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px"&gt; &lt;li&gt;Get-Eventlog Application -After ([datetime]::Parse("2012-02-08 17:00")) | where {($_.entryType -eq "Error")} | select EntryType,InstanceId,Message,Category,Source, @{Name="TimeWritten";Expression={&amp;nbsp; ([datetime]::Parse($_.TimeWritten)).ToString("yyyy-MM-dd HH:mm:ss") }} | Format-list -Property EntryType, Source, Message, TimeWritten &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;strong&gt;2. Export the errors from 1 to a csv file (so that the errors will become less real time and more all time).&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;As seen in the bottom of tutorial 5:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:809d38cd-bf08-4d4e-b108-6a21cb1ea050" class="wlWriterSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="padding-bottom: 0px; margin: 0px; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px"&gt; &lt;li&gt;Get-Eventlog Application -After ([datetime]::Parse("2012-02-08 17:00")) | where {($_.entryType -eq "Error")} | select EntryType,InstanceId,Message,Category,Source, @{Name="TimeWritten";Expression={&amp;nbsp; ([datetime]::Parse($_.TimeWritten)).ToString("yyyy-MM-dd HH:mm:ss") }} | Export-CSV "EventErrors.csv" &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;&lt;strong&gt;3. Do an infinite loop that does 2 on new errors, so that errors in the night shift will be stored.&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;That was a bit more complex simply because I wanted to append rows to the CSV. &lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b9f9147b-5eb4-4f02-bd5f-23622c0db888" class="wlWriterSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="padding-bottom: 0px; margin: 0px; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px"&gt; &lt;li&gt;$currentTime = get-date  &lt;li class="even"&gt;$currentDate = get-date -format "yyyy_MM_dd"  &lt;li&gt;if(test-path "EventErrors_$currentDate.csv")  &lt;li class="even"&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $record = Import-CSV "EventErrors_$currentDate.csv" | sort -Property TimeWritten | Select-Object -Last 1 | select TimeWritten  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $currentTime = [datetime]::Parse($record.TimeWritten)  &lt;li&gt;}  &lt;li class="even"&gt;&amp;nbsp; &lt;li&gt;while($true)  &lt;li class="even"&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $currentDate = get-date -format "yyyy_MM_dd"  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $data = Get-Eventlog Application -After $currentTime | where {($_.entryType -eq "Error")} | select EntryType,InstanceId,Message,Category,Source, @{Name="TimeWritten";Expression={&amp;nbsp; ([datetime]::Parse($_.TimeWritten)).ToString("yyyy-MM-dd HH:mm:ss") }}  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $currentTime = get-date  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if($data -ne $NULL)  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(test-path "EventErrors_$currentDate.csv")  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "File EventErrors_$currentDate.csv exists, importing data."  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $data = (Import-CSV "EventErrors_$currentDate.csv") + $data | sort -Property TimeWritten  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $data | Export-CSV "EventErrors_$currentDate.csv"  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li class="even"&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Start-Sleep -s 20  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Ping $currentTime"  &lt;li&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;Notes:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The script won’t work if the file is opened in Excel (but the csv can be copied or opened with notepad).  &lt;li&gt;You can adjust the sleep time, I choose 20 seconds.  &lt;li&gt;Since it’s an infinite loop it can only be exited by Ctrl+C&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Output in Excel:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-7RKGPe4Wa30/TzPxTWbKQGI/AAAAAAAAB5c/4epORaSFnNg/s1600-h/EventViewer-csv-errors%25255B7%25255D.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="EventViewer-csv-errors" border="0" alt="EventViewer-csv-errors" src="http://lh3.ggpht.com/-vkq_acC2XXE/TzPxU8IEUpI/AAAAAAAAB5k/jCvj2YI44SI/EventViewer-csv-errors_thumb%25255B4%25255D.png?imgmax=800" width="644" height="461"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;By the way an advanced script to this could be outputting the errors to the DB… But that can be considered a version in some companies.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.powershellpro.com/powershell-tutorial-introduction/tutorial-windows-powershell-console/" target="_blank"&gt;PowerShell Tutorial 1: Configuring the PowerShell Console&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.powershellpro.com/powershell-tutorial-introduction/tutorial-powershell-cmdlet/" target="_blank"&gt;PowerShell Tutorial 2: PowerShell Commands – Cmdlet&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.powershellpro.com/powershell-tutorial-introduction/tutorial-powershell-aliases/" target="_blank"&gt;PowerShell Tutorial 3: PowerShell Aliases&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.powershellpro.com/powershell-tutorial-introduction/powershell-parameters-objects-and-formatting/" target="_blank"&gt;PowerShell Tutorial 4: Using Cmdlet Options&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.powershellpro.com/powershell-tutorial-introduction/powershell-providers/" target="_blank"&gt;PowerShell Tutorial 5: Windows PowerShell Providers&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.powershellpro.com/powershell-tutorial-introduction/variables-arrays-hashes/" target="_blank"&gt;PowerShell Tutorial 7: Accumulate, Recall, and Modify Data&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a title="PowerShell Tutorial 8: Conditional Logic (if, elseif, else, and switch)" href="http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-conditional-logic/" target="_blank"&gt;PowerShell Tutorial 8: Conditional Logic (if, elseif, else, and switch)&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a title="PowerShell Tutorial 9: Getting Loopy" href="http://www.powershellpro.com/powershell-tutorial-introduction/logic-using-loops/" target="_blank"&gt;PowerShell Tutorial 9: Getting Loopy&lt;/a&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=vc4H-Gfo9eY:Won3QTyAmRo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/vc4H-Gfo9eY" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/761017977148424866?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/761017977148424866?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/vc4H-Gfo9eY/powershell-event-viewer-saver.html" title="PowerShell: Event Viewer saver" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-vkq_acC2XXE/TzPxU8IEUpI/AAAAAAAAB5k/jCvj2YI44SI/s72-c/EventViewer-csv-errors_thumb%25255B4%25255D.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2012/02/powershell-event-viewer-saver.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUMCR3Y5fSp7ImA9WhRUFUw.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-1878401285633942244</id><published>2012-01-25T10:51:00.001-08:00</published><updated>2012-01-25T10:51:06.825-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-25T10:51:06.825-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Silverlight" /><title>Silverlight Windows Authentication (the Prism way)</title><content type="html">&lt;p&gt;&lt;em&gt;Note: this was done with Silverlight 5 and Prism 4&lt;/em&gt;&lt;/p&gt; &lt;p&gt;In the past month our team started a new project and after many discussions of how to build it right, decided to use the Prism framework (you an read more on Prism &lt;a href="http://www.codeproject.com/Articles/155835/Prism-for-Silverlight-MEF-in-Easy-Samples-Part-1-P" target="_blank"&gt;here&lt;/a&gt;). I was put in charge of providing a service (as in a Silverlight utility class) for Authentication and Authorization using Windows Authentication and Active Directory groups. &lt;/p&gt; &lt;p&gt;The way we handled that in our previous project was using the built in services in RIA services (the only use we had for RIA Services). But that implementation used:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Code in the main Silverlight Application project (not in Class Library projects)  &lt;li&gt;Configuration in App.Xaml  &lt;li&gt;Configuration in web.config&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;So I tried for two days to create the code in a Silverlight Application project that is not the main project (not the one referenced in the ASPX page), with no success and many errors. I found many forum posts that claim it is possible but all the examples were either Forms Authentication or used the main Silverlight Application (like &lt;a href="http://forums.silverlight.net/t/149199.aspx/1" target="_blank"&gt;this one&lt;/a&gt; or &lt;a href="http://forums.silverlight.net/t/219450.aspx/1/10" target="_blank"&gt;this one&lt;/a&gt;). The main problem I found is the configuration that should be put in the App.Xaml:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:afab5637-25f9-46c8-b4ce-0f1836e7c9fd" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;Application.ApplicationLifetimeObjects&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;app&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;WebContext&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;app&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;WebContext.Authentication&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;            &lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;appsvc&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;WindowsAuthentication&lt;/span&gt;&lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;app&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;WebContext.Authentication&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;app&lt;/span&gt;&lt;span style="color:#0000ff"&gt;:&lt;/span&gt;&lt;span style="color:#a31515"&gt;WebContext&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#a31515"&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;Application.ApplicationLifetimeObjects&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The app preface is from the generated code that is generated in a Module Silverlight Application, but the App.Xaml is in the Main Silverlight Application and it just doesn’t work to use it outside of the project it was generated at. Adding App.xaml in the Module Silverlight Application won’t work either because Prism doesn’t call the App.Xaml of inner Modules (though having that Module run as it’s own main application does work). &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;In the end I decided to try to implement the RIA Authentication myself using WCF Services (me and my team leader have burned to much time on RIA by that point… and since we use it for just authentication it didn’t seem justified). &lt;/p&gt; &lt;p&gt;The WCF Services web site must be configured in IIS to use Windows Authentication. The code for the service is:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:baea39ab-93f7-476c-90ef-343c5a9f81e5" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;[&lt;span style="color:#2b91af"&gt;ServiceContract&lt;/span&gt;]&lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;interface&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IAuthenticationService&lt;/span&gt;&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li class="even"&gt;    [&lt;span style="color:#2b91af"&gt;OperationContract&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;User&lt;/span&gt; GetUser();&lt;/li&gt; &lt;li class="even"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4846be6f-4d58-4353-85e1-1311e78d351c" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;[&lt;span style="color:#2b91af"&gt;AspNetCompatibilityRequirements&lt;/span&gt;(RequirementsMode = &lt;span style="color:#2b91af"&gt;AspNetCompatibilityRequirementsMode&lt;/span&gt;.Allowed)]&lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;AuthenticationService&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;IAuthenticationService&lt;/span&gt;&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;User&lt;/span&gt; GetUser()&lt;/li&gt; &lt;li&gt;    {&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; result = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;User&lt;/span&gt; { Name = &lt;span style="color:#2b91af"&gt;OperationContext&lt;/span&gt;.Current.ServiceSecurityContext.WindowsIdentity.Name };&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (&lt;span style="color:#2b91af"&gt;OperationContext&lt;/span&gt;.Current.ServiceSecurityContext.WindowsIdentity.Groups != &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li class="even"&gt;        {&lt;/li&gt; &lt;li&gt;            result.Groups = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li class="even"&gt;            &lt;span style="color:#0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; userGroup &lt;span style="color:#0000ff"&gt;in&lt;/span&gt; &lt;span style="color:#2b91af"&gt;OperationContext&lt;/span&gt;.Current.ServiceSecurityContext.WindowsIdentity.Groups)&lt;/li&gt; &lt;li&gt;            {&lt;/li&gt; &lt;li class="even"&gt;                result.Groups.Add(userGroup.Translate(&lt;span style="color:#0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;NTAccount&lt;/span&gt;)).Value);&lt;/li&gt; &lt;li&gt;            }&lt;/li&gt; &lt;li class="even"&gt;        }&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; result;&lt;/li&gt; &lt;li class="even"&gt;    }&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The user groups default values are in SID format so the code:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0ac76d67-c699-4745-bf32-25cebac36ec5" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;userGroup.Translate(&lt;span style="color:#0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;NTAccount&lt;/span&gt;)).Value&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;translate it to readable text.&lt;/p&gt; &lt;p&gt;User is defined as:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1ba06468-1dfd-41c1-b2a7-3a2682f04f2c" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;[&lt;span style="color:#2b91af"&gt;DataContract&lt;/span&gt;]&lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;User&lt;/span&gt;&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li class="even"&gt;    [&lt;span style="color:#2b91af"&gt;DataMember&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Name { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    [&lt;span style="color:#2b91af"&gt;DataMember&lt;/span&gt;]&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt; Groups { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Web.Config code:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6afea10c-2698-40ca-85f6-ee631e0357ee" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;  &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;system.web&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;compilation&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;debug&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;true&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;targetFramework&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;4.0&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;authentication&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;mode&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;Windows&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;system.web&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;  &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;behaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;behavior&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;AllServicesBehavior&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;          &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceMetadata&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;httpGetEnabled&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;true&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceDebug&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;includeExceptionDetailInFaults&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;true&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;          &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;dataContractSerializer&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;maxItemsInObjectGraph&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;2147483647&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;behavior&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;behavior&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&amp;quot;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceMetadata&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;httpGetEnabled&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;true&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;          &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceDebug&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;includeExceptionDetailInFaults&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;false&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;behavior&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;behaviors&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;bindings&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;customBinding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;customBinaryEncodedBinding&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;binaryMessageEncoding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;          &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;httpTransport&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;authenticationScheme&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;Negotiate&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;customBinding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;bindings&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;services&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;service&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;AllServicesBehavior&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;DllShepherd.AuthenticationService&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;endpoint&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;address&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;binding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;customBinding&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;customBinaryEncodedBinding&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;contract&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;DllShepherd.IAuthenticationService&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;service&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;services&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;configuration&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;The important part is:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:91601b24-5398-4e8a-ad93-9ad319f92376" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;httpTransport&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;authenticationScheme&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;Negotiate&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;and:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:69ad5010-9d11-411c-a3a7-bfba64b796b8" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;authentication&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;mode&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;Windows&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;that enables the authentication and binaryMessageEncoding for Silverlight.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;In the Silverlight Services Class Library project (Services is part of the Prism terminology for client services, usually Singleton utility classes), add the service reference (I do this part usually in code) and consume it using usual Silverlight code:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c16c9341-6a6d-48ca-88b4-8f7aac737d78" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; UserName { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;event&lt;/span&gt; &lt;span style="color:#2b91af"&gt;EventHandler&lt;/span&gt; UserLoaded;&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; GetUser()&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    Client.Begin(&lt;span style="color:#a31515"&gt;&amp;quot;GetUser&amp;quot;&lt;/span&gt;, GetUserCompleted, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;);&lt;/li&gt; &lt;li class="even"&gt;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; GetUserCompleted(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af"&gt;ObjectClient&lt;/span&gt;&amp;lt;DllShepherd.&lt;span style="color:#2b91af"&gt;IAuthenticationService&lt;/span&gt;&amp;gt;.&lt;span style="color:#2b91af"&gt;ClientEventArgs&lt;/span&gt; e)&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li class="even"&gt;    Dispatcher.BeginInvoke(() =&amp;gt;&lt;/li&gt; &lt;li&gt;    {&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; result = e.LoadResult&amp;lt;&lt;span style="color:#2b91af"&gt;User&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;        UserName = result.Name;&lt;/li&gt; &lt;li class="even"&gt;        AuthorizationService.Roles = result.Groups;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (UserLoaded != &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li class="even"&gt;            UserLoaded(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;    });&lt;/li&gt; &lt;li class="even"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;AuthorizationService will later use the Groups to check if the user is authorized to view Modules, Views or data.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;In the Prism way the Modules now know only the interface for this Silverlight service (the interface is in the Infrastructure project which everyone knows), which look something like:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:985904f4-dfbe-4eb3-9ac7-210ad9afbbc3" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;interface&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IAuthenticationService&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;#region&lt;/span&gt; EVENTS&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;event&lt;/span&gt; &lt;span style="color:#2b91af"&gt;EventHandler&lt;/span&gt; UserLoaded;&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;#region&lt;/span&gt; METHODS&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; GetUser();&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;#endregion&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; UserName { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; }&lt;/li&gt; &lt;li class="even"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;But the implementation is only known by the Application (not the Modules which just use IAuthenticationService with a Prism Import) and there is no special code or configuration needed in the Application.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://forums.silverlight.net/t/149199.aspx/1" target="_blank"&gt;Silverlight.Net Forum - Prism, RIA &amp;amp; Authentication (VS 2010)&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://forums.silverlight.net/t/219450.aspx/1/10" target="_blank"&gt;Silverlight.Net Forum - PRISM 4 and RIA services&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.codeproject.com/Articles/155835/Prism-for-Silverlight-MEF-in-Easy-Samples-Part-1-P" target="_blank"&gt;Prism for Silverlight/MEF in Easy Samples. Part 1 - Prism Modules&lt;/a&gt; (there are three parts)&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=H_mcLm3YGLg:-6xykqO6wmc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/H_mcLm3YGLg" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/1878401285633942244?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/1878401285633942244?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/H_mcLm3YGLg/silverlight-windows-authentication.html" title="Silverlight Windows Authentication (the Prism way)" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><feedburner:origLink>http://www.dllshepherd.net/2012/01/silverlight-windows-authentication.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QCSHo8fyp7ImA9WhRXGEQ.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-3872939387466811192</id><published>2011-12-26T03:35:00.002-08:00</published><updated>2011-12-26T03:36:09.477-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-26T03:36:09.477-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ArcObjects" /><category scheme="http://www.blogger.com/atom/ns#" term="ESRI" /><title>ArcObjects: TOC</title><content type="html">&lt;p&gt;List of ArcObjects posts:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://www.dllshepherd.net/2011/05/arcobjects-introduction.html"&gt;Introduction&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.dllshepherd.net/2011/06/arcobjects-getting-started.html"&gt;Getting Started&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.dllshepherd.net/2011/06/arcobjects-extending-framework.html" target="_blank"&gt;Extending the Framework&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.dllshepherd.net/2011/11/this-post-is-forth-post-in-my.html" target="_blank"&gt;Workspace&lt;/a&gt;  &lt;li&gt;&lt;a href="http://www.dllshepherd.net/2011/12/arcobjects-workspace-provider.html"&gt;Workspace Provider&lt;/a&gt; &lt;li&gt;&lt;a href="http://www.dllshepherd.net/2011/12/arcobjects-workspace-is-down.html" target="_blank"&gt;Workspace is Down&lt;/a&gt; &lt;li&gt;Licensing  &lt;li&gt;Com Releaser  &lt;li&gt;Cursors and IsRecycling  &lt;li&gt;WorkspaceUtils  &lt;li&gt;Multithreading  &lt;li&gt;Mocking&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:568166b4-07ac-48b0-b117-69f1b5847b47" class="wlWriterSmartContent"&gt;IceRocket Tags: &lt;a href="http://blogs.icerocket.com/search?q=ArcObjects" rel="tag"&gt;ArcObjects&lt;/a&gt;&lt;/div&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=YJrFj_MJDUE:aJgWQSowObI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/YJrFj_MJDUE" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/3872939387466811192?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/3872939387466811192?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/YJrFj_MJDUE/list-of-arcobjects-posts-introduction.html" title="ArcObjects: TOC" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><feedburner:origLink>http://www.dllshepherd.net/2011/11/list-of-arcobjects-posts-introduction.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QGQ38yfSp7ImA9WhRXGEQ.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-8119981226122771388</id><published>2011-12-26T03:35:00.001-08:00</published><updated>2011-12-26T03:35:22.195-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-26T03:35:22.195-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SDE" /><category scheme="http://www.blogger.com/atom/ns#" term="ArcObjects" /><category scheme="http://www.blogger.com/atom/ns#" term="Exception" /><category scheme="http://www.blogger.com/atom/ns#" term="ESRI" /><title>ArcObjects: Workspace is Down</title><content type="html">&lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;This post is the sixth post in my &lt;a href="http://www.dllshepherd.net/2011/11/list-of-arcobjects-posts-introduction.html" target="_blank"&gt;ArcObjects series&lt;/a&gt;.&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;This is a direct continuation from my post &lt;a href="http://www.dllshepherd.net/2011/12/arcobjects-workspace-provider.html"&gt;ArcObjects: Workspace Provider&lt;/a&gt;.&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;Back in March our DB was down over the night and unlike all the other systems ours didn't just resume work after the DB was brought up, it needed the team’s involvement.&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;The Exception we got was:&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;System.Runtime.InteropServices.COMException was unhandled&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;HelpLink=esri_csGeoDatabase.hlp&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Message=Failure to access the DBMS server [Microsoft SQL Server Native Client 10.0: Communication link failure] [SERVER.SCHEMA.LAYER_NAME]&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Source=esriDataSourcesGDB.SdeWorkspace.1&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;ErrorCode=-2147155559&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;StackTrace:&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;at ESRI.ArcGIS.Geodatabase.IFeatureClass.Search(IQueryFilter filter, Boolean Recycling)&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;InnerException:&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&lt;font style="font-size: 11pt" color="#000000"&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;So I recreated the error by restarting the "SQL Server (MSSQLSERVER)" service in our DB with &lt;a href="http://www.dllshepherd.net/2011/03/restarting-sql-server-by-code.html" target="_blank"&gt;some special code&lt;/a&gt;. &lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt; unicode-bidi: embed; direction: ltr" dir="ltr" class="MsoNormal"&gt;&lt;strong&gt;&lt;u&gt;Symptoms:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p style="line-height: 13pt; text-indent: -18pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto; mso-list: l0 level1 lfo1" dir="ltr" class="MsoListParagraph"&gt;&lt;span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;1.&lt;span style="line-height: normal; font-family: "&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;The IWorkspace status:&lt;/p&gt; &lt;p style="line-height: normal; text-indent: 18pt; margin: 0cm 0cm 0pt 54pt; unicode-bidi: embed; direction: ltr; mso-layout-grid-align: none" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;((&lt;span&gt;IWorkspace&lt;/span&gt;) &lt;span&gt;_workspace&lt;/span&gt;).&lt;span&gt;Exists&lt;/span&gt;();&lt;/span&gt;&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto" dir="ltr" class="MsoListParagraphCxSpFirst"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Returns true&lt;/p&gt; &lt;p style="line-height: 13pt; text-indent: -18pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto; mso-list: l0 level1 lfo1" dir="ltr" class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;span style="mso-list: ignore"&gt;2.&lt;span style="line-height: normal; font-family: "&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;Then I started looking at other &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//002500000n8v000000"&gt;places&lt;/a&gt; like ESRI’s diagrams. One of the diagrams:&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto" dir="ltr" class="MsoListParagraphCxSpMiddle"&gt;&lt;a href="http://lh5.ggpht.com/_SU7V9sPwn1o/TSRyZbMfS0I/AAAAAAAAAc8/3IYTTtibLLw/s1600-h/image%5B3%5D.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://lh5.ggpht.com/_SU7V9sPwn1o/TSRyaNu4O-I/AAAAAAAAAdA/S7wTuEsoCNY/image_thumb%5B1%5D.png?imgmax=800" width="559" height="488"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p style="line-height: 13pt; text-indent: 36pt; margin: 0cm 0cm 10pt 144pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto" dir="ltr" class="MsoListParagraphCxSpMiddle"&gt;&lt;font style="font-size: 11pt" color="#000000"&gt;(Not mine EDN's)&lt;/font&gt;&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto" dir="ltr" class="MsoListParagraphCxSpMiddle"&gt;&lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IWorkspaceStatus_Interface/002500000mrn000000/"&gt;IWorkspaceStatus&lt;/a&gt; sounded a bit off to me that it is under WorkspaceFactory and not under Workspace but the real problem was what was written in &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IWorkspaceStatus_Interface/002500000mrn000000/"&gt;the documentation&lt;/a&gt;. There are no implementations of this according to EDN…&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto" dir="ltr" class="MsoListParagraphCxSpLast"&gt;But I found another interface &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IWorkspaceFactoryStatus_Interface/002500000mmz000000/"&gt;IWorkspaceFactoryStatus&lt;/a&gt;, managed to point it to my workspace and got back:&lt;/p&gt; &lt;p style="line-height: normal; margin: 0cm 0cm 0pt 72pt; unicode-bidi: embed; direction: ltr; mso-layout-grid-align: none" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;((ESRI.ArcGIS.Geodatabase.IWorkspaceFactoryStatus&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;)workspaceFactoryTemp).PingWorkspaceStatus((ESRI.ArcGIS.Geodatabase.IWorkspace)_workspace)&lt;/span&gt;&lt;/p&gt; &lt;p style="line-height: normal; margin: 0cm 0cm 0pt 72pt; unicode-bidi: embed; direction: ltr; mso-layout-grid-align: none" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;{System.__ComObject}&lt;/span&gt;&lt;/p&gt; &lt;p style="line-height: normal; margin: 0cm 0cm 0pt 72pt; unicode-bidi: embed; direction: ltr; mso-layout-grid-align: none" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font style="background-color: #ffffff"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[System.__ComObject]: {System.__ComObject}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="line-height: normal; margin: 0cm 0cm 0pt 72pt; unicode-bidi: embed; direction: ltr; background: #ffffff; mso-layout-grid-align: none" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font style="background-color: #ffffff"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ConnectionStatus: esriWCSAvailable&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="line-height: normal; margin: 0cm 0cm 0pt 72pt; unicode-bidi: embed; direction: ltr; mso-layout-grid-align: none" dir="ltr" class="MsoNormal"&gt;&lt;span style="font-family: "&gt;&lt;font style="background-color: #ffffff"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Workspace: {System.__ComObject}&lt;/font&gt;&lt;/span&gt;&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto" dir="ltr" class="MsoListParagraphCxSpFirst"&gt;&lt;font style="background-color: #ffffff"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto" dir="ltr" class="MsoListParagraphCxSpFirst"&gt;I just thought to myself how can it possibly be Available, until I look at the documentation at &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/esriWorkspaceConnectionStatus_Constants/0025000000m0000000/"&gt;esriWorkspaceConnectionStatus&lt;/a&gt;:&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto" dir="ltr" class="MsoListParagraphCxSpMiddle"&gt;&lt;a href="http://lh4.ggpht.com/_SU7V9sPwn1o/TSRyao9hq9I/AAAAAAAAAdE/4fxRyhZeAow/s1600-h/image%5B7%5D.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://lh4.ggpht.com/_SU7V9sPwn1o/TSRybtHBxKI/AAAAAAAAAdI/Qt3N9csoats/image_thumb%5B3%5D.png?imgmax=800" width="559" height="349"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 10pt 36pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto" dir="ltr" class="MsoListParagraphCxSpMiddle"&gt;Available doesn't mean it's up - just that it was lost and now is available. And I was sure it meant something else… (Couldn’t they name it something like LostAndNowAvailable or AvailableToReconnect? – Available just does not cut it!!!).&lt;/p&gt; &lt;p style="line-height: 13pt; margin: 0cm 0cm 0pt; unicode-bidi: embed; direction: ltr; mso-add-space: auto" dir="ltr" class="MsoListParagraphCxSpMiddle"&gt;&amp;nbsp;&lt;/p&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt;&lt;span style="color: #000000"&gt; &lt;p&gt;The end result looks like this:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2f36ecaf-79e0-4f73-aa0c-31803efd3ded" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (!IsWorkspaceRunning(_workspace))&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    ReactivateWorkspace();&lt;/li&gt; &lt;li class="even"&gt;    InitializeWorkspaceUtils(_workspace);&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; _workspaceUtils;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;Checking if the workspace is running:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ef350e04-2060-45d3-92d8-4a364e089763" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; IsWorkspaceRunning(&lt;span style="color:#2b91af"&gt;IWorkspace&lt;/span&gt; workspace)&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;IWorkspaceFactoryStatus&lt;/span&gt; workspaceFactory = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;SdeWorkspaceFactoryClass&lt;/span&gt;();&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; workspaceFactory.PingWorkspaceStatus(workspace).ConnectionStatus == &lt;span style="color:#2b91af"&gt;esriWorkspaceConnectionStatus&lt;/span&gt;.esriWCSUp &amp;amp;&amp;amp; workspace.Exists();&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;If it’s down recreate it (and if it can’t be recreated throw an exception):&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f13b6848-1df0-4e19-9270-78fd5f9134b0" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; ReactivateWorkspace()&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;IWorkspaceFactoryStatus&lt;/span&gt; workspaceFactory = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;SdeWorkspaceFactoryClass&lt;/span&gt;();&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; status = workspaceFactory.PingWorkspaceStatus(_workspace);&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (status.ConnectionStatus != &lt;span style="color:#2b91af"&gt;esriWorkspaceConnectionStatus&lt;/span&gt;.esriWCSDown)&lt;/li&gt; &lt;li class="even"&gt;    {&lt;/li&gt; &lt;li&gt;        _workspace = workspaceFactory.OpenAvailableWorkspace(status);&lt;/li&gt; &lt;li class="even"&gt;    }&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#008000"&gt;//try to create it again:&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    _workspace = CreateWorkspace(_connectionString);&lt;/li&gt; &lt;li class="even"&gt;    status = workspaceFactory.PingWorkspaceStatus(_workspace);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (status.ConnectionStatus == &lt;span style="color:#2b91af"&gt;esriWorkspaceConnectionStatus&lt;/span&gt;.esriWCSDown)&lt;/li&gt; &lt;li&gt;    {&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ApplicationException&lt;/span&gt;(&lt;span style="color:#a31515"&gt;&amp;quot;The Connection to the database was lost. Please contact your system administrators.&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li class="even"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;You can also look at the full code &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/view/11943#228389" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Hopefully next time the DB is down it will just recreate IWorksapce…&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://forums.arcgis.com/threads/20408-How-to-know-when-the-connection-to-SQL-server-was-lost?p=65919#post65919"&gt;The forum post I wrote&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=y2yLY9v1lEI:m86pSAq2lAQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/y2yLY9v1lEI" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/8119981226122771388?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/8119981226122771388?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/y2yLY9v1lEI/arcobjects-workspace-is-down.html" title="ArcObjects: Workspace is Down" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/_SU7V9sPwn1o/TSRyaNu4O-I/AAAAAAAAAdA/S7wTuEsoCNY/s72-c/image_thumb%5B1%5D.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2011/12/arcobjects-workspace-is-down.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0AGQ3c6eyp7ImA9WhRXGEQ.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-1703659166384929554</id><published>2011-12-26T01:28:00.001-08:00</published><updated>2011-12-26T01:28:42.913-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-26T01:28:42.913-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ArcObjects" /><category scheme="http://www.blogger.com/atom/ns#" term="ESRI" /><title>ArcObjects: Workspace Provider</title><content type="html">&lt;p&gt;This post is the fifth post in my &lt;a href="http://www.dllshepherd.net/2011/11/list-of-arcobjects-posts-introduction.html" target="_blank"&gt;ArcObjects series&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;As I mentioned in my previous post you cannot create a workspace you have to receive it from some place. That place is called the WorkspaceFactory (or as usual &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IWorkspaceFactory_Interface/002500000m9w000000/" target="_blank"&gt;IWorkspaceFactory&lt;/a&gt;).&amp;nbsp; Now since getting the workspace is useful and usually only done once we put it in a singleton class named WorkspaceProvider. &lt;/p&gt; &lt;p&gt;As can be seen in the &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IWorkspaceFactory_Interface/002500000m9w000000/" target="_blank"&gt;IWorkspaceFactory&lt;/a&gt; documentation there are many implementation of this interface. The implementation differ in the Space where the workspace is doing it’s work:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/001m/001m00000035000000.htm"&gt;SdeWorkspaceFactory&lt;/a&gt; – works on a Sde DB  &lt;li&gt;&lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/0019/001900000006000000.htm"&gt;CadWorkspaceFactory&lt;/a&gt; – works on CAD files  &lt;li&gt;&lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/001m/001m00000001000000.htm"&gt;AccessWorkspaceFactory&lt;/a&gt; and &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/001m/001m0000000p000000.htm"&gt;FileGDBWorkspaceFactory&lt;/a&gt; – work on File based Geodatabases&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;These classes provide the interface to connect to the Space the same way ArcDesktop tools do so by the Open method. You can either use a file containing the connection (created in ArcCatalog), use &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//004200000180000000" target="_blank"&gt;IPropertySet&lt;/a&gt; a list containing the connection information (see &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/Open_Method/002500000mnm000000/" target="_blank"&gt;here&lt;/a&gt; for details) or by using connection string (the other options just use this option behind the scene). &lt;/p&gt; &lt;p&gt;Sde connection string are separated to two categories (more details in one of my previous posts: &lt;a href="http://www.dllshepherd.net/2011/12/arcsde-connection-to-geodatabase.html" target="_blank"&gt;ArcSDE: Connection to the Geodatabase&lt;/a&gt;):&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Regular connection: "SERVER={0};INSTANCE={4};USER={2};PASSWORD={3};Database={1};VERSION=SDE.Default"  &lt;li&gt;Direct connection: "SERVER={0};INSTANCE=sde:{5}:{0};USER={2};PASSWORD={3};Database={1};VERSION=SDE.Default"&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Where:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;{0} – Server name  &lt;li&gt;{1} – Database name  &lt;li&gt;{2} – User name  &lt;li&gt;{3} – password  &lt;li&gt;{4} – Sde service number  &lt;li&gt;{5} – Type of the server (i.e. sqlserver)  &lt;li&gt;If you need to you can also add the Sde version &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;As you can see direct connection doesn’t use the Sde service number, that is because it doesn’t use the Sde service (it does all the work at the client). Most times you won’t need to change the Server type so that’s out as well. &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/view/11943#228934"&gt;My code&lt;/a&gt; only uses Direct Connection string (since ESRI recommends using it).&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;In my experience most applications will use only one IWorkspace – the one connecting them to the application Sde. For that reason WorkspaceProvider uses &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/view/11943#228934"&gt;DefaultDbConfigSection&lt;/a&gt; which is both a &lt;a href="http://msdn.microsoft.com/en-us/library/2tw134k3.aspx"&gt;Configuration Section&lt;/a&gt; and a Connection String builder (I use it for both the Sde and regular DB Connection string). To prevent unnecessary creation of IWorkspace objects WorkspaceProvider will also store the last IWorkspace created and the connection string used to create it.&lt;/p&gt; &lt;p&gt;As it is the only public methods needed for this class are:&lt;/p&gt; &lt;p&gt;1. Using Sde Connection String from web/app.config file:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c8ae367b-a5d4-4aaa-87bc-27df1502249a" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;WorkspaceUtils&lt;/span&gt; GetWorkspace()&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&amp;nbsp; &lt;p&gt;2. Using Sde Connection String provided:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9b6c6618-2273-4eff-a756-2bc92c183fa5" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;WorkspaceUtils&lt;/span&gt; GetWorkspace(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; sdeConnectionString)&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;3. Using a Cad file:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7ace0656-bbde-432c-a3d9-41127e62aa1c" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CadWorkspaceUtils&lt;/span&gt; GetCadWorkspace(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; path)&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;4. Using either GDB or MDB file paths:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d6559244-7743-4e00-b147-5887e28b0799" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;FileWorkspaceUtils&lt;/span&gt; GetFileWorkspace(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; filePath)&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The full code can be found &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/view/11943#228389"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Most of the code is self-explanatory except one part – getting a cached Workspace. Now you might think this is the most simple part but when taking into account that sometimes connections fail, servers are down and Murphy is constantly prowling than you must be ready for that “What If…”. I will write more on this in one of the next posts.&lt;/p&gt; &lt;p&gt;The rest of the code is pretty much self-explanatory and can be found in &lt;a href="http://dllshepherdsamples.codeplex.com/" target="_blank"&gt;my CodePlex Project&lt;/a&gt;, or directly &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/changes/11943"&gt;here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/2tw134k3.aspx"&gt;MSDN: How to: Create Custom Configuration Sections Using ConfigurationSection&lt;/a&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=SY3V5vwUeiU:exEA6ET9l18:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/SY3V5vwUeiU" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/1703659166384929554?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/1703659166384929554?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/SY3V5vwUeiU/arcobjects-workspace-provider.html" title="ArcObjects: Workspace Provider" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><feedburner:origLink>http://www.dllshepherd.net/2011/12/arcobjects-workspace-provider.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMFRX89cSp7ImA9WhRXEk4.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-608373287486787477</id><published>2011-12-18T09:46:00.000-08:00</published><updated>2011-12-18T09:46:54.169-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-18T09:46:54.169-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server 2008" /><category scheme="http://www.blogger.com/atom/ns#" term="SDE" /><category scheme="http://www.blogger.com/atom/ns#" term="Beginners" /><category scheme="http://www.blogger.com/atom/ns#" term="ESRI" /><title>ArcSDE: Connection to the Geodatabase</title><content type="html">&lt;p&gt;When connection to a database SDE there are two ways to achieve that:&lt;/p&gt; &lt;p&gt;&lt;img src="http://help.arcgis.com/en/arcgisdesktop/10.0/help/0029/GUID-6A721839-F5B1-40B7-88EA-0EE4EF61AA84-web.png"&gt;&lt;/p&gt; &lt;p&gt;(From &lt;a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00290000003q000000.htm" target="_blank"&gt;ESRI site&lt;/a&gt; the ArcCatalog connection screen)&lt;/p&gt; &lt;p&gt;1. Regular connection using Server, Service (enter the SDE service number), database, user(optional), password(optional)&lt;/p&gt; &lt;p&gt;The regular way uses a service on the database machine which must be running. The service can be found in:&lt;/p&gt; &lt;p&gt;Right click on My Computer –&amp;gt; Manage:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_SU7V9sPwn1o/TSmXMOrKglI/AAAAAAAAAmE/69TLS8Ljg5g/s1600-h/image%5B2%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 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://lh4.ggpht.com/_SU7V9sPwn1o/TSmXM5aDGiI/AAAAAAAAAmI/2oubg48jLBo/image_thumb.png?imgmax=800" width="332" height="245"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Computer Management –&amp;gt; Services And Applications –&amp;gt; Service:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_SU7V9sPwn1o/TSmXNY8iJwI/AAAAAAAAAmM/-HWrVgYD2js/s1600-h/image%5B5%5D.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; margin: 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://lh4.ggpht.com/_SU7V9sPwn1o/TSmXN8FLW0I/AAAAAAAAAmQ/IB98-RTkefQ/image_thumb%5B1%5D.png?imgmax=800" width="297" height="158"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;By Default the service will be called “ArcSde Service(esri_sde)”:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_SU7V9sPwn1o/TSmXOVsxX4I/AAAAAAAAAmU/Hsaky9X94Bw/s1600-h/image%5B9%5D.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://lh4.ggpht.com/_SU7V9sPwn1o/TSmXO6B_BJI/AAAAAAAAAmY/29IWlA3C9wg/image_thumb%5B3%5D.png?imgmax=800" width="559" height="61"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;As you can see I am not using the regular way (the service is not marked as started). For both 10 and 9.3.1 ESRI advices not to use it this way since it does all it’s work on the DB machine.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Note:&lt;/u&gt;&lt;/strong&gt; if you are using several sde services than the Service port will differ than the default of 5151. If you are unsure about the number than look in the DB server at services file (located at: c:\Windows\System32\drivers\etc and has no extension). The file contains lines for services, their port and connection protocol:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;esri_sde&amp;nbsp;&amp;nbsp;&amp;nbsp; 5151/tcp&amp;nbsp;&amp;nbsp;&amp;nbsp; #ArcSDE for SqlServer&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;2. Direct Connection using Server, Service, database, user(optional), password(optional)&lt;/p&gt; &lt;p&gt;The difference in the connection is only in Service, for example in SQL Server: “sde:sqlserver:&amp;lt;sql_server_instance&amp;gt;” (for any other server use &lt;a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Connecting_to_an_ArcSDE_geodatabase/006m0000006n000000/" target="_blank"&gt;this ESRI reference&lt;/a&gt; the forth step).&lt;/p&gt; &lt;p&gt;This connection doesn’t use the SDE service. It connects directly to the DB and does all it’s work on the client. If you are using only this connection type then I advise you to change the “ArcSde Service(esri_sde)” to run Manually instead of Automatic – it just means that at startup the service won’t be turned on.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h3&gt;&lt;u&gt;Managing SDE connection in a developer team&lt;/u&gt;&lt;/h3&gt; &lt;p&gt;I have created all my SDE connection but now my team mate Bob needs a connection, What do I do?&lt;/p&gt; &lt;p&gt;Well I usually save the connections in one of the team’s network folders with a bat file called install connections. Here is how I do that:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Copy all the connections from %APPDATA%\ESRI\Desktop10.0\ArcCatalog to your network folder.  &lt;li&gt;Create a bat file with:&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;xCopy *.sde %APPDATA%\ESRI\Desktop10.0\ArcCatalog /I&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;(The /I is for creating the sub folder when they don’t exist (like when you never opened ArcCatalog…))&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00290000003q000000.htm" target="_blank"&gt;ESRI: Geodatabase connections in ArcGIS Desktop&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/0029/00290000008v000000.htm" target="_blank"&gt;ESRI: Preparing database connection files&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/0029/00290000003v000000.htm" target="_blank"&gt;ESRI: What is a direct connection to a geodatabase in DB2?&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://ss64.com/nt/xcopy.html" target="_blank"&gt;Help about xCopy&lt;/a&gt;&lt;/p&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=PrrnrSLLvy4:Htmg0nl5euM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/PrrnrSLLvy4" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/608373287486787477?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/608373287486787477?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/PrrnrSLLvy4/arcsde-connection-to-geodatabase.html" title="ArcSDE: Connection to the Geodatabase" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/_SU7V9sPwn1o/TSmXM5aDGiI/AAAAAAAAAmI/2oubg48jLBo/s72-c/image_thumb.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2011/12/arcsde-connection-to-geodatabase.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0EDSHg-eCp7ImA9WhRXEkw.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-8628533655573666528</id><published>2011-12-18T06:47:00.001-08:00</published><updated>2011-12-18T06:47:59.650-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-18T06:47:59.650-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ArcGIS Server" /><category scheme="http://www.blogger.com/atom/ns#" term="ArcObjects" /><category scheme="http://www.blogger.com/atom/ns#" term="ESRI" /><title>MSD tools: Changing Connection and Publishing</title><content type="html">&lt;p&gt;Last month I got a new assignment to develop a tool that changes the layers’ connection in a MXD file and publish it in ArcGis Server. It is fairly easy to do it &lt;a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00sq00000018000000.htm" target="_blank"&gt;using ArcMap&lt;/a&gt; but we have too many environments/servers and whatever we can automate should be automated.&lt;/p&gt; &lt;p&gt;Since then the team went to a Systematics Event (ESRI local provider) where they talked about the new stuff in version 10.1, namely that &lt;a href="http://pdgisusers.org/2010/10/04/arcgis-10-0-and-10-1-deprecation-document/" target="_blank"&gt;publishing will only support MSD files (not MXD files)&lt;/a&gt; – so the task got changed a bit. For more information on &lt;a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00530000003t000000" target="_blank"&gt;MSD functionality&lt;/a&gt; and &lt;a href="http://resources.arcgis.com/content/enterprisegis/10.0/services_performance" target="_blank"&gt;Performance considerations&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Finding how to change the connection of the layers was easy enough with the &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IMSDHelper_Interface/001200000sr5000000/" target="_blank"&gt;IMSDHelper&lt;/a&gt; interface:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:84cfee01-7f4e-49ce-a8bc-81c83d863acc" class="wlWriterSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="padding-bottom: 0px; margin: 0px; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px"&gt; &lt;li&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; UseRelativePath = &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;  &lt;li class="even"&gt;&lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;const&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; ValidateLayerConnection = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;  &lt;li&gt;&amp;nbsp; &lt;li class="even"&gt;&lt;span style="color: #808080"&gt;///&lt;/span&gt;&lt;span style="color: #008000"&gt; &lt;/span&gt;&lt;span style="color: #808080"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;  &lt;li&gt;&lt;span style="color: #808080"&gt;///&lt;/span&gt;&lt;span style="color: #008000"&gt; Changes the SDE connection string for all the layers in the MSD file&lt;/span&gt;  &lt;li class="even"&gt;&lt;span style="color: #808080"&gt;///&lt;/span&gt;&lt;span style="color: #008000"&gt; &lt;/span&gt;&lt;span style="color: #808080"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;  &lt;li&gt;&lt;span style="color: #808080"&gt;///&lt;/span&gt;&lt;span style="color: #008000"&gt; &lt;/span&gt;&lt;span style="color: #808080"&gt;&amp;lt;param name="msdFilePath"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&lt;span style="color: #808080"&gt;///&lt;/span&gt;&lt;span style="color: #008000"&gt; &lt;/span&gt;&lt;span style="color: #808080"&gt;&amp;lt;param name="connectionString"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;  &lt;li&gt;&lt;span style="color: #808080"&gt;///&lt;/span&gt;&lt;span style="color: #008000"&gt; &lt;/span&gt;&lt;span style="color: #808080"&gt;&amp;lt;param name="resultMsdFile"&amp;gt;&lt;/span&gt;&lt;span style="color: #008000"&gt;result file is relative path&lt;/span&gt;&lt;span style="color: #808080"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ChangeConnection(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; msdFilePath, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; connectionString, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; resultMsdFile)  &lt;li&gt;{  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af"&gt;IMSDHelper&lt;/span&gt; helper = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;MSDHelper&lt;/span&gt;();  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; helper.Open(msdFilePath);  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; maps = helper.GetMaps();  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;var&lt;/span&gt; i = 0; i &amp;lt; maps.Count; i++)  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; layers = helper.GetLayers(maps.Element[i]);  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;for&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;var&lt;/span&gt; j = 0; j &amp;lt; layers.Count; j++)  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; helper.PutWorkspaceConnectionStringInLayer(layers.Element[j], connectionString, ValidateLayerConnection);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; helper.SaveAs(resultMsdFile, UseRelativePath);  &lt;li class="even"&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;We simply iterate through all the maps and all the inner layers and change the connection to the given one.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;But what about Publishing the MSD automatically? This proved to be a bit more problematic. It was fairly easy to find a &lt;a href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/PublishMSDToServer/00s300000021000000/" target="_blank"&gt;Python script using arcPy that publishes MSD files&lt;/a&gt;. But less so on ArcObjects code, in the end I found &lt;a href="http://forums.arcgis.com/threads/9383-Promote-map-service-from-one-server-stage-to-another-in-automated-fashion" target="_blank"&gt;this forum post&lt;/a&gt; which led me to &lt;a href="http://www.cnblogs.com/myGIS/articles/1636720.html" target="_blank"&gt;this code&lt;/a&gt; (just run it through Google Translate since it’s in Chinese). The code looks like this:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ba457b70-6165-4b16-9dbf-499211254f9f" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; PublishToServer(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; mapFilePath, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; serverName, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; serviceName)&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#2b91af"&gt;IGISServerConnection&lt;/span&gt; gisServerConnection = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;GISServerConnectionClass&lt;/span&gt;();&lt;/li&gt; &lt;li class="even"&gt;    gisServerConnection.Connect(serverName);&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; serverObjectAdmin = gisServerConnection.ServerObjectAdmin;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; configuration = (&lt;span style="color:#2b91af"&gt;IServerObjectConfiguration2&lt;/span&gt;)serverObjectAdmin.CreateConfiguration();&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#008000"&gt;// release the name of the Service, required&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    configuration.Name = serviceName;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#008000"&gt;// release the type of service, such as: MapServer, GeocodeServer&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    configuration.TypeName = ServiceConfigurationTypeName;&lt;/li&gt; &lt;li class="even"&gt;    configuration.Description = serviceName;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#008000"&gt;// Service Description&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    SetDefaultServerConfigurations(configuration, mapFilePath, serverName); &lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008000"&gt;// add service to the Server&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;    serverObjectAdmin.AddConfiguration(configuration);&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#008000"&gt;// start the service&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    serverObjectAdmin.StartConfiguration(configuration.Name, configuration.TypeName);&lt;/li&gt; &lt;li class="even"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;This is to set the default values of my organization:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7445d4b-c0cf-45f9-97b1-77b527e183a5" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px;"&gt;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; SetDefaultServerConfigurations(&lt;span style="color:#2b91af"&gt;IServerObjectConfiguration2&lt;/span&gt; configuration, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; mapFilePath, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; serverName)&lt;br&gt; {&lt;br&gt;     &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; properties = configuration.Properties;&lt;br&gt;     &lt;span style="color:#008000"&gt;// Set the path of the file&lt;/span&gt;&lt;br&gt;     properties.SetProperty(&lt;span style="color:#a31515"&gt;&amp;quot;FilePath&amp;quot;&lt;/span&gt;, mapFilePath);&lt;br&gt;     &lt;span style="color:#008000"&gt;// image output directory&lt;/span&gt;&lt;br&gt;     properties.SetProperty(&lt;span style="color:#a31515"&gt;&amp;quot;outputdir&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;c:&amp;#92;&amp;#92;arcgisserver&amp;#92;&amp;#92;arcgisoutput&amp;quot;&lt;/span&gt;);&lt;br&gt;     &lt;span style="color:#008000"&gt;// image output virtual path&lt;/span&gt;&lt;br&gt;     properties.SetProperty(&lt;span style="color:#a31515"&gt;&amp;quot;VirtualOutPutDir&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;http://&amp;quot;&lt;/span&gt; + serverName + &lt;span style="color:#a31515"&gt;&amp;quot;/arcgisoutput&amp;quot;&lt;/span&gt;);&lt;br&gt;     &lt;span style="color:#008000"&gt;// image type supported by&lt;/span&gt;&lt;br&gt;     properties.SetProperty(&lt;span style="color:#a31515"&gt;&amp;quot;SupportedImageReturnTypes&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515"&gt;&amp;quot;URL&amp;quot;&lt;/span&gt;);&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;(there are more settings that can be found &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/view/11600#210821"&gt;here&lt;/a&gt;)&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;I found that it is best to look at existing services, for that I added the capability of getting your service settings in XML format:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:21e38235-56b9-4874-9006-4f4857f62a74" class="wlWriterSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="padding-bottom: 0px; margin: 0px; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px"&gt; &lt;li&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; GetServiceConfiguration(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; serverName, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; serviceName)  &lt;li class="even"&gt;{  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af"&gt;IGISServerConnection&lt;/span&gt; gisServerConnection = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;GISServerConnectionClass&lt;/span&gt;();  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gisServerConnection.Connect(serverName);  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; serverObjectAdmin = gisServerConnection.ServerObjectAdmin;  &lt;li class="even"&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; configuration = (&lt;span style="color: #2b91af"&gt;IServerObjectConfiguration4&lt;/span&gt;)serverObjectAdmin.GetConfiguration(serviceName, ServiceConfigurationTypeName);  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; configuration.Serialize();  &lt;li class="even"&gt;} &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;The output of this method looks like this:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:60b13671-335f-4c94-b8f9-b233b39dea2c" class="wlWriterSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="padding-bottom: 0px; margin: 0px; padding-left: 5px; padding-right: 0px; background: #ffffff; padding-top: 0px"&gt; &lt;li&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ServerObjectConfiguration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Description&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;PublishDemoIi&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Description&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Properties&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;FilePath&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;C:\Install\MsdUtils\Demo.msd&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;FilePath&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;outputdir&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;c:\arcgisserver\arcgisoutput&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;outputdir&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;VirtualOutPutDir&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;http://server/arcgisoutput&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;VirtualOutPutDir&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;SupportedImageReturnTypes&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;URL&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;SupportedImageReturnTypes&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxImageHeight&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;2048&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxImageHeight&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxRecordCount&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;50000&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxRecordCount&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxBufferCount&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;100&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxBufferCount&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxImageWidth&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;2048&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxImageWidth&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;IsCached&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;IsCached&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;CacheOnDemand&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;CacheOnDemand&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;IgnoreCache&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;IgnoreCache&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ClientCachingAllowed&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ClientCachingAllowed&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;CacheDir&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;c:\arcgisserver\arcgiscache\GtmPublishDemoIi&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;CacheDir&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;SOMCacheDir&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;c:\arcgisserver\arcgiscache&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;SOMCacheDir&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;UseLocalCacheDir&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;UseLocalCacheDir&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Properties&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Extension&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TypeName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;FeatureServer&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;TypeName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Enabled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Enabled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Properties&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;EnableZDefaults&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;EnableZDefaults&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ZDefaultValue&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;0&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ZDefaultValue&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Properties&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Info&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WebEnabled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WebEnabled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;SupportsMSD&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;SupportsMSD&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WebCapabilities&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;Query&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WebCapabilities&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Info&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Extension&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp; &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Extension&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;TypeName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;...&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;TypeName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Enabled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;false&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Enabled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Properties&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Properties&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Info&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Info&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Extension&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;li&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Info&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WebEnabled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WebEnabled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WebCapabilities&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;Map,Query,Data&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WebCapabilities&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Info&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;IsPooled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;true&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;IsPooled&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MinInstances&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;1&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;MinInstances&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxInstances&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;2&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;MaxInstances&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;InstancesPerContainer&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;1&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;InstancesPerContainer&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;WaitTimeout&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;60&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;WaitTimeout&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;IdleTimeout&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;-1&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;IdleTimeout&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;UsageTimeout&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;600&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;UsageTimeout&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;CleanupTimeout&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;30&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;CleanupTimeout&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;ServiceKeepAliveInterval&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;-1&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ServiceKeepAliveInterval&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;StartupTimeout&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;300&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;StartupTimeout&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;Isolation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;high&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;Isolation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li class="even"&gt;&amp;nbsp; &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;StartupType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;automatic&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;StartupType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;li&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #a31515"&gt;ServerObjectConfiguration&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt; &lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;As you can see the properties in the XML correspond perfectly with the properties settings.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;To test the creation of the service you can look at ArcGis Server Manager:&lt;/p&gt; &lt;p&gt;http://ServerName/ArcGIS/manager/default.aspx&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-w7Wl9XJWy-A/Tu39CGTsHgI/AAAAAAAAB4c/2OE3DzEXcmg/s1600-h/ArcGisServerManagementService%25255B7%25255D.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="ArcGisServerManagementService" border="0" alt="ArcGisServerManagementService" src="http://lh5.ggpht.com/-K5msE5nd2zc/Tu39DNTPV8I/AAAAAAAAB4k/RcUIgwAJUjI/ArcGisServerManagementService_thumb%25255B4%25255D.png?imgmax=800" width="644" height="389"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Where you can tweak the settings (as you can see I had 5 tries till I got it right…).&lt;/p&gt; &lt;p&gt;Also you can test the service using the REST API :&lt;/p&gt; &lt;p&gt;http://ServerName/ArcGIS/rest/services&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-adc0h0A3Xvg/Tu39D15zGSI/AAAAAAAAB4s/eEdU6e8uxEA/s1600-h/ArcGisRestService%25255B7%25255D.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="ArcGisRestService" border="0" alt="ArcGisRestService" src="http://lh5.ggpht.com/-la_z5-P3fgQ/Tu39E19ocKI/AAAAAAAAB40/xUngYiPy3R4/ArcGisRestService_thumb%25255B4%25255D.png?imgmax=800" width="498" height="333"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Looking into the FeatureServer link you will find in the bottom “&lt;b&gt;Supported Operations: &lt;/b&gt;Query” where you can test the Feature service queries:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh6.ggpht.com/-mEi-jlEgWRE/Tu39GAocn2I/AAAAAAAAB48/3Q7PdJseGUI/s1600-h/FeatureServiceQuery%25255B6%25255D.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="FeatureServiceQuery" border="0" alt="FeatureServiceQuery" src="http://lh3.ggpht.com/-PQCm9CXsJuw/Tu39Gzkej7I/AAAAAAAAB5E/Mn0yzl51qz8/FeatureServiceQuery_thumb%25255B3%25255D.png?imgmax=800" width="500" height="484"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Some points:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Using PublishToServer needs MSD file located on the server.  &lt;li&gt;In order to use PublishToServer user must be an admin on the server (otherwise the call gisServerConnection.ServerObjectAdmin would fail)  &lt;li&gt;You must clear ArcGis rest API cache before using the service (or you won’t see it in the rest/services url) – for doing that automatically see my previous post: &lt;a href="http://www.dllshepherd.net/2011/11/clearing-arcgis-server-rest-api-cache.html" target="_blank"&gt;Clearing ArcGIS Server REST API Cache&lt;/a&gt; &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;I have posted the complete tool in my Codeplex project: &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/view/11600#210828" target="_blank"&gt;ArcGisServerTools&lt;/a&gt;, &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/view/11600#210823" target="_blank"&gt;MsdUtils&lt;/a&gt;, &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/view/11600#210821" target="_blank"&gt;ArcGisServerUtils&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://forums.arcgis.com/threads/9383-Promote-map-service-from-one-server-stage-to-another-in-automated-fashion"&gt;ArcGis Server Forum: Promote map service from one server stage to another in automated fashion?&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.cnblogs.com/myGIS/articles/1636720.html" target="_blank"&gt;Findleaf - Chinese Blog code&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://forums.arcgis.com/threads/23196-publish-mxd-to-server-in-arcobjects-c"&gt;ArcObjects Forum: Publish MXD to server in ArcObjects C#&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Keywords: MSD, ArcObjects, ArcGis Server, ESRI&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:295e1118-9070-41e8-ab87-b997360120eb" class="wlWriterSmartContent"&gt;IceRocket Tags: &lt;a href="http://blogs.icerocket.com/search?q=MSD" rel="tag"&gt;MSD&lt;/a&gt;,&lt;a href="http://blogs.icerocket.com/search?q=ArcObjects" rel="tag"&gt;ArcObjects&lt;/a&gt;,&lt;a href="http://blogs.icerocket.com/search?q=ArcGis+Server" rel="tag"&gt;ArcGis Server&lt;/a&gt;,&lt;a href="http://blogs.icerocket.com/search?q=ESRI" rel="tag"&gt;ESRI&lt;/a&gt;&lt;/div&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=kIu9E7_ikR8:KG1342oxTx8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/kIu9E7_ikR8" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/8628533655573666528?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/8628533655573666528?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/kIu9E7_ikR8/msd-tools-changing-connection-and.html" title="MSD tools: Changing Connection and Publishing" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-K5msE5nd2zc/Tu39DNTPV8I/AAAAAAAAB4k/RcUIgwAJUjI/s72-c/ArcGisServerManagementService_thumb%25255B4%25255D.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2011/12/msd-tools-changing-connection-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUBRX45eCp7ImA9WhRQFk0.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-6800581944083878013</id><published>2011-12-11T04:57:00.001-08:00</published><updated>2011-12-11T04:57:34.020-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-11T04:57:34.020-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Troubleshooting" /><title>Active Window Loses Focus problem (Full Screen minimizes)</title><content type="html">&lt;p&gt;For the past several years I have been having a problem with my home computer (Windows XP), the problem is not so severe just annoying (though I guess for some people it will be much more severe). My problem? from time to time the application I work on losses it’s focus for a second and then either: &lt;/p&gt; &lt;p&gt;a. gets it back (when it’s in windowed state)&amp;nbsp; &lt;/p&gt; &lt;p&gt;b. another application gets the focus (when it’s full screen applications). &lt;/p&gt; &lt;p&gt;My solution to the problem was using only windowed applications but it is too annoying when watching movies or sometimes impossible when playing games.&lt;/p&gt; &lt;p&gt;From time to time I would search the web for solutions and find forums that advise people to open Task Manager (or other similar applications) and just see what application is stealing the focus – the problem is you need to be fairly fast to catch the bugger (especially when games and movies demand your full attention). Other solutions were with specific applications that caused the problem like AVG anti virus (in one of its old versions). I have tried formatting the computer but the problem returned (meaning it must be some application I always use).&lt;/p&gt; &lt;p&gt;So I have decided to fix (or at least find the problematic application) myself. I first found a windows function that partially does what I wanted – &lt;a href="http://msdn.microsoft.com/en-us/library/ms633505(v=VS.85).aspx" target="_blank"&gt;GetForegroundWindow&lt;/a&gt;, then searching for it with C# I found a solution at &lt;a href="http://stackoverflow.com/questions/2635404/how-to-get-process-name-and-title-of-the-top-window-on-windows-c-sharp" target="_blank"&gt;StackOverflow site&lt;/a&gt; a bunch of invoke methods that return the current focused window information, all that was left was wrapping it in a console application and using it. &lt;/p&gt; &lt;p&gt;In the end running the little app at home found the problem:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;27/11/2011 20:22:10:C:\WINDOWS\System32\rasautou.exe -&amp;gt; Connecting Cables012...&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;For the past several years my computer has been the dial up computer for the internet. Cables012 is that connection. Thinking to solve connection problems I enabled “Establish a dial-up connection whenever a computer on my network attempts to access the Internet”:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/-tMAfqusP6no/TuSot_e1rbI/AAAAAAAAB4I/3Gd3ZuFOGBk/s1600-h/BeforeInternetConnection%25255B10%25255D.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="BeforeInternetConnection" border="0" alt="BeforeInternetConnection" src="http://lh4.ggpht.com/-0MiKcS_C74g/TuSou4q0nSI/AAAAAAAAB4Q/R9QHKios3gE/BeforeInternetConnection_thumb%25255B8%25255D.png?imgmax=800" width="433" height="484"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;I thought to myself that this option will just reconnect to the internet when the connection is down, well it does that and also steals the windows focus whenever it feels like and at exactly midnight it also activate what I like to call “Blinking Window Mode” when at least one window will appear in the general top left area of the screen and disappear before you can read what it says…&lt;/p&gt; &lt;p&gt;Well the fix was easy enough just uncheck this option and restart the connection. This whole thing was a surprise since I was sure I had some kind of funky spyware app installed which caused all of this… &lt;/p&gt; &lt;p&gt;I have added the source code for this little app to &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/view/11600#227443" target="_blank"&gt;my Codeplex project&lt;/a&gt;, and also a &lt;a href="http://dllshepherdsamples.codeplex.com/releases/view/78557" target="_blank"&gt;release exec&lt;/a&gt; (for the non programmers who reach this site). &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Keywords: Windows, Full Screen, Focus&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:5552deea-d141-4cfc-b9de-fa85e6ee344c" class="wlWriterEditableSmartContent"&gt;IceRocket Tags: &lt;a href="http://blogs.icerocket.com/search?q=Windows" rel="tag"&gt;Windows&lt;/a&gt;,&lt;a href="http://blogs.icerocket.com/search?q=Full+Screen" rel="tag"&gt;Full Screen&lt;/a&gt;,&lt;a href="http://blogs.icerocket.com/search?q=Focus" rel="tag"&gt;Focus&lt;/a&gt;&lt;/div&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=RAdUxGl8Wjk:LaMG9wbHkxI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/RAdUxGl8Wjk" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6800581944083878013?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6800581944083878013?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/RAdUxGl8Wjk/active-window-loses-focus-problem-full.html" title="Active Window Loses Focus problem (Full Screen minimizes)" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-0MiKcS_C74g/TuSou4q0nSI/AAAAAAAAB4Q/R9QHKios3gE/s72-c/BeforeInternetConnection_thumb%25255B8%25255D.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2011/12/active-window-loses-focus-problem-full.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QNQ3o5fyp7ImA9WhRREEs.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-8605600957026491078</id><published>2011-11-23T09:29:00.001-08:00</published><updated>2011-11-23T09:29:52.427-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-23T09:29:52.427-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ArcGIS Server" /><title>Clearing ArcGIS Server REST API Cache</title><content type="html">&lt;p&gt;Whenever you change a layer in the DB or publish a new server you might notice that the REST API will not automatically update. In order for it to update you might need to clear the REST API cache. &lt;/p&gt; &lt;p&gt;There are several ways to do so:&lt;/p&gt; &lt;h4&gt;&lt;u&gt;The default way:&lt;/u&gt;&lt;/h4&gt; &lt;p&gt;ArcGis Server comes with a REST API admin page, which can be found here:&lt;/p&gt; &lt;p&gt;&lt;a title="http://SERVERNAME/ArcGIS/rest/admin" href="http://SERVERNAME/ArcGIS/rest/admin"&gt;http://SERVERNAME/ArcGIS/rest/admin&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Logging in to this page gives you the Clear Cache Options:&lt;/p&gt; &lt;p&gt;&lt;img src="http://lh3.ggpht.com/-U5brGWzk7_M/Ts0kvV1QqJI/AAAAAAAAB3w/hTG1KQXku9U/rest-api-admin-options_thumb%25255B2%25255D.png"&gt;&lt;/p&gt; &lt;p&gt;The page has a bunch of options for clearing the catch semi-automatically:&lt;/p&gt; &lt;p&gt;&lt;img src="http://lh6.ggpht.com/-VlnJZWyOGXg/Ts0kxEDIt1I/AAAAAAAAB4A/ZeHUP7p8VGw/Clear-cache-options_thumb%25255B2%25255D.png"&gt;&lt;/p&gt; &lt;p&gt;What you need to do is simply click on the "Clear Cache Now" several times (at some version of the Server one time was not enough…).&lt;/p&gt; &lt;p&gt;&lt;u&gt;Disadvantages:&lt;/u&gt;&lt;/p&gt; &lt;p&gt;1. You need to have the admin user/password in order to clear the cache&lt;br&gt;2. The process needs to be done manually.&lt;br&gt;3. If you have multiple server you will have to do so for each server&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;&lt;u&gt;The token way:&lt;/u&gt;&lt;/h4&gt; &lt;p&gt;ESRI gives another way which is to use a generated token and then you can simply call a link whenever you want to clear the cache. More on that &lt;a href="http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2010/10/08/Clearing-the-ArcGIS-Services-Directory-cache-_2200_the-easy-way_2200_.aspx" target="_blank"&gt;here&lt;/a&gt; (ESRI refers to this method as “the easy way”).&lt;/p&gt; &lt;p&gt;&lt;u&gt;Disadvantages:&lt;/u&gt;&lt;/p&gt; &lt;p&gt;1. Different token for each server&lt;br&gt;2. The process needs to be manually set at each server&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;h4&gt;&lt;u&gt;With Console Application (with code):&lt;/u&gt;&lt;/h4&gt; &lt;p&gt;The problem with all of these methods is that you can’t really use them to install servers, at my company we have more servers then flies and having to clear the cache after each installation is tedious work that is often forgotten (and when it is forgotten I find myself wasting hours trying to debug the “problem”). So I decided to write a console application that does the clearing of the cache for me. This idea actually came from &lt;a href="http://forumsstg.arcgis.com/threads/6654-Question-about-clearing-the-cache" target="_blank"&gt;this forum post&lt;/a&gt;, the only problem was that the code didn’t really work for me…&lt;/p&gt; &lt;p&gt;So I tweaked it a bit with &lt;a href="http://www.hanselman.com/blog/HTTPPOSTsAndHTTPGETsWithWebClientAndCAndFakingAPostBack.aspx" target="_blank"&gt;WebRequest&lt;/a&gt; and the end result is this:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3e8eae22-11e7-429c-82f3-b475e8fb5d4a" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; ClearCache(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; serverName, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; userName, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; password)&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; result = &lt;span style="color:#2b91af"&gt;HttpUtils&lt;/span&gt;.PostRequest(&lt;span style="color:#a31515"&gt;&amp;quot;http://&amp;quot;&lt;/span&gt; + serverName + &lt;span style="color:#a31515"&gt;&amp;quot;/ArcGIS/rest/admin/login&amp;quot;&lt;/span&gt;,&lt;/li&gt; &lt;li class="even"&gt;                            &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;KeyValuePair&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;&amp;gt;&lt;/li&gt; &lt;li&gt;                                {&lt;/li&gt; &lt;li class="even"&gt;                                    &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;KeyValuePair&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="color:#a31515"&gt;&amp;quot;username&amp;quot;&lt;/span&gt;, userName),&lt;/li&gt; &lt;li&gt;                                    &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;KeyValuePair&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="color:#a31515"&gt;&amp;quot;password&amp;quot;&lt;/span&gt;, password),&lt;/li&gt; &lt;li class="even"&gt;                                    &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;KeyValuePair&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;(&lt;span style="color:#a31515"&gt;&amp;quot;redirect&amp;quot;&lt;/span&gt;, &lt;span style="color:#2b91af"&gt;String&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;&amp;quot;http%3a%2f%2f{0}%2fArcGIS%2frest%2fadmin%2fcache%2fclear&amp;quot;&lt;/span&gt;, serverName)),&lt;/li&gt; &lt;li&gt;                                }, &lt;span style="color:#2b91af"&gt;String&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;&amp;quot;http://srvp7d-gtm/ArcGIS/rest/admin/login?redirect=http%3a%2f%2f{0}%2fArcGIS%2frest%2fadmin%2fcache%2fclear&amp;quot;&lt;/span&gt;, serverName));&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008000"&gt;//The response is in html, only return the response if its not a success&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; result.Contains(&lt;span style="color:#a31515"&gt;&amp;quot;Cache Cleared.&amp;quot;&lt;/span&gt;) ? &lt;span style="color:#a31515"&gt;&amp;quot;Cache Cleared.&amp;quot;&lt;/span&gt; : result;&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;And HttpUtils.PostRequest looks like:&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5148dd74-57c5-4a17-b59c-6ccdf6bbfed2" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; PostRequest(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; url, &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;KeyValuePair&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;&amp;gt; paramters, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; referer)&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; req = &lt;span style="color:#2b91af"&gt;WebRequest&lt;/span&gt;.Create(url);&lt;/li&gt; &lt;li class="even"&gt;    req.ContentType = &lt;span style="color:#a31515"&gt;&amp;quot;application/x-www-form-urlencoded&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;    req.Method = &lt;span style="color:#a31515"&gt;&amp;quot;POST&amp;quot;&lt;/span&gt;;&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; parameters = GetParameters(paramters);&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#008000"&gt;//We need to count how many bytes we&amp;#39;re sending. &lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; bytes = &lt;span style="color:#2b91af"&gt;Encoding&lt;/span&gt;.ASCII.GetBytes(parameters);&lt;/li&gt; &lt;li&gt;    req.ContentLength = bytes.Length;&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    ((&lt;span style="color:#2b91af"&gt;HttpWebRequest&lt;/span&gt;)req).CookieContainer = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CookieContainer&lt;/span&gt;();&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (!&lt;span style="color:#2b91af"&gt;String&lt;/span&gt;.IsNullOrEmpty(referer))&lt;/li&gt; &lt;li&gt;        ((&lt;span style="color:#2b91af"&gt;HttpWebRequest&lt;/span&gt;)req).Referer = referer;&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; os = req.GetRequestStream();&lt;/li&gt; &lt;li class="even"&gt;    os.Write(bytes, 0, bytes.Length); &lt;span style="color:#008000"&gt;//Push it out there&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    os.Close();&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; resp = req.GetResponse();&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (resp == &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; sr = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;StreamReader&lt;/span&gt;(resp.GetResponseStream());&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; sr.ReadToEnd().Trim();&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;I think that this way is the best since all I need is the server name, the admin user and it’s password. I can do it remotely and I can do it automatically after each deploy. The only thing that is not so good is the using of the clear password (and lets be honest here the next step is putting the call to the console application in a batch file for the development environment and giving that file to the rest of the team so that a hacker…).&lt;/p&gt; &lt;p&gt;Source code can be found at &lt;a href="http://dllshepherdsamples.codeplex.com/" target="_blank"&gt;my Codeplex project&lt;/a&gt;, &lt;a href="http://dllshepherdsamples.codeplex.com/SourceControl/changeset/changes/11149" target="_blank"&gt;here&lt;/a&gt; (the code has a few more useful commands like publishing a MSD file, changing the connection of MSD file etc.).&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;u&gt;Resources:&lt;/u&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2010/10/08/Clearing-the-ArcGIS-Services-Directory-cache-_2200_the-easy-way_2200_.aspx" target="_blank"&gt;Clearing the ArcGIS Services Directory cache “the easy way” – ArcGIS Server Blog&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://forumsstg.arcgis.com/threads/6654-Question-about-clearing-the-cache" target="_blank"&gt;Clear cache through code by demand – ArcGis Server Forum&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.hanselman.com/blog/HTTPPOSTsAndHTTPGETsWithWebClientAndCAndFakingAPostBack.aspx" target="_blank"&gt;Hanselman: HTTP POSTs and HTTP GETs with WebClient and C# and Faking a PostBack&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Keywords: ESRI,ArcGIS Server,REST API&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4066aa08-0e90-4fec-ba01-aef26a9bf0c9" class="wlWriterEditableSmartContent"&gt;IceRocket Tags: &lt;a href="http://blogs.icerocket.com/search?q=ESRI" rel="tag"&gt;ESRI&lt;/a&gt;,&lt;a href="http://blogs.icerocket.com/search?q=ArcGIS+Server" rel="tag"&gt;ArcGIS Server&lt;/a&gt;,&lt;a href="http://blogs.icerocket.com/search?q=REST+API" rel="tag"&gt;REST API&lt;/a&gt;&lt;/div&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=HfvQmttQaA8:GyesjOmeb4w:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/HfvQmttQaA8" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/8605600957026491078?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/8605600957026491078?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/HfvQmttQaA8/clearing-arcgis-server-rest-api-cache.html" title="Clearing ArcGIS Server REST API Cache" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-U5brGWzk7_M/Ts0kvV1QqJI/AAAAAAAAB3w/hTG1KQXku9U/s72-c/rest-api-admin-options_thumb%25255B2%25255D.png" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2011/11/clearing-arcgis-server-rest-api-cache.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4MSXg_fSp7ImA9WhRSE0s.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-7981317031718509368</id><published>2011-11-15T04:42:00.000-08:00</published><updated>2011-11-15T04:43:08.645-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-15T04:43:08.645-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ArcObjects" /><category scheme="http://www.blogger.com/atom/ns#" term="ESRI" /><title>ArcObjects: Workspace</title><content type="html">&lt;p&gt;This post is the forth post in my &lt;a href="http://www.dllshepherd.net/2011/11/list-of-arcobjects-posts-introduction.html" target="_blank"&gt;ArcObjects series&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;As I have written in &lt;a href="http://www.dllshepherd.net/2011/05/arcobjects-introduction.html"&gt;ArcObjects: Introduction&lt;/a&gt;, using ArcObjects is one way of performing CRUD operations against a Spatial DB (with SDE layer on top) and the way to do that is by using the intefaces of &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/WorkspaceClass_Class/002500000n73000000/" target="_blank"&gt;WorkspaceClass&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;ESRI definition for the Workspace is this:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;A Workspace is a container of spatial and non-spatial datasets such as feature classes, raster datasets and tables. It provides methods to instantiate existing datasets and to create new datasets.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Mine is a bit more simple, the &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/WorkspaceClass_Class/002500000n73000000/" target="_blank"&gt;WorkspaceClass&lt;/a&gt; is the class that does all the “work” within the “space” it is defined to work at. The Space section of the definition can be a DB Sde, File Geodatabase, Cad files and anything else ArcDesktop applications can open. The Work section refers to any &lt;strong&gt;&lt;u&gt;basic&lt;/u&gt;&lt;/strong&gt; action that can be done with ArcDesktop applications. &lt;/p&gt; &lt;p&gt;For example: &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IFeatureWorkspace_Interface/002500000317000000/" target="_blank"&gt;IFeatureWorkspace&lt;/a&gt; allows you to create a new Feature Table, open an existing Feature Table and with the help of &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//0025000002qs000000" target="_blank"&gt;IFeatureClass&lt;/a&gt; perform CRUD operations on that table. &lt;/p&gt; &lt;p&gt;One important note however is that you cannot create a new instance of it, it must be returned for you – the next post will be on getting the workspace.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-JgVF_ByFtxA/TsJeV_9NXyI/AAAAAAAAB3U/cVSY0rLmSQc/s1600-h/WorkspaceClass-Object%25255B8%25255D.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="WorkspaceClass-Object" border="0" alt="WorkspaceClass-Object" src="http://lh6.ggpht.com/-5HsbuFjpju8/TsJeWtqxyLI/AAAAAAAAB3c/zH9Wn9OWlS8/WorkspaceClass-Object_thumb%25255B5%25255D.png?imgmax=800" width="312" height="643"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As you can see the &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/WorkspaceClass_Class/002500000n73000000/" target="_blank"&gt;WorkspaceClass&lt;/a&gt; implements a lot of interfaces, the good news is you don’t need most of them (I have only found usage for two of them). &lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;What do you need then?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt; &lt;li&gt;&lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IFeatureWorkspace_Interface/002500000317000000/" target="_blank"&gt;IFeatureWorkspace&lt;/a&gt; – probably the most important interface, will allow you to edit features in the Space section&lt;/li&gt; &lt;li&gt;&lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IWorkspaceDomains_Interface/002500000m58000000/" target="_blank"&gt;IWorkspaceDomains&lt;/a&gt; – allows the creation, deletion of domains (important only if you want to automate the deployment process and using domains)&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;strong&gt;&lt;u&gt;So how do we use it?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:94905d96-7faa-4ffc-a206-6698826e9e27" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff"&gt;internal&lt;/span&gt; &lt;span style="color:#0000ff"&gt;readonly&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IFeatureWorkspace&lt;/span&gt; _workspace;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;/p&gt; &lt;p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:18c32dc0-678a-469c-9ec3-d206f3b48343" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;protected&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IFeatureClass&lt;/span&gt; GetFeatureClass(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; layerName)&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; _workspace.OpenFeatureClass(layerName);&lt;/li&gt; &lt;li class="even"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;/p&gt; &lt;p&gt;This actually the only thing you can do with just the &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IFeatureWorkspace_Interface/002500000317000000/" target="_blank"&gt;IFeatureWorkspace&lt;/a&gt;, but if you actually want to do something like&amp;nbsp; return all the feature in a layer you need to use the &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IFeatureClass_Interface/0025000002qs000000/" target="_blank"&gt;IFeatureClass&lt;/a&gt;:&lt;/p&gt; &lt;p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:efc8dfba-6ed9-4248-8ebe-d2986ab66d4d" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;const&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; IsRecyclingCursorInGetFeatures = &lt;span style="color:#0000ff"&gt;false&lt;/span&gt;;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e80b262b-8d3d-4d40-8821-53cae0961461" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #fff; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IQueryFilter&lt;/span&gt; GetQueryFilter(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; whereClause)&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;QueryFilter&lt;/span&gt; {WhereClause = whereClause};&lt;/li&gt; &lt;li class="even"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6a52348f-414b-4114-86b6-7e6023e2efe3" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;protected&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;IFeature&lt;/span&gt;&amp;gt; GetLayerFeatures(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; layerName)&lt;/li&gt; &lt;li class="even"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; result = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af"&gt;IFeature&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; filter = GetQueryFilter(EmptyWhereClause);&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; featureClass = GetFeatureClass(layerName);&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;using&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; comReleaser = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ComReleaser&lt;/span&gt;())&lt;/li&gt; &lt;li&gt;    {&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; cursor = featureClass.Search(filter, IsRecyclingCursorInGetFeatures);&lt;/li&gt; &lt;li&gt;        comReleaser.ManageLifetime(cursor);&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff"&gt;var&lt;/span&gt; feature = cursor.NextFeature();&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff"&gt;while&lt;/span&gt; (feature != &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;        {&lt;/li&gt; &lt;li class="even"&gt;            result.Add(feature);&lt;/li&gt; &lt;li&gt;            feature = cursor.NextFeature();&lt;/li&gt; &lt;li class="even"&gt;        }&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; result;&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;p&gt;So what do we have here?&lt;/p&gt; &lt;p&gt;line 4: creates the &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IQueryFilter_Interface/0025000006mr000000/" target="_blank"&gt;IQueryFilter&lt;/a&gt; – this goes into the where clause of the SQL we will send to DB.&lt;/p&gt; &lt;p&gt;line 5: we get the &lt;a href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IFeatureClass_Interface/0025000002qs000000/" target="_blank"&gt;IFeatureClass&lt;/a&gt; of the layer&lt;/p&gt; &lt;p&gt;line 6 and 9: this is important ArcObjects use Com which is a resource, every resource we use &lt;strong&gt;&lt;u&gt;must&lt;/u&gt;&lt;/strong&gt; be disposed. At kine 6 we create the disposing class and in line 9 we attach the cursor to that disposing class, when line 17 arrives the using statement will call the Dispose method for ComReleaser&amp;nbsp; and automatically dispose our cursor. More on cursor and disposing of the resources will be written in a later post.&lt;/p&gt; &lt;p&gt;line 8: creates the cursor that we will use to iterate the rows of the DB, IsRecyclingCursorInGetFeatures defines the way the cursor works (more on that on a later post) &lt;/p&gt; &lt;p&gt;lines 12-16: iterating the data&lt;/p&gt;    &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;And that’s it. &lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:4d67b189-4edd-4927-93dc-286de2bf56a1" class="wlWriterEditableSmartContent"&gt;IceRocket Tags: &lt;a href="http://blogs.icerocket.com/search?q=ArcObjects" rel="tag"&gt;ArcObjects&lt;/a&gt;,&lt;a href="http://blogs.icerocket.com/search?q=Workspace" rel="tag"&gt;Workspace&lt;/a&gt;&lt;/div&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=wlz3avv_Tdk:1e75k2Dq_Hs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/wlz3avv_Tdk" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/7981317031718509368?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/7981317031718509368?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/wlz3avv_Tdk/this-post-is-forth-post-in-my.html" title="ArcObjects: Workspace" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-5HsbuFjpju8/TsJeWtqxyLI/AAAAAAAAB3c/zH9Wn9OWlS8/s72-c/WorkspaceClass-Object_thumb%25255B5%25255D.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2011/11/this-post-is-forth-post-in-my.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEEDQX49cCp7ImA9WhdbEks.&quot;"><id>tag:blogger.com,1999:blog-1952747285294462312.post-6522004482598535784</id><published>2011-10-10T09:04:00.000-07:00</published><updated>2011-10-10T09:04:30.068-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-10T09:04:30.068-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="General" /><title>Simple Web Mapping</title><content type="html">&lt;p&gt;A friend of mine called me a few months ago and asked for advice on implementing a simple mapping application on the web. He remembered I worked on a mapping project and wanted my help.&lt;/p&gt; &lt;p&gt;His client wanted him to implement a web based site with a map of the client stores. The map should be customizable, meaning you could add items and remove them. And when I write map I mean a map of the interior of the store not it’s location in the world.&lt;/p&gt; &lt;p&gt;Now all the mapping options I know of are bulky and not quite simple but I promised him I will look it up for him.&lt;/p&gt; &lt;p&gt;The first thing I did was Googling “web simple map” got myself this results:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://gis.stackexchange.com/questions/2800/suggestions-for-simple-mapping-platform-for-alumni-web-site"&gt;http://gis.stackexchange.com/questions/2800/suggestions-for-simple-mapping-platform-for-alumni-web-site&lt;/a&gt; uses Google maps to store the location of people  &lt;li&gt;&lt;a href="http://developers.cloudmade.com/projects/web-maps-api/examples"&gt;http://developers.cloudmade.com/projects/web-maps-api/examples&lt;/a&gt;&amp;nbsp;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;But the options were neither simple nor easy to implement. &lt;/p&gt; &lt;p&gt;Then I got back to the requirements – mapping a store. That is almost like my B.A. final project of internal design for apartments, that had a 3D look to it but the design mode was at it’s base a 2D painter. And that is what the requirements wanted a Painter that has only basic drawing tools like placing certain items on the canvas.&lt;/p&gt; &lt;p&gt;The background for this application will be an image of the store. Saving the canvas will save the items’ locations in the canvas, while loading will repaint them in place. &lt;/p&gt; &lt;p&gt;And the best part there is already an open source Painter application around in Java Script &lt;a href="http://canvaspaint.org/" target="_blank"&gt;Called Canvas Paint&lt;/a&gt; (a copy of Microsoft’s Paint application in the Web) the script is also included &lt;a href="http://canvaspaint.org/paint.js" target="_blank"&gt;here&lt;/a&gt;:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_SU7V9sPwn1o/TWA83guE09I/AAAAAAAABdk/9p2LqgzTUpU/s1600-h/web-painter%5B6%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="web-painter" border="0" alt="web-painter" src="http://lh6.ggpht.com/_SU7V9sPwn1o/TWA84UW0auI/AAAAAAAABdo/mu4yhrYO7LI/web-painter_thumb%5B3%5D.png?imgmax=800" width="644" height="328"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;The File-&amp;gt;Save option allow saving the image on the server…&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;In the end my friend decided to create a demo using &lt;a href="http://www.mapsalive.com/" target="_blank"&gt;this site&lt;/a&gt;, which allows you to place points on an image:&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_SU7V9sPwn1o/TWA85gg8nVI/AAAAAAAABds/fHOQz5OMav4/s1600-h/mapsalive-floor-plan%5B4%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="mapsalive-floor-plan" border="0" alt="mapsalive-floor-plan" src="http://lh3.ggpht.com/_SU7V9sPwn1o/TWA86zkXf7I/AAAAAAAABdw/K9Fy6dng8BA/mapsalive-floor-plan_thumb%5B1%5D.png?imgmax=800" width="477" height="484"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;(when the mouse is over a point you get a tooltip with an image)&lt;/p&gt; &lt;p&gt;If the client likes it he will actually program something similar.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;So, I guess what I am saying is check out the requirements before you jump to implementing a GIS solution. Mapping for the client doesn’t always mean using world coordinates (and often the client won’t even know what world coordinates mean).&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Keywords: mapping, simple, paint&lt;/p&gt; &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c5fd5564-8dc0-4d47-927a-2e5907bb9d75" class="wlWriterSmartContent"&gt;IceRocket Tags: &lt;a href="http://blogs.icerocket.com/search?q=mapping" rel="tag"&gt;mapping&lt;/a&gt;,&lt;a href="http://blogs.icerocket.com/search?q=simple" rel="tag"&gt;simple&lt;/a&gt;,&lt;a href="http://blogs.icerocket.com/search?q=paint" rel="tag"&gt;paint&lt;/a&gt;&lt;/div&gt;  &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/dllshepherdDomain?a=KhqAcmT0_oc:qHOkFfkrv0Y:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/dllshepherdDomain?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/dllshepherdDomain/~4/KhqAcmT0_oc" height="1" width="1"/&gt;</content><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6522004482598535784?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1952747285294462312/posts/default/6522004482598535784?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/dllshepherdDomain/~3/KhqAcmT0_oc/simple-web-mapping.html" title="Simple Web Mapping" /><author><name>Roy Dallal</name><uri>http://www.blogger.com/profile/00119182637862451390</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://4.bp.blogspot.com/_SU7V9sPwn1o/TQybJawk_YI/AAAAAAAAAAQ/m8wxSB_We1Q/S220/MyPhoto.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/_SU7V9sPwn1o/TWA84UW0auI/AAAAAAAABdo/mu4yhrYO7LI/s72-c/web-painter_thumb%5B3%5D.png?imgmax=800" height="72" width="72" /><feedburner:origLink>http://www.dllshepherd.net/2011/02/simple-web-mapping.html</feedburner:origLink></entry></feed>
