<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Damon Armstrong</title><subtitle type="html">Caffeine Induced Tirades about .NET and Life</subtitle><id>http://www.simple-talk.com/community/blogs/damon_armstrong/atom.aspx</id><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/default.aspx" /><link rel="self" type="application/atom+xml" href="http://www.simple-talk.com/community/blogs/damon_armstrong/atom.aspx" /><generator uri="http://communityserver.org" version="2.0.60217.2664">Community Server</generator><updated>2010-08-17T02:50:51Z</updated><entry><title>Getting the URL to the Content Type Hub Programmatically in SharePoint 2010</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2012/02/07/105921.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2012/02/07/105921.aspx</id><published>2012-02-07T17:23:38Z</published><updated>2012-02-07T17:23:38Z</updated><content type="html">&lt;p&gt;Many organizations use the content-type hub to manage content-types in their SharePoint 2010 environment.&amp;#160; As a developer in these types of organizations, you may one day find yourself in need of getting the URL of the content type hub programmatically.&amp;#160; Here is a quick snippet that demonstrates how to do it fairly painlessly:&lt;/p&gt;  &lt;p&gt;&lt;code&gt;public static Uri GetContentTypeHubUri(SPSite site)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; TaxonomySession session = new TaxonomySession(site);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return Session.&lt;/code&gt;&lt;code&gt;DefaultSiteCollectionTermStore     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/code&gt;&lt;code&gt;.ContentTypePublishingHub;     &lt;br /&gt;}&lt;/code&gt;&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=105921" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>Retrieving Passwords from Managed Accounts in SharePoint 2010 for C#</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2012/01/06/105198.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2012/01/06/105198.aspx</id><published>2012-01-06T15:17:00Z</published><updated>2012-01-06T15:17:00Z</updated><content type="html">&lt;p&gt;I was looking for a way to retrieve a password from a managed account when I ran into a post titled &lt;a href="http://www.sharepointlonghorn.com/Lists/Posts/Post.aspx?ID=11"&gt;How to: Get Your Managed Account Passwords When They are Changed Automatically by SharePoint 2010&lt;/a&gt; by Jason Himmelstein.  It was written for PowerShell and I needed in C#, so I figured I would post the converted code in case anyone was looking for the same thing.  You will need to have the following using statements:&lt;/p&gt; &lt;code&gt;using System.Runtime.InteropServices;    &lt;br /&gt;using Microsoft.SharePoint.Administration; &lt;/code&gt;  &lt;p&gt;Then you can use the following code to retrieve the managed password:&lt;/p&gt;  &lt;p&gt;&lt;code&gt;var managedAccounts = new SPFarmManagedAccountCollection(SPFarm.Local);     &lt;br /&gt;&lt;/code&gt;&lt;code&gt;foreach (SPManagedAccount managedAccount in managedAccounts)      &lt;br /&gt;{  &lt;br /&gt;  var securePassword = (SPEncryptedString)managedAccount      &lt;br /&gt;&lt;/code&gt;&lt;code&gt;    .GetType()     &lt;br /&gt;    .GetField("m_Password",  &lt;br /&gt;      System.Reflection.BindingFlags.GetField |      &lt;br /&gt;      System.Reflection.BindingFlags.Instance |      &lt;br /&gt;      System.Reflection.BindingFlags.NonPublic)       &lt;br /&gt;    .GetValue(managedAccount);       &lt;br /&gt;      &lt;br /&gt;  var intptr = System.IntPtr.Zero;       &lt;br /&gt;  var unmanagedString = Marshal.      &lt;br /&gt;    SecureStringToGlobalAllocUnicode(securePassword.SecureStringValue);      &lt;br /&gt;&lt;/code&gt;&lt;code&gt;     &lt;br /&gt;  var unsecureString = Marshal.PtrToStringUni(unmanagedString);      &lt;br /&gt;  Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);  &lt;br /&gt;      &lt;br /&gt;&lt;/code&gt;&lt;code&gt;  //Do something with unsecureString      &lt;br /&gt;} &lt;/code&gt;&lt;/p&gt;  &lt;p&gt;One caveat to this is that you must be running as a Farm Administrator for the code to succeed.  Otherwise you will get an error about accessing the registry.  It is also relying on reflection to retrieve a non-public internal field, so as my friend Jeff Burt was quick to point out, Microsoft could change it at any time and break this code.  Probably not good for production code.&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=105198" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>SharePoint 2010 HierarchicalConfig Caching Problem</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2011/10/28/104048.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2011/10/28/104048.aspx</id><published>2011-10-29T03:58:02Z</published><updated>2011-10-29T03:58:02Z</updated><content type="html">&lt;p&gt;We've started using the &lt;a href="http://msdn.microsoft.com/en-us/library/ff798371.aspx"&gt;Application Foundations for SharePoint 2010&lt;/a&gt; in some of our projects at work, and I came across a nasty issue with the hierarchical configuration settings.&amp;#160; I have some settings that I am storing at the Farm level, and as I was testing my code it seemed like the settings were not being saved - at least that is what it appeared was the case at first.&amp;#160; &lt;/p&gt;  &lt;p&gt;However, I happened to reset IIS and the settings suddenly appeared.&amp;#160; Immediately, I figured that it must be a caching issue and dug into the code base.&amp;#160; I found that there was a 10 second caching mechanism in the SPFarmPropertyBag and the SPWebAppPropertyBag classes.&amp;#160; So I ran another test where I waited 10 seconds to make sure that enough time had passed to force the caching mechanism to reset the data.&amp;#160; After 10 minutes the cache had still not cleared.&amp;#160; After digging a bit further, I found a double lock check that looked a bit off in the GetSettingsStore() method of the SPFarmPropertyBag class:&lt;/p&gt;    &lt;pre&gt;&lt;font&gt;if &lt;/font&gt;&lt;font&gt;&lt;font&gt;&lt;font&gt;(_settingStore == null || &lt;br /&gt;   (DateTime.Now.Subtract(lastLoad).TotalSeconds) &amp;gt; cacheInterval))&lt;/font&gt;
&lt;/font&gt;&lt;/font&gt;{
  //Need to exist so don't deadlock.
  rrLock.EnterWriteLock();
  try
  {
    //make sure first another thread didn't already load...
    &lt;font&gt;if (_settingStore == null)&lt;/font&gt;&lt;br /&gt;    {
      _settingStore = WebAppSettingStore.Load(this.webApplication);
      lastLoad = DateTime.Now;
    }
  }
  finally
  {
    rrLock.ExitWriteLock();
  }
}&lt;/pre&gt;

&lt;p&gt;What ends up happening here is the outer check determines if the _settingStore is null or the cache has expired, but the inner check is just checking if the _settingStore is null (which is never the case after the first time it's been loaded).&amp;#160; Ergo, the cached settings are never reset.&amp;#160; &lt;/p&gt;

&lt;p&gt;The fix is really easy, just add the cache checking back into the inner if statement.&lt;/p&gt;





&lt;pre&gt;//make sure first another thread didn't already load...
&lt;font&gt;if (_settingStore == null || &lt;br /&gt;   (DateTime.Now.Subtract(lastLoad).TotalSeconds) &amp;gt; cacheInterval)&lt;/font&gt;&lt;br /&gt;  {
    _settingStore = WebAppSettingStore.Load(this.webApplication);
    lastLoad = DateTime.Now;
  }&lt;/pre&gt;

&lt;p&gt;And then it starts working just fine. as long as you wait at least 10 seconds for the cache to clear.&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=104048" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>How to Check if a Binary File Has Been Updated in an SPItemEventReceiver</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2011/08/02/102650.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2011/08/02/102650.aspx</id><published>2011-08-02T05:16:31Z</published><updated>2011-08-02T05:16:31Z</updated><content type="html">&lt;p&gt;I've been dealing with a number of item event receivers in SharePoint and I ran across the need to figure out whether or not the binary file associated with an item in a document library is being updated during the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventreceiver.itemupdating.aspx"&gt;ItemUpdating&lt;/a&gt; event.&amp;#160; I knew there were some additional events in the &lt;a href="http://msdn.microsoft.com/en-us/library/ms462603.aspx"&gt;SPItemEventReceiver&lt;/a&gt; class, but it turns out that none of them alert you as to when a binary file is actually being updated.&amp;#160; &lt;/p&gt;  &lt;p&gt;With the simple option out, I had to turn to a more investigative approach.&amp;#160; So I threw in some code to write out the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventproperties.beforeproperties.aspx"&gt;BeforeProperties&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventproperties.afterproperties.aspx"&gt;AfterProperties&lt;/a&gt; of the properties parameter passed into the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventreceiver.itemupdating.aspx"&gt;ItemUpdating&lt;/a&gt; method to see if there was some telltale sign of a binary file update, and there were a few.&lt;/p&gt;  &lt;p&gt;So if you want to tell whether or not the binary file has been updated in the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventreceiver.itemupdating.aspx"&gt;ItemUpdating&lt;/a&gt; method, you just have to check if &lt;strong&gt;vti_docstoreversion&lt;/strong&gt; has a &lt;strong&gt;null&lt;/strong&gt; value in the &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spitemeventproperties.afterproperties.aspx"&gt;AfterProperties&lt;/a&gt; collection.&amp;#160; If it has a value, then the binary file has NOT been updated.&lt;/p&gt;  &lt;p&gt;There are some additional properties for which this appears to hold true as well:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;vti_docstoreversion&lt;/li&gt;    &lt;li&gt;vti_docstoretype&lt;/li&gt;    &lt;li&gt;vti_metainfoversion&lt;/li&gt;    &lt;li&gt;vti_contentversionisdirty&lt;/li&gt;    &lt;li&gt;vti_contenttag&lt;/li&gt;    &lt;li&gt;vti_modifiedby&lt;/li&gt;    &lt;li&gt;vti_timelastmodified&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I'm not sure if they all always hold true, but they appeared to be consistent in what little testing I did.&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=102650" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>Enabling Web Editor Support in Class Library Projects</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2011/04/08/101160.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2011/04/08/101160.aspx</id><published>2011-04-08T19:42:34Z</published><updated>2011-04-08T19:42:34Z</updated><content type="html">&lt;p&gt;One of the things that has bothered me for a while is that it's tough to edit web files (.aspx / .ascx files) in non-web projects.&amp;#160; I think you can edit them if they are in the root directory (I may be recalling wrong, it's been a while) but the minute you put them in a directory the editor won't open up for them.&amp;#160; &lt;strong&gt;Jeff Burt&lt;/strong&gt; informed me this morning that if this bothers you, you can fix it!&amp;#160; Just open up your project file, locate the line containing the &lt;strong&gt;&amp;lt;ProjectGuid&amp;gt;&lt;/strong&gt; element and add the following line under it:    &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;&amp;lt;ProjectTypeGuids&amp;gt;{349c5851-65df-11da-9384-00065b846f21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&amp;lt;/ProjectTypeGuids&amp;gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This enables web editing functionality in non-web projects.&amp;#160; If your project already has a &lt;strong&gt;ProjectTypeGuids&lt;/strong&gt; element then you may just have to add those entries to the existing list.&amp;#160; Thanks Jeff!&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=101160" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>SQL - Joining to a Single Row</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2011/03/23/100966.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2011/03/23/100966.aspx</id><published>2011-03-23T21:05:50Z</published><updated>2011-03-23T21:05:50Z</updated><content type="html">&lt;p&gt;If you have a one-to-many relationship, and you are performing a join on the tables but you only want one record from the "many" portion of the relationship, then this is a very helpful link:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://stackoverflow.com/questions/2281551/tsql-left-join-and-only-last-row-from-right" href="http://stackoverflow.com/questions/2281551/tsql-left-join-and-only-last-row-from-right"&gt;http://stackoverflow.com/questions/2281551/tsql-left-join-and-only-last-row-from-right&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The outer apply appears to be very useful for joining a single row in one table to a very specific single row in another table.&amp;#160; Not sure about efficiency, but it gets the job done.&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=100966" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>Obscure SPUtility.SendMail Behavior When Manually Passing in Mail Headers</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2011/01/17/98934.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2011/01/17/98934.aspx</id><published>2011-01-17T18:01:43Z</published><updated>2011-01-17T18:01:43Z</updated><content type="html">&lt;p&gt;There are two ways to send mail in SharePoint: you can either use the mail components from the System.Net namespace, or you can send email using SharePoint's SPUtility.SendMail method.&amp;#160; One of the benefits of the SPUtility.SendMail method is that it uses the mail configuration from SharePoint, so you can manage settings in Central Administration instead of having to go through and modify your web.config file.&amp;#160; &lt;/p&gt;  &lt;p&gt;SPUtility.SendMail can get the job done, but it's defiantly not as developer friendly as the components from the System.Net namespace.&amp;#160; If you want to CC someone on an email, for example, you do NOT have a nice CC parameter - you have to manually add the CC mail header and pass it into the SPUtility.SendMail method.&amp;#160; I had to do this the other day, and ran into a really obscure issue.&lt;/p&gt;  &lt;p&gt;If you do NOT pass the headers into the method then SharePoint sends the email using the From Address configured in the Outgoing Mail settings in Central Admin.&amp;#160; &lt;/p&gt;  &lt;p&gt;If you pass headers into the method, but do not include the &lt;strong&gt;from&lt;/strong&gt; header, then SharePoint sends the mail using the email address of the current user.&lt;/p&gt;  &lt;p&gt;This can be an issue if your mail server is setup to reject an email from an invalid email address or an email address that is not on your domain.&amp;#160; The way to fix this issue is to always pass in the from header.&amp;#160; If you want to use the configured From address, then you can do the following:&lt;/p&gt;  &lt;p&gt;SPWebApplication webApp = SPWebApplication.Lookup(new Uri(SPContext.Current.Site.Url));   &lt;br /&gt;StringDictionary headers = new StringDictionary();    &lt;br /&gt;headers.Add(&amp;quot;from&amp;quot;, webApp.OutboundMailSenderAddress);&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=98934" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>Resolving an App-Relative URL without a Page Object Reference</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/12/18/96282.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/12/18/96282.aspx</id><published>2010-12-19T05:38:37Z</published><updated>2010-12-19T05:38:37Z</updated><content type="html">&lt;p&gt;If you've worked with ASP.NET before then you've almost certainly seen an application-relative URL like ~/SomeFolder/SomePage.aspx.&amp;#160; The tilde at the beginning is a stand in for the application path, and it can easily be resolved using the &lt;strong&gt;Page&lt;/strong&gt; object's &lt;strong&gt;ResolveUrl&lt;/strong&gt; method:&lt;/p&gt;  &lt;p&gt;string url = Page.ResolveUrl("~/SomeFolder/SomePage.aspx");&lt;/p&gt;  &lt;p&gt;There are times, however, when you don't have a page object available and you need to resolve an application relative URL.&amp;#160; Assuming you have an &lt;strong&gt;HttpContext&lt;/strong&gt; object available, the following method will accomplish just that:&lt;/p&gt;  &lt;p&gt;public static string ResolveAppRelativeUrl(string url)   &lt;br /&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return url.Replace(&amp;quot;~&amp;quot;, System.Web.HttpContext.Current.Request.ApplicationPath);    &lt;br /&gt;}&lt;/p&gt;  &lt;p&gt;It just replaces the tilde with the application path, which is essentially all the &lt;strong&gt;ResolveUrl&lt;/strong&gt; method does.&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=96282" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>SPUtility.SendMail and the 2048 Character Limit</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/12/13/96148.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/12/13/96148.aspx</id><published>2010-12-14T03:02:07Z</published><updated>2010-12-14T03:02:07Z</updated><content type="html">&lt;p&gt;We were in the middle of testing a web part responsible for gathering information from visitors to our Client's website and emailing it to someone responsible for responding to the request.&amp;#160; During testing, however, it was brought to our attention that the message was cutting off at 2048 characters.&amp;#160; Now, 2048 is one of those numbers that is usually indicative of some computational limit, but I was hopeful that Microsoft had thought through the possibility of emailing more than 2048 characters from SharePoint.&amp;#160; Luckily I was right. and wrong.&lt;/p&gt;  &lt;p&gt;As it turns out, SPUtility.SendMail is not limited to any specific character limit as far as I can tell.&amp;#160; However, each LINE of text that you send via SendMail cannot exceed 2048 characters.&amp;#160; Since we were sending an HTML email it was constructed entirely without line breaks, far exceeding the 2048 character limit and ultimately helping to educate me about this obscure technical limitation whose only benefit thus far is offering me something to rant about on my blog.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The fix is simple, just put in a carriage return and a line break often enough to avoid going past the 2048 character limit.&amp;#160; &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I'm sure someone can present a great technical reason for the 2048 character limit, but it seems fairly arbitrary since the "\r\n" that got appended to the string are ultimately just characters too.&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=96148" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>Where is the Site URL property of a SharePoint 2010 Project?</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/11/06/95545.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/11/06/95545.aspx</id><published>2010-11-06T20:30:44Z</published><updated>2010-11-06T20:30:44Z</updated><content type="html">&lt;p&gt;I ran into an issue today opening up an ASP.NET page from a SharePoint 2010 sample project from MSDN today:&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;The Site URL property of the project does not contain a valid URL. To ensure that designers work as expected, set the Site URL property of the project to the URL of the local SharePoint server. Close all designers, and then open them again.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;If you are accustomed to working with VSeWSS 1.3 then you may try to set the URL from the &lt;strong&gt;Start Browser With&lt;/strong&gt; option from the debug tab in the property pages for the project, but that will not work.&amp;#160; &lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;Site URL&lt;/strong&gt; property to which this error is referring can be found in the properties tool window when you have the project selected.&amp;#160; If you cannot see the properties tool window then you should be able to make it appear by hitting &lt;strong&gt;F4&lt;/strong&gt; or selected &lt;strong&gt;View &amp;gt; Properties Window&lt;/strong&gt; from the menu.&amp;#160; From there, you just type the URL into the Site URL property and you should be good to go.&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=95545" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>Using SharePoint 2010 as a DataSource: Presentation and Source Code from the Tyson Developer’s Conference</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/10/25/95340.aspx" /><link rel="enclosure" type="application/x-zip-compressed" length="1527676" href="http://www.simple-talk.com/community/blogs/damon_armstrong/attachment/95340.ashx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/10/25/95340.aspx</id><published>2010-10-25T17:06:00Z</published><updated>2010-10-25T17:06:00Z</updated><content type="html">I wanted to thank everyone who came out to my presentation.  Below you will find the source code and the presentation slides from the talk.&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=95340" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>VSeWSS Bin Folder File List</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/10/01/94852.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/10/01/94852.aspx</id><published>2010-10-01T20:02:22Z</published><updated>2010-10-01T20:02:22Z</updated><content type="html">&lt;p&gt;I had an earlier post about how to avoid the dreaded &lt;a href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2009/09/14/VSeWSS_Unable_to_Load_One_or_More_of_the_Requested_Types.aspx" target="_blank"&gt;Unable to load one or more of the requested types&lt;/a&gt; I mentioned that you can put DLLs into the VSeWSS bin folder.&amp;#160; I had an issue today, however, where I needed to clean out that directory but I had no idea what files were in there originally.&amp;#160; If you are running into the same issue, here is a quick listing:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Microsoft.SharePoint.Tools.FileResources.dll&lt;/li&gt;    &lt;li&gt;Microsoft.SharePoint.Tools.Resources.dll&lt;/li&gt;    &lt;li&gt;VSeWSS.Server.Services.dll&lt;/li&gt;    &lt;li&gt;VSeWSS.Server.SPProxies.dll     &lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=94852" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>System.DirectoryServices Unknown error (0x80005000) Resolution</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/09/21/94593.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/09/21/94593.aspx</id><published>2010-09-21T22:31:38Z</published><updated>2010-09-21T22:31:38Z</updated><content type="html">&lt;p&gt;This seems completely ridiculous.&amp;#160; I needed to write some queries against Active Directory so I made a quick console application to thresh things out before putting them inside SharePoint.&amp;#160; After getting everything working, I dropped it into a web part and deployed it out to our test server.&amp;#160; After setting up the LDAP connection on the web part (I made them editable properties instead of hardcoding them) I ended up getting the following obscure error:&lt;/p&gt;  &lt;p&gt;COM Exception was unhandled   &lt;br /&gt;Unknown error (0x80005000)    &lt;br /&gt;Error Code: -2147463168    &lt;br /&gt;Source: System.DirectoryServices&lt;/p&gt;  &lt;p&gt;At first I was thinking it was a SharePoint induced security problem and was expecting a long and arduous road of getting everything working.&amp;#160; However, after finding a random comment in a forum it turns out this is really simple issue with a terrible error message.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Resolution&lt;/strong&gt;:&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&lt;strong&gt;Capitalize LDAP:// in the connection string.&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;It turns out I accidentally did everything right in the console app but failed to do it again when configuring my web part.&amp;#160; I'm glad I found this now instead of running into it while deploying it to production.&amp;#160; What I decided to do was just add this code to the set section of my web part property:&lt;/p&gt;  &lt;p&gt;Regex.Replace(value, &amp;quot;ldap://&amp;quot;, &amp;quot;LDAP://&amp;quot;, RegexOptions.IgnoreCase); &lt;/p&gt;  &lt;p&gt;It uses a regular expression to locate ldap:// in the connection string regardless of how it is spelled (Ldap, LDap, ldaP, etc) and replaces it with the fully uppercased version. Pretty easy fix.&lt;/p&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=94593" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>Static Property Behavior with Generics and Inheritance</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/08/20/94159.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/08/20/94159.aspx</id><published>2010-08-20T09:50:40Z</published><updated>2010-08-20T09:50:40Z</updated><content type="html">&lt;p&gt;I'm in the midst of writing some classes that use generics so I figured I would blog about the way static properties work in different situations.&amp;#160; This is not ground breaking stuff, but it's good to be aware of so you know exactly what you are getting in different situations.&amp;#160; Let's say that you have a base class that does not use any generics that exposes a static property named &lt;strong&gt;SomeProperty&lt;/strong&gt;:&lt;/p&gt; &lt;code&gt;public class MyBaseClass    &lt;br /&gt;&lt;/code&gt;&lt;code&gt;{    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public static object SomeProperty = new object();     &lt;br /&gt;} &lt;/code&gt;  &lt;p&gt;And then let's say you have two classes that inherit from that base class:&lt;/p&gt; &lt;code&gt;public class MyClassA : MyBaseClass { }    &lt;br /&gt;public class MyClassB : MyBaseClass { } &lt;/code&gt;  &lt;p&gt;Then it should come as no surprise that this line of code:&lt;code&gt;      &lt;br /&gt;      &lt;br /&gt;bool value = (MyClassA.SomeProperty == MyClassB.SomeProperty);&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;results in a value equal to &lt;strong&gt;true&lt;/strong&gt;.&amp;#160; When you inherit from a base class, all of the inheritors use the exact same property from the base class.&amp;#160; But now let's look at a generic class like this:&lt;/p&gt;  &lt;p&gt;&lt;code&gt;public class MyGenericBaseClass&amp;lt;T&amp;gt;      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public static object AnotherProperty = new object();       &lt;br /&gt;} &lt;/code&gt;&lt;code&gt;&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;And then let's say you have three classes that inherit from that base class:&lt;/p&gt;  &lt;p&gt;&lt;code&gt;public class MyClassX : MyGenericBaseClass&amp;lt;int&amp;gt; { }      &lt;br /&gt;&lt;/code&gt;&lt;code&gt;public class MyClassY : MyGenericBaseClass&amp;lt;int&amp;gt; { }      &lt;br /&gt;public class MyClassZ : MyGenericBaseClass&amp;lt;string&amp;gt; { } &lt;/code&gt;&lt;/p&gt;  &lt;p&gt;When you have a situation like this, then the following line:&lt;/p&gt; &lt;code&gt;bool value = (MyClassX.AnotherProperty== MyClassY.AnotherProperty);&lt;/code&gt;   &lt;p&gt;results in a value equal to &lt;strong&gt;true&lt;/strong&gt;, and the following line:&lt;/p&gt; &lt;code&gt;bool value = (MyClassX.AnotherProperty== MyClassZ.AnotherProperty);&lt;/code&gt;   &lt;p&gt;results in a value equal to &lt;strong&gt;false&lt;/strong&gt;.&amp;#160; Why?&amp;#160; Because when you use generics, it's basically creating an entirely new type for each different generic type parameter.&amp;#160; Both &lt;strong&gt;MyClassX&lt;/strong&gt; and &lt;strong&gt;MyClassY&lt;/strong&gt; pass the same type parameter to the &lt;strong&gt;MyGenericBaseClass&lt;/strong&gt;, so they use the same resulting type.&amp;#160; &lt;strong&gt;MyClassZ&lt;/strong&gt; passes a different type parameter, so the resulting base class from which it derives has its own version of &lt;strong&gt;AnotherProperty&lt;/strong&gt; that is different from the one inherited from &lt;strong&gt;MyClassX&lt;/strong&gt; and &lt;strong&gt;MyClassY&lt;/strong&gt;.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Many people mistakenly believe that a new type gets created each time you reference a generic class, but the reality is that a new type is only created when you reference a unique set of generic type parameters.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;But what happens when you mix the two?&amp;#160; For example, if you have the following class:&lt;/p&gt;  &lt;p&gt;&lt;code&gt;public class MixedBaseClass&amp;lt;T&amp;gt; : MyBaseClass      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public static object MixedProperty = new object();       &lt;br /&gt;}&lt;/code&gt;&lt;/p&gt;  &lt;p&gt;&lt;code&gt;&lt;/code&gt;And then you have the following three classes:&lt;/p&gt; &lt;code&gt;public class MyClass1 : MixedBaseClass&amp;lt;int&amp;gt; { }    &lt;br /&gt;&lt;/code&gt;&lt;code&gt;public class MyClass2 : MixedBaseClass&amp;lt;int&amp;gt; { }    &lt;br /&gt;public class MyClass3 : MixedBaseClass&amp;lt;string&amp;gt; { } &lt;/code&gt;  &lt;p&gt;Then you get an interesting hybrid where references to properties defined in generic classes vary from type parameter to type parameter, but the properties defined in the non-generic classes contain the same reference.&amp;#160; As such,&lt;/p&gt;  &lt;p&gt;&lt;/p&gt; &lt;code&gt;bool value = (MyClass1.MixedProperty == MyClass2.MixedProperty);&lt;/code&gt;   &lt;p&gt;results in a value equal to &lt;strong&gt;true &lt;/strong&gt;and&lt;/p&gt;  &lt;p&gt;&lt;/p&gt; &lt;code&gt;bool value = (MyClass1.MixedProperty == MyClass3.MixedProperty);&lt;/code&gt;   &lt;p&gt;results in a value equal to &lt;strong&gt;false &lt;/strong&gt;(just like before), but&lt;/p&gt; &lt;code&gt;bool value = (MyClass1.SomeProperty == MyClass2.SomeProperty);    &lt;br /&gt;bool value = (MyClass1.SomeProperty == MyClass3.SomeProperty);&lt;/code&gt;   &lt;p&gt;both result in a value of &lt;strong&gt;true&lt;/strong&gt; even though their classes have different generic type parameters.&amp;#160; Why does this matter?&amp;#160; Because to the untrained eye the following to classes appear very similar:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt; &lt;code&gt;&lt;/code&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;public class UtilityA&amp;lt;T&amp;gt;     &lt;br /&gt;{      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; private object SyncLock = new object();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public void DoSomething()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lock(SyncLock)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ... do something ...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;font face="Courier New"&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;font face="Courier New"&gt;     &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier New"&gt;public class UtilityB     &lt;br /&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; private object SyncLock = new object();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public void DoSomething&amp;lt;T&amp;gt;()      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; lock(SyncLock)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ... do something ...      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;font face="Courier New"&gt;     &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;However, it has a really big effect on the locking mechanism.&amp;#160; &lt;strong&gt;UtilityA&lt;/strong&gt; defines the type parameter at the class level, which means there is an entire type for each type parameter, which in turn means there is a locking object for each type parameter.&amp;#160; As such, if you run the following two lines of code on different threads:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt; &lt;code&gt;UtilityA&amp;lt;int&amp;gt;.DoSomething();&amp;#160; //Run on thread #1   &lt;br /&gt;UtilityA&amp;lt;bool&amp;gt;.DoSomething(); //Run on thread #2 (will not block)&lt;/code&gt;  &lt;p&gt;then you will not have a blocking situation because there are two &lt;strong&gt;SyncLock&lt;/strong&gt; objects - one for the &lt;strong&gt;Utility&amp;lt;A&amp;gt;&lt;/strong&gt; type and one for the &lt;strong&gt;Utility&amp;lt;bool&amp;gt;&lt;/strong&gt; type.&amp;#160; However, if you were to run the next lines of code on separate threads:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt; &lt;code&gt;UtilityB.DoSomething&amp;lt;int&amp;gt;();&amp;#160; //Run on thread #1   &lt;br /&gt;UtilityB.DoSomething&amp;lt;bool&amp;gt;(); //Run on thread #2&lt;/code&gt;&amp;#160; (may block)  &lt;p&gt;Then you could have blocking situation because &lt;strong&gt;UtilityB&lt;/strong&gt; defines the generic type parameters at the function level and not the class level, which means &lt;strong&gt;UtilityB&lt;/strong&gt; is a non-generic class.&amp;#160; As such, there will only be a single type, and that single type will contain a single &lt;strong&gt;SyncLock&lt;/strong&gt; object.&amp;#160; That means that all of the &lt;strong&gt;DoSomething&lt;/strong&gt; functions, regardless of their type parameter, will use the same &lt;strong&gt;SyncLock&lt;/strong&gt; object.&lt;/p&gt;  &lt;p&gt;Depending on the desired behavior, you can adjust your generic type parameter usage accordingly.&amp;#160; As mentioned, not earth shattering stuff, but its defiantly something to keep in mind when you're using generics.&lt;/p&gt;  &lt;div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:04d39577-457a-4c05-9ba1-6e4e42a3dc9a" class="wlWriterEditableSmartContent"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Generics" rel="tag"&gt;Generics&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Inheritance" rel="tag"&gt;Inheritance&lt;/a&gt;,&lt;a href="http://technorati.com/tags/C%23" rel="tag"&gt;C#&lt;/a&gt;&lt;/div&gt;  &lt;br /&gt;  &lt;div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:437dfd7c-ea9a-4e49-826a-d3e8f14b7188" class="wlWriterEditableSmartContent"&gt;del.icio.us Tags: &lt;a href="http://del.icio.us/popular/.NET" rel="tag"&gt;.NET&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/Generics" rel="tag"&gt;Generics&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/Inheritance" rel="tag"&gt;Inheritance&lt;/a&gt;,&lt;a href="http://del.icio.us/popular/C%23" rel="tag"&gt;C#&lt;/a&gt;&lt;/div&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=94159" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry><entry><title>Resolving an Initial 404 Error with Ninject's MVC Extension</title><link rel="alternate" type="text/html" href="http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/08/17/94121.aspx" /><id>http://www.simple-talk.com/community/blogs/damon_armstrong/archive/2010/08/17/94121.aspx</id><published>2010-08-17T07:50:51Z</published><updated>2010-08-17T07:50:51Z</updated><content type="html">&lt;p&gt;I'm about to begin working on an MVC application so I went out and bought a copy of &lt;a href="http://www.apress.com/book/view/1430228865" target="_blank"&gt;Pro ASP.NET MVC 2 Framework&lt;/a&gt; from &lt;a href="http://www.apress.com/" target="_blank"&gt;APress&lt;/a&gt; to brush up on my nearly non-existent MVC skills.&amp;#160; The author recommends using the &lt;a href="http://ninject.org/" target="_blank"&gt;Ninject&lt;/a&gt; dependency injector, so I downloaded and referenced it in the project.&amp;#160; He also mentioned an extension called &lt;a href="http://github.com/ninject/ninject.web.mvc" target="_blank"&gt;Ninject.Web.Mvc&lt;/a&gt; that did the heavy lifting for setting up Ninject as the controller factory for the application.&amp;#160; I attempted to follow the instructions for getting the extension setup, but the instructions were not so much instructions as they were a single code listing from which what to do must be divined.&amp;#160; When I ran the MVC application I was greeted by the following error:&lt;/p&gt;  &lt;h4&gt;&lt;i&gt;The resource cannot be found.&lt;/i&gt;&lt;/h4&gt; &lt;b&gt;Description: &lt;/b&gt;HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.&amp;#160; Please review the following URL and make sure that it is spelled correctly.   &lt;br /&gt;&lt;b&gt;Requested URL: &lt;/b&gt;/   &lt;p&gt;The error is pretty simple:&amp;#160; when you start a new MVC project, the global.asax contains a method that looks like this:&lt;/p&gt; &lt;code&gt;protected void Application_Start()    &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; AreaRegistration.RegisterAllAreas();     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; RegisterRoutes(RouteTable.Routes);     &lt;br /&gt;} &lt;/code&gt;  &lt;p&gt;If you look at the RegisterRoutes method, you'll see that's where all your routing gets defined.&amp;#160; However, one of the changes you have to make when you setup the Ninject extensions is to change the class from which your web applications inherits from HttpApplication to NinjectHttpApplication.&amp;#160; This action hides the Application_Start() method defined in the global.asax class, so it will never actually run - Visual Studio is nice enough to let you know this with the following &lt;strong&gt;warning&lt;/strong&gt;:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;'EventManagerWeb.MvcApplication.Application_Start()' hides inherited member 'Ninject.Web.Mvc.NinjectHttpApplication.Application_Start()'. Use the new keyword if hiding was intended.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Since it's a warning, the application compiles and runs just fine so you may have not noticed it was ever there in the first place.&amp;#160; So, what do you do?&amp;#160; You just move all the code from Application_Start() into an overridden version of the OnApplicationStarted method, and then things will start working just fine.&amp;#160; Here is the full listing that you really can copy and paste into your MVC application if you're just starting out (make sure your change the namespace though):&lt;/p&gt; &lt;code&gt;using System;    &lt;br /&gt;using System.Collections.Generic;     &lt;br /&gt;using System.Linq;     &lt;br /&gt;using System.Web;     &lt;br /&gt;using System.Web.Mvc;     &lt;br /&gt;using System.Web.Routing;     &lt;br /&gt;using Ninject;     &lt;br /&gt;using Ninject.Web.Mvc;     &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;namespace SomeNamespace     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // Note: For instructions on enabling IIS6 or IIS7 classic mode,     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // visit http://go.microsoft.com/?LinkId=9394801     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public class MvcApplication : NinjectHttpApplication     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected override IKernel CreateKernel()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; return new StandardKernel();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; public static void RegisterRoutes(RouteCollection routes)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; routes.IgnoreRoute(&amp;quot;{resource}.axd/{*pathInfo}&amp;quot;);     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; routes.MapRoute(     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Default&amp;quot;, // Route name     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;{controller}/{action}/{id}&amp;quot;, // URL with parameters     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; new { controller = &amp;quot;Home&amp;quot;, action = &amp;quot;Index&amp;quot;,&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; id = UrlParameter.Optional } // Parameter defaults     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; );     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; protected override void OnApplicationStarted()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AreaRegistration.RegisterAllAreas();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; RegisterRoutes(RouteTable.Routes);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; base.OnApplicationStarted();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;} &lt;/code&gt;&lt;img src="http://www.simple-talk.com/community/aggbug.aspx?PostID=94121" width="1" height="1"&gt;</content><author><name>Damon</name><uri>http://www.simple-talk.com/community/user/Profile.aspx?UserID=2140</uri></author></entry></feed>
