<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ellis Web Development &#187; Code</title>
	<atom:link href="http://ellisweb.net/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://ellisweb.net</link>
	<description>Thoughts &#38; Articles on ASP.net, C#, Software Development and Technology by Yaakov Ellis</description>
	<lastBuildDate>Mon, 07 May 2012 07:45:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Could not load type &#8216;System.Web.Razor.Parser.SyntaxTree.CodeSpan&#8217; from assembly &#8216;System.Web.Razor</title>
		<link>http://ellisweb.net/2012/04/could-not-load-type-system-web-razor-parser-syntaxtree-codespan-from-assembly-system-web-razor/</link>
		<comments>http://ellisweb.net/2012/04/could-not-load-type-system-web-razor-parser-syntaxtree-codespan-from-assembly-system-web-razor/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 12:54:19 +0000</pubDate>
		<dc:creator>Yaakov Ellis</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[razor]]></category>
		<category><![CDATA[webapi]]></category>

		<guid isPermaLink="false">http://ellisweb.net/?p=544</guid>
		<description><![CDATA[I am working with an ASP.net MVC4 project with WebAPI, and upgraded/installed a number of nuget packages (and stupidly did not test after each one). When the dust settled, I tried to load an API page in my browser and got the following error message: &#8220;Could not load type &#8216;System.Web.Razor.Parser.SyntaxTree.CodeSpan&#8217; … <a href="http://ellisweb.net/2012/04/could-not-load-type-system-web-razor-parser-syntaxtree-codespan-from-assembly-system-web-razor/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
			<content:encoded><![CDATA[<p>I am working with an ASP.net MVC4 project with WebAPI, and upgraded/installed a number of nuget packages (and stupidly did not test after each one). When the dust settled, I tried to load an API page in my browser and got the following error message:</p>
<h4><em>&#8220;Could not load type &#8216;System.Web.Razor.Parser.SyntaxTree.CodeSpan&#8217; from assembly &#8216;System.Web.Razor&#8221;</em></h4>
<p>Eventually, I was able to resolve the error by removing the following from my web.config and app.config files:</p>
<pre class="brush: xml; gutter: false">&lt;runtime&gt;
  &lt;assemblyBinding xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;
    &lt;!-- Begin Remove --&gt;
    &lt;dependentAssembly&gt;
      &lt;assemblyIdentity name=&quot;System.Web.Razor&quot; publicKeyToken=&quot;31bf3856ad364e35&quot; culture=&quot;neutral&quot; /&gt;
      &lt;bindingRedirect oldVersion=&quot;0.0.0.0-2.0.0.0&quot; newVersion=&quot;2.0.0.0&quot; /&gt;
    &lt;/dependentAssembly&gt;
    &lt;!-- End Remove --&gt;
  &lt;/assemblyBinding&gt;
&lt;/runtime&gt;</pre>
<p>I would guess that one of the packages that I installed added this reference, which had a conflict with a different version of the same assembly in the GAC. In any event, it fixed the error (and did not cause any apparent new errors). Posting in case it may help you out with a similar error.</p>
]]></content:encoded>
			<wfw:commentRss>http://ellisweb.net/2012/04/could-not-load-type-system-web-razor-parser-syntaxtree-codespan-from-assembly-system-web-razor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force WebAPI to return JSON by Default for Html GET Requests</title>
		<link>http://ellisweb.net/2012/04/force-webapi-to-return-json-by-default-for-html-get-requests/</link>
		<comments>http://ellisweb.net/2012/04/force-webapi-to-return-json-by-default-for-html-get-requests/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 06:04:38 +0000</pubDate>
		<dc:creator>Yaakov Ellis</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[webapi]]></category>

		<guid isPermaLink="false">http://ellisweb.net/?p=536</guid>
		<description><![CDATA[Currently, the default response type of for Web API requests is XML. By the time it comes out of beta, it will be the default (source - this is mentioned by Hanselman towards the end of the post). However, if you want to activate this right now, how should you … <a href="http://ellisweb.net/2012/04/force-webapi-to-return-json-by-default-for-html-get-requests/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
			<content:encoded><![CDATA[<p>Currently, the default response type of for Web API requests is XML. By the time it comes out of beta, it will be the default (<a href="http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx">source </a>- this is mentioned by Hanselman towards the end of the post). However, if you want to activate this right now, how should you do it?</p>
<p>Two steps:</p>
<ol>
<li>Set a JSON formatter as the first Formatter in the Web API Config Formatters collection</li>
<li>Set &#8220;text/html&#8221; as an accepted media type for this formatter</li>
</ol>
<p>WebAPI includes a JSON Serializer by default: DataContractJsonSerializer. However, <a href="http://encosia.com/jquery-asp-net-web-api-and-json-net-walk-into-a-bar/">no one wants to use it</a>, and for good reason: lots of issues with different types, slow performance, bad date formatting <a href="http://www.west-wind.com/weblog/posts/2012/Mar/09/Using-an-alternate-JSON-Serializer-in-ASPNET-Web-API">and more</a>.</p>
<p>Thankfully, WebAPI allows you to switch customize the data formatters used for different content types. Bloggers have recommended a number of different approaches. What seems to be the most promising is <a href="http://blogs.msdn.com/b/henrikn/archive/2012/02/18/using-json-net-with-asp-net-web-api.aspx">Henrik Nielsen&#8217;s</a> <a href="https://github.com/WebApiContrib/WebAPIContrib/blob/master/src/WebApiContrib.Formatting.JsonNet/JsonNetFormatter.cs">JsonNetFormatter</a> (using Json.NET to handle the JSON serialization) combined with a fix for a DateTime serialization issue (Hanselman also implies that this will be the default in post-beta WebAPI).</p>
<p>After you add the code for the JsonNetFormatter, you can set this up as the default Json data formatter by doing the following:</p>
<pre class="brush: csharp; gutter: true">protected void Application_Start()
{
    ...

    JsonSerializerSettings serializerSettings = new JsonSerializerSettings();
    serializerSettings.Converters.Add(new IsoDateTimeConverter());
    GlobalConfiguration.Configuration.Formatters.Insert(0, new JsonNetFormatter(serializerSettings));

    ...
}</pre>
<p>Once you have done this, any request that comes in to the API that asks for json (setting a header to accept content of type application/json, utilizing the facility in WebAPI for <a href="http://weblogs.asp.net/gunnarpeipman/archive/2012/04/19/asp-net-web-api-how-content-negotiation-works.aspx">content negotiation</a>) will receive Json content formatter using the JsonNetFormatter class. However, if you want to just test this out in your browser, you will still get XML content. This is because a plan request from your browser is for type text/html, which translates to xml in the Web API universe. Though the Json will be returned automatically if you explicitly request json content (or if you use a function that requests this content type, like the <a href="http://api.jquery.com/jQuery.ajax/">$.ajax</a> function in jQuery), if you want to test out the json in your browser, you will be out of luck using the standard configuration.</p>
<p>To get around this, you need to <a href="http://stackoverflow.com/a/10197525/51">set the JsonNetFormatter</a> to support the &#8220;text/html&#8221; media type. This will allow it to respond to requests made from the browser (and since the JsonNetFormatter is now the first Formatter in the Formatters collection, it will be used by default). You can do this as follows:</p>
<pre class="brush: csharp; gutter: true">protected void Application_Start()
{
    ...

    JsonSerializerSettings serializerSettings = new JsonSerializerSettings();
    serializerSettings.Converters.Add(new IsoDateTimeConverter());
    var jsonFormatter = new JsonNetFormatter(serializerSettings);
    jsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue(&quot;text/html&quot;));
    GlobalConfiguration.Configuration.Formatters.Insert(0, jsonFormatter);

    ...
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://ellisweb.net/2012/04/force-webapi-to-return-json-by-default-for-html-get-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error Loading MVC 3 Project after MVC 4 is Installed or in VS 2011</title>
		<link>http://ellisweb.net/2012/02/error-loading-mvc-3-project-after-mvc-4-is-installed-or-in-vs-2011/</link>
		<comments>http://ellisweb.net/2012/02/error-loading-mvc-3-project-after-mvc-4-is-installed-or-in-vs-2011/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 12:29:44 +0000</pubDate>
		<dc:creator>Yaakov Ellis</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[mvc3]]></category>
		<category><![CDATA[mvc4]]></category>
		<category><![CDATA[vs]]></category>

		<guid isPermaLink="false">http://ellisweb.net/?p=525</guid>
		<description><![CDATA[Since installing the ASP.net MVC 4 Beta, it has happened to me a few times that MVC 3 websites will not load when the solution is loaded into VS 2010 (I have also read about this happening with VS 2011). You can fix this by doing the following: In the … <a href="http://ellisweb.net/2012/02/error-loading-mvc-3-project-after-mvc-4-is-installed-or-in-vs-2011/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
			<content:encoded><![CDATA[<p>Since installing the ASP.net MVC 4 Beta, it has happened to me a few times that MVC 3 websites will not load when the solution is loaded into VS 2010 (I have also read about this happening with VS 2011).</p>
<p>You can fix this by doing the following:</p>
<ol>
<li>In the Solution Explorer, right click on the project that wont load and click on &#8220;Edit [ProjectName].csproj&#8221;. This will open up the project definition file in VS. You can also edit this manually using your favorite text editor, opening the file through Windows Exporer.</li>
<li>Find the line in the file that starts with <code>ProjectTypeGuids</code> and remove the entry &#8220;{E53F8FEA-EAE0-44A6-8774-FFD645390401}&#8221; from the list (this is code that tells Visual Studio that it is an MVC 3 project &#8211; for some reason, including this in the project file after installing MVC 4 messes things up).</li>
<li>Save the .csproj. file and [Reload] the project through the Right Click menu in Solution Explorer.</li>
</ol>
<p>The project should now load properly (if the MVC project has been the startup project for the solution, you may have to reset this as well).</p>
]]></content:encoded>
			<wfw:commentRss>http://ellisweb.net/2012/02/error-loading-mvc-3-project-after-mvc-4-is-installed-or-in-vs-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crucible Code Review Wishlist</title>
		<link>http://ellisweb.net/2012/02/crucible-code-review-wishlist/</link>
		<comments>http://ellisweb.net/2012/02/crucible-code-review-wishlist/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 12:41:52 +0000</pubDate>
		<dc:creator>Yaakov Ellis</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[CodeReview]]></category>
		<category><![CDATA[Crucible]]></category>

		<guid isPermaLink="false">http://ellisweb.net/?p=515</guid>
		<description><![CDATA[I have been trying out Crucible Code Review software from Atlassian (halfway through the trial) with a number of teams in my department. The competition in this area is pretty sparse, and each one has its other issues: Kiln only works for Mercurial (which we may move to some day, but … <a href="http://ellisweb.net/2012/02/crucible-code-review-wishlist/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
			<content:encoded><![CDATA[<p>I have been trying out <a href="http://www.atlassian.com/software/crucible/overview">Crucible Code Review</a> software from Atlassian (halfway through the trial) with a number of teams in my department. The competition in this area is pretty sparse, and each one has its other issues:</p>
<ul>
<li><a href="http://www.fogcreek.com/kiln">Kiln</a> only works for Mercurial (which we may move to some day, but for now we are using SVN so we need a solution that works with that as also)</li>
<li><a href="http://www.reviewboard.org/">Review Board</a> seems to be very popular, but just looking at the list of the <a href="http://www.reviewboard.org/docs/codebase/dev/getting-started/">dependencies</a> gives me indigestion when considering an install on our Windows Server environment.</li>
<li><a href="http://smartbear.com/products/development-tools/code-review/">Code Collaborator</a> is way too expensive without giving much extra (50 users in Crucible = $2200, 50 named users in Code Collaborator = $24,450)</li>
<li><a href="http://codereviewtool.com/">Code Review Tool</a> doesn&#8217;t have a very professional looking site, hardly any documentation and no plugin potential and no Mercurial support</li>
<li><a href="http://www.bigfishsolutions.biz/Products/PeerReviewswithSpectare/tabid/121/Default.aspx">Specatare</a>&#8216;s and <a href="http://www.parasoft.com/jsp/technologies/code_review.jsp?itemId=325">Parasoft</a>&#8216;s websites are even sparser and gives almost no info (aside from a few screenshots) &#8211; not enough to make me spend the time trying it out.</li>
</ul>
<p>On the other hand, thus far Crucible has delivered on the main functionality: establishing a medium for easily performing code reviews. The <a href="http://www.atlassian.com/software/crucible/pricing">price</a> is very fair and there is very <a href="http://confluence.atlassian.com/display/CRUCIBLE">decent documentation</a>. We will probably go with it, just for those reasons alone.</p>
<p>That said, I have a number of issues with Crucible &#8211; posting them here in the hopes that someone from Atlassian will see this and can do something about some or all of them.<span id="more-515"></span></p>
<ol>
<li><strong>Design</strong>: The marketing website is professionally designed, from a usability perspective. The software is not. It looks like I (or someone with their head in code all day) designed it. For new users, it is just not so intuitive to use. What is the difference between Source and Projects? Where do I need to go to get things done? Where are the important items? After spending some time, we can figure it out, but a better design would go a long way. If you need some hints, just check out <a href="http://www.jetbrains.com/teamcity/">Team City</a>. They have figured this out pretty well.</li>
<li><strong>Installation</strong>: I was able to get it running on Windows Server with Sql Server as a backend, without <em>too much</em> pain (note: there was <em>some</em> pain involved). However, thus I am only able to launch it from the command line. Instructions for setting it up as a <a href="http://confluence.atlassian.com/pages/viewpage.action?pageId=179439487">Windows Service</a> did not work. If we end up purchasing a license, I will have to bite the bullet and get it working somehow. But this needs to be fixed. Both Team City and <a href="http://www.fogcreek.com/fogbugz/">Fog Creek</a> (and I am sure, many others) have figured out how to bundle the installation of a windows service into an Installation Setup routine. Please see to this (and for upgrades as well). Same with documentation relating to getting Crucible to bind to the domain name properly. I eventually figured it out, but more guidance around this could have been given (hint: HTTP bind to the IP address on port 80, set the Proxy Host to the domain name without &#8220;http://&#8221; and set the site url to the domain name with &#8220;http://&#8221;).</li>
<li><strong>Repository Administration</strong>: A lot of little things here could be changed to make this easier (again, check out Team City &#8211; they have nailed this). Off the top of my head:</li>
<ol>
<li>Why can&#8217;t I change the name of a repository after it has been created?</li>
<li>Please give me some concrete examples about how Include/Exclude paths work in a repository. I want to use these but don&#8217;t want to put in a couple of hours trying it out (especially when the only way to try it is to re-index the whole repository, something that can take a really long time).</li>
<li>Why can&#8217;t I create a new repository based off of the settings used in a different repository, or better yet, have one base repository root, from which I define other repositories based on their relative paths (like in TC)? We have one big SVN repository, and Crucible, our individual repositories are all subdirectories somewhere down from this root. Right now it is really annoying to create new repositories &#8211; this could be made less painful.</li>
</ol>
<li><strong>Workflows &amp; Permission Schemes</strong>: Bit of a learning curve here &#8211; so many options. Some more explanation and help with setting these up <a href="http://ellisweb.net/wp-content/uploads/2012/02/crucible1.jpg" rel="lightbox[515]" title="crucible permission schemes"><img class="size-medium wp-image-516 alignright" style="border-style: initial; border-color: initial;" title="crucible permission schemes" src="http://ellisweb.net/wp-content/uploads/2012/02/crucible1-300x249.jpg" alt="" width="300" height="249" /></a>would be good. Maybe more default setups available out of the box. And the one preset Permission Scheme that was given (agile) was setup by default to make the contents and reviews of all associated projects public to all users, including users who have not logged in (not so cool).</li>
<li><strong>Better Notifications</strong>: Right now it is easy for notifications to get lost in the different dashboards. I want to be able to set up a way for notifications regarding certain types of SCM updates to be elevated in prominence. For example, let me give a path or pattern match within a repository so that whenever code is committed to this path, I will get some loud notifications about these. Or when a specific user commits code to a specific project. There are so many commits, that I am not always able to review every single one &#8211; this is something to strive for, but I am  not there yet. However, there are some areas in my projects (or some users) where I always want to review every line of code that they put in. I don&#8217;t want to lose these in the haystack. Give me a way to do this better and I will be very appreciative.</li>
</ol>
<p>Looking at the market for code review software, it definitely seems like it is a third-class citizen, not getting as much attention as its bigger cousins in the realm of Continuous Integration or Bug Tracking (it is obvious even from looking at the list of different Twitter accounts used by <a href="https://twitter.com/#!/atlassian">@Atlassian</a>, or the popular tags on their <a href="http://blogs.atlassian.com/">blog</a> &#8211; Crucible or Fisheye are naught to be seen). Still, this lower status can also present an opportunity to really claim the mantle as the best in the business (and a note to competitors, existing or potential: not a high barrier to entry right now).</p>
]]></content:encoded>
			<wfw:commentRss>http://ellisweb.net/2012/02/crucible-code-review-wishlist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Horrible Page Design at JPost.com</title>
		<link>http://ellisweb.net/2012/02/horrible-page-design-at-jpost-com/</link>
		<comments>http://ellisweb.net/2012/02/horrible-page-design-at-jpost-com/#comments</comments>
		<pubDate>Sun, 26 Feb 2012 14:19:48 +0000</pubDate>
		<dc:creator>Yaakov Ellis</dc:creator>
				<category><![CDATA[WebDev]]></category>
		<category><![CDATA[jpost]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[web-design]]></category>

		<guid isPermaLink="false">http://ellisweb.net/?p=507</guid>
		<description><![CDATA[I just loaded up a link at jpost.com talking about how the Rami Levy supermarket chain predicts that by 2012 20% of food purchases in Israel will be online. However, when I loaded the link, it took me a minute to actually find the content. Can you see the problem … <a href="http://ellisweb.net/2012/02/horrible-page-design-at-jpost-com/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
			<content:encoded><![CDATA[<p>I just loaded up a link at jpost.com talking about how the Rami Levy supermarket chain predicts that by 2012 <a href="http://www.jpost.com/Business/Globes/Article.aspx?id=258816">20% of food purchases in Israel</a> will be online. However, when I loaded the link, it took me a minute to actually find the content. Can you see the problem here?</p>
<p><a href="http://ellisweb.net/wp-content/uploads/2012/02/jpost1.jpg" rel="lightbox[jpost]" title="jpost1"><img class="aligncenter size-medium wp-image-508" title="jpost1" src="http://ellisweb.net/wp-content/uploads/2012/02/jpost1-300x278.jpg" alt="" width="300" height="278" /></a></p>
<p>To make it a little bit clearer, I have added highlights &#8211; Ads are in yellow, In-site navigation is in green, and the content is in blue. The content occupies a tiny strip down the center of the page (maybe 30-40% of the total width of the page). This is surrounded on all sides several layers:<span id="more-507"></span></p>
<p><a href="http://ellisweb.net/wp-content/uploads/2012/02/jpost2.jpg" rel="lightbox[jpost]" title="jpost2"><img class="aligncenter size-medium wp-image-510" title="jpost2" src="http://ellisweb.net/wp-content/uploads/2012/02/jpost2-300x278.jpg" alt="" width="300" height="278" /></a></p>
<ol>
<li>The first layer has a set of Ads (Yellow &#8211; all advertising the same thing) and goes around the entire perimeter, switching vertical alignment to fit the ad into a narrow width going up each side (not to mention the completely irrelevant ad for investing in Brazilian agriculture &#8211; what is that about?). These are loud and completely distract the user&#8217;s attention.</li>
<li>The next layer is a mixture of ads (Yellow) and navigation links (Blue). The ads here are either irrelevant AdSense style ads, or ads from the Jerusalem Post advertising your ability to advertise on jpost.com (I wonder what the ROI is on that).</li>
<li>The worst part though are the strips of internal navigation links going up and down either side of the page. They all relate to different subcontent areas of the site (things other than news) and each one has a very similar looking graphics. The overall affect is that the graphics make it hard to tell the difference between the different sections, and I am completely turned off from clicking here.</li>
</ol>
<p>Though these ads may add a bit of revenue in the short-term, in the long term the poor usability and design of this page will probably lead to lower traffic, shorter visits by users (in terms of both number of pages visited and overall time spent on the site) and fewer repeat visitors. It also reflects rather poorly on the professionalism of the site (and I would think that conveying an air of professionalism would be quite important in the online news-delivery market space).</p>
<p>Fixing these problems would require:</p>
<ol>
<li><strong>Rethinking the ad strategy for the site</strong>:</li>
<ul>
<li>Do you really need those vertically aligned ads surrounding the whole page? What is that Brazil ad doing all the way out there? Are those AdSense style ads actually getting clicks? The ads should not distract users from the main purpose of the site. Doing so will not get you clicks, they will only end up annoying users.</li>
</ul>
<li><strong>Smarter Navigation</strong>:</li>
<ul>
<li>The navigation links that I would find the most useful (links to other news sections) are the least pronounced and emphasized links on the whole page. Make these easier to use.</li>
<li>Where are the tags? Links to similar articles? Links to most popular articles and most emailed articles? If I saw these, I might spend more time on your site?</li>
<li>Those ads going up and down each side of the content are totally useless. How about using a well designed expanding menu that can include links to all of these areas without taking up so much room and without being such an eyesore? And if you really have to see all of those links at once, do something about the graphics.</li>
</ul>
<li><strong>Standards-Based Design</strong>:</li>
<ul>
<li>Looking at <a href="http://pastebin.com/htDE3LFK" target="_blank">the source</a> for the site, it is a big mess. Definitely not built using web standards. Lots of table-based design. I imagine that this is very hard to maintain and does not play nicely on some or all mobile platforms. And that is not even starting with <a href="http://wave.webaim.org/report?url=http%3A%2F%2Fwww.jpost.com%2FBusiness%2FGlobes%2FArticle.aspx%3Fid%3D258816&amp;js=2" target="_blank">accessibility</a>.</li>
<li>I have a fast Internet connection and I presumably located very close to the servers. Fully loading the page took about 25 seconds, and includes 37 HTML Get/Post requests, 20 separate CSS files, 104 different JS files, 119 different images &#8211; a total of around 290 separate requests. Total downloaded off of a fresh load: 2.5MB (imaging this on a slower connection). Reloading the page still took 240 requests and 19 seconds. This is just not acceptable. It is really bad.</li>
<li></li>
</ul>
</ol>
<p>(To anyone at <a href="http://jpost.com">jpost.com</a> who is reading this &#8211; I have nothing personal against you guys, and I do enjoy reading some of your content. But your site design is so poor, getting to the content is just too hard and too much of a strain on my eyes).</p>
]]></content:encoded>
			<wfw:commentRss>http://ellisweb.net/2012/02/horrible-page-design-at-jpost-com/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Clearing out a Mysterious Table Lock (LCK_M_S) in Sql Server 2008</title>
		<link>http://ellisweb.net/2012/02/clearing-out-a-mysterious-table-lock-lck_m_s-in-sql-server-2008/</link>
		<comments>http://ellisweb.net/2012/02/clearing-out-a-mysterious-table-lock-lck_m_s-in-sql-server-2008/#comments</comments>
		<pubDate>Mon, 13 Feb 2012 20:35:46 +0000</pubDate>
		<dc:creator>Yaakov Ellis</dc:creator>
				<category><![CDATA[Sql Server]]></category>
		<category><![CDATA[lock]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://ellisweb.net/?p=487</guid>
		<description><![CDATA[A user reported today that they were trying to query a table with 181 records and the output stopped at 178 and just hung there. I tried to replicate this and the same thing happened &#8211; also couldn&#8217;t run a Select (*) on the table. So I pulled up the … <a href="http://ellisweb.net/2012/02/clearing-out-a-mysterious-table-lock-lck_m_s-in-sql-server-2008/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
			<content:encoded><![CDATA[<p>A user reported today that they were trying to query a table with 181 records and the output stopped at 178 and just hung there. I tried to replicate this and the same thing happened &#8211; also couldn&#8217;t run a Select (*) on the table. So I pulled up the Activity Monitor for the server and observed that there was only one query in process &#8211; the hung query. It listed the process as being suspended with a Wait Type of <code>LCK_M_S</code>. Some quick searching <a href="http://blog.sqlauthority.com/2011/02/15/sql-server-lck_m_xxx-wait-type-day-15-of-28/">told me</a> that the task was waiting to acquire a shared lock. However, it was not obvious what was locking the table. What to do?</p>
<p>After some more searching, I found two more posts that gave advice on what to do in the given scenario:</p>
<ul>
<li><a href="http://weblogs.sqlteam.com/joew/archive/2008/08/14/60687.aspx">Sql Server Locks, a Sleeping Process Still Holds Them</a></li>
<li><a href="http://blog.sqlauthority.com/2010/10/06/sql-server-quickest-way-to-identify-blocking-query-and-resolution-dirty-solution/">SQL SERVER – Quickest Way to Identify Blocking Query and Resolution – Dirty Solution</a></li>
</ul>
<p>Based on these, I did the following:</p>
<ol>
<ol>
<li>Ran <code>Exec sp_who2</code> through Sql Management Studio. This gave me a list of all current processes. There was only one open process on this database at the time, so it was the likely culprit.</li>
<li>Next, ran the code in the Sql Server Locks article above to show the process that was locking my table. Bingo &#8211; process 52.</li>
</ol>
</ol>
<pre class="brush: sql; gutter: true">USE DBNAME; GO;

DECLARE @dbid INT ; --what&#039;s the dbid for DBNAME?
SET @dbid = DB_ID() ;

DECLARE @objectid INT ; --what&#039;s objectid for our demo table?
SET @objectid = OBJECT_ID(N&#039;TABLENAME&#039;) ;

--look at locking in the DB
SELECT  resource_type
       ,resource_database_id
       ,resource_associated_entity_id
       ,request_mode
       ,request_type
       ,request_session_id
FROM    sys.dm_tran_locks
WHERE   resource_database_id = @dbid ;

--limit the results to only the offending table
SELECT  *
FROM    sys.dm_tran_locks
WHERE   resource_database_id = @dbid AND
        resource_associated_entity_id = @objectid ;</pre>
<p>After I had confirmed the identity of the process, I ran <code>Kill 52</code> to kill the offending process. Everything immediately started working again with the table.</p>
<p>(After the fact, went back through the code with my team and found the spot where someone was running <code>db.Connection.BeginTransation()</code> on a data context that already had an open transaction, causing an error: &#8220;<code>SqlConnection does not support parallel transactions</code>&#8220;. And to make things worse, this was done outside of the <code>try/catch/finally</code> structure that ensured that any open transactions would be committed. Oy.)</p>
<p>As Pinal Dave writes:</p>
<blockquote><p>As mentioned earlier, if you kill something important on your production server, there’s a great possibility that you’ll face some serious integrity issues, so I there’s no way I advise use this method. As the title goes, this is a dirty solution so you must utilize this only if you are confident.</p></blockquote>
<p>It is important to keep that in mind. But that said, this technique for identifying and killing a hung transaction can definitely come in handy. (And be sure to backup your DB and transaction logs regularly!)</p>
]]></content:encoded>
			<wfw:commentRss>http://ellisweb.net/2012/02/clearing-out-a-mysterious-table-lock-lck_m_s-in-sql-server-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Numeric String Sort in C#</title>
		<link>http://ellisweb.net/2011/06/numeric-string-sort-in-c/</link>
		<comments>http://ellisweb.net/2011/06/numeric-string-sort-in-c/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 07:06:42 +0000</pubDate>
		<dc:creator>Yaakov Ellis</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[icomparer]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://ellisweb.net/?p=470</guid>
		<description><![CDATA[Scenario: you have a List&#60;string&#62; collection where the contents could be alpha, numeric, or alphanumeric. If you just sort the collection using the built-in Sort() method, it will use string.CompareTo(), treating each item in the collection as a string. Thus a collection with the following values ["1", "44", "22", 4", … <a href="http://ellisweb.net/2011/06/numeric-string-sort-in-c/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
			<content:encoded><![CDATA[<p>Scenario: you have a <code>List&lt;string&gt;</code> collection where the contents could be alpha, numeric, or alphanumeric. If you just sort the collection using the built-in <code>Sort()</code> method, it will use <code>string.CompareTo()</code>, treating each item in the collection as a string. Thus a collection with the following values <code>["1", "44", "22", 4", "5"]</code> will end up being sorted as <code>["1", "22", "4", "44", "5"]</code> &#8211; even though you might want the items to be treated as numbers (in which case they would be sorted as <code>["1", "4", "5", "22", "44"]</code>.</p>
<p>The solution to this is to use a custom comparer class. I put the following together:</p>
<pre class="brush: csharp; gutter: true">public class NumericStringSort : IComparer {

    int IComparer.Compare(string a, string b) {
        decimal aDec;
        decimal bDec;
        if (decimal.TryParse(a, out aDec) &amp;&amp; decimal.TryParse(b, out bDec)) {
            return aDec.CompareTo(bDec);
        } else {
            return a.CompareTo(b);
        }
    }

    public static IComparer NumericStringSorter() {
        return (IComparer) new NumericStringSort();
    }
}</pre>
<p>As you can see, the class implements the <a href="http://msdn.microsoft.com/en-us/library/system.collections.icomparer.aspx">IComparer</a> interface. If both of the strings can be converted into decimals, then the decimal comparison is used. Otherwise the string comparison is used.</p>
<p>You can see a usage example through the following set of unit tests (as you can see, it also handles mixed alphanumeric sets gracefully, sorting all numeric items to the front of the list in numeric order, followed by all alpha entries in alphabetical order):</p>
<pre class="brush: csharp; gutter: true">[TestFixture]
public class NumericStringSortTests {

    [Test]
    public void TestNumericSort_AllNumeric() {
        List items = new List { &quot;1&quot;, &quot;44&quot;, &quot;22&quot;, &quot;4&quot;, &quot;5&quot; };
        items.Sort(NumericStringSort.NumericStringSorter());
        List expectedItems = new List { &quot;1&quot;, &quot;4&quot;, &quot;5&quot;, &quot;22&quot;, &quot;44&quot; };
        Assert.IsTrue(items.SequenceEqual(expectedItems));
    }

    [Test]
    public void TestNumericSort_MixesAlphaNumeric() {
        List items = new List { &quot;a&quot;, &quot;c&quot;, &quot;d&quot;, &quot;b&quot;, &quot;1&quot;, &quot;2&quot;, &quot;22&quot;, &quot;3&quot; };
        items.Sort(NumericStringSort.NumericStringSorter());
        List expectedItems = new List { &quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;22&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot; };
        Assert.IsTrue(items.SequenceEqual(expectedItems));
    }

    [Test]
    public void TestNumericSort_AllAlpha() {
        List items = new List { &quot;a&quot;, &quot;c&quot;, &quot;d&quot;, &quot;b&quot; };
        items.Sort(NumericStringSort.NumericStringSorter());
        List expectedItems = new List { &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot; };
        Assert.IsTrue(items.SequenceEqual(expectedItems));
    }
}</pre>
<p>This is something that I have needed on previous occasions &#8211; perhaps it may be of use to someone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://ellisweb.net/2011/06/numeric-string-sort-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to Excel and Access Files using .Net on a 64-bit Server</title>
		<link>http://ellisweb.net/2010/01/connecting-to-excel-and-access-files-using-net-on-a-64-bit-server/</link>
		<comments>http://ellisweb.net/2010/01/connecting-to-excel-and-access-files-using-net-on-a-64-bit-server/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 13:30:42 +0000</pubDate>
		<dc:creator>Yaakov Ellis</dc:creator>
				<category><![CDATA[c#]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[ace]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[jet]]></category>
		<category><![CDATA[odbc]]></category>
		<category><![CDATA[oledb]]></category>

		<guid isPermaLink="false">http://ellisweb.net/?p=436</guid>
		<description><![CDATA[If you are trying to query a MS Excel (.xls, .xlsx, .xlsb) or MS Access (.mdb, .accdb) file on a 64-bit server and are getting one of the following error messages: The &#8216;Microsoft.Jet.OLEDB.4.0&#8242; provider is not registered on the local machine. The &#8216;Microsoft.ACE.OLEDB.12.0&#8242; provider is not registered on the local … <a href="http://ellisweb.net/2010/01/connecting-to-excel-and-access-files-using-net-on-a-64-bit-server/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
			<content:encoded><![CDATA[<p>If you are trying to query a MS Excel (.xls, .xlsx, .xlsb) or MS Access (.mdb, .accdb) file on a 64-bit server and are getting one of the following error messages:</p>
<ul>
<li>The &#8216;Microsoft.Jet.OLEDB.4.0&#8242; provider is not registered on the local machine.</li>
<li>The &#8216;Microsoft.ACE.OLEDB.12.0&#8242; provider is not registered on the local machine.</li>
</ul>
<p>Then it is necessary to install <a href="http://www.microsoft.com/downloads/details.aspx?familyid=C06B8369-60DD-4B64-A44B-84B371EDE16D&amp;displaylang=en">2010 Office System Driver Beta: Data Connectivity Components</a> on the server (the reason for this is the old Jet4.0 drover does not exist for 64 bit, and the ACE driver needed to read the newer formats is not installed by default). If you are using a version of Windows with UAC enabled, be sure to do this as Administrator.</p>
<p>After installing the components, use the following connection string formats (from the page linked-to above):</p>
<ul>
<li>Using <strong>OLEDB</strong>, set the Provider argument of the ConnectionString property to “Microsoft.ACE.OLEDB.14.0”. Example: &#8220;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Path_To_File&#8221;</li>
<li>Using <strong>OLEDB </strong>and connecting to a Microsoft Office Excel file, add “Excel 14.0” to the Extended Properties of the OLEDB connection string defined in the previous bullet point.</li>
<li>Using <strong>ODBC</strong>:
<ul>
<li>Connecting to Microsoft Office Access (.mdb or .accdb): set the Connection String to “Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=path to mdb/accdb file”</li>
<li>Connecting to Microsoft Office Excel (.xls, .xlsx, .xlsb): set the Connection String to “Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=path to xls/xlsx/xlsm/xlsb file”</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://ellisweb.net/2010/01/connecting-to-excel-and-access-files-using-net-on-a-64-bit-server/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Fixing the &#8220;circular file references are not allowed&#8221; Error in ASP.net</title>
		<link>http://ellisweb.net/2009/12/fixing-the-circular-file-references-are-not-allowed-error-in-asp-net/</link>
		<comments>http://ellisweb.net/2009/12/fixing-the-circular-file-references-are-not-allowed-error-in-asp-net/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 09:41:06 +0000</pubDate>
		<dc:creator>Yaakov Ellis</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[circular]]></category>
		<category><![CDATA[error]]></category>

		<guid isPermaLink="false">http://ellisweb.net/?p=433</guid>
		<description><![CDATA[If you get the &#8220;circular file references are not allowed&#8221; error in an ASP.net Website Project and you do not have any controls that have any obvious circular references, what does the error mean and how do you fix it? See this blog post from Siderite Zackwehdex as well as … <a href="http://ellisweb.net/2009/12/fixing-the-circular-file-references-are-not-allowed-error-in-asp-net/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
			<content:encoded><![CDATA[<p>If you get the &#8220;<em>circular file references are not allowed</em>&#8221; error in an ASP.net Website Project and you do not have any controls that have any obvious circular references, what does the error mean and how do you fix it?</p>
<p>See this <a href="http://siderite.blogspot.com/2007/09/circular-file-references-are-not.html">blog post</a> from Siderite Zackwehdex as well as this <a href="http://forums.asp.net/t/922622.aspx">MSDN forum post</a>: by default, in a Website Project, ASP.net compiles one dll per folder in an ASP.net project. So if you have the following setup:</p>
<p style="padding-left: 30px;">/folder1/Control1.ascx &gt; References Control2<br />
/folder2/Control2.ascx &gt; References Control3<br />
/folder1/Control3.ascx</p>
<p>This means that the folder1 dll will reference the folder2 dll which will again reference the folder1 dll, causing a &#8220;circular file reference&#8221;.</p>
<p>Ways to fix it:</p>
<ol>
<li>Rearrange the layout of your controls (or masterpages) to remove the circular references (normally this will mean moving one control to another folder &#8211; in the example above, move control2 to folder1). This is the preferred solution.</li>
<li>Use batch=&#8221;false&#8221; in the <a href="http://msdn.microsoft.com/en-us/library/s10awwz0.aspx">compilation</a> tag of the web.config file. This will cause a new dll to be created for each control/page in the site. This should fix the error but is really lousy for performance, so it should be avoided (especially on production sites).</li>
</ol>
<p>(This has happened to me a couple of times already, so posting it here as a reminder to myself for the next time).</p>
]]></content:encoded>
			<wfw:commentRss>http://ellisweb.net/2009/12/fixing-the-circular-file-references-are-not-allowed-error-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Optimal Setup for SyntaxHighlighter &amp; TinyMCE</title>
		<link>http://ellisweb.net/2009/11/optimal-setup-for-syntaxhighlighter-and-tinymce/</link>
		<comments>http://ellisweb.net/2009/11/optimal-setup-for-syntaxhighlighter-and-tinymce/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 11:50:53 +0000</pubDate>
		<dc:creator>Yaakov Ellis</dc:creator>
				<category><![CDATA[WebDev]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[formatting]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[syntaxhighlighter]]></category>

		<guid isPermaLink="false">http://ellisweb.net/?p=424</guid>
		<description><![CDATA[My favorite Javascript-based WYSIWYG editor is TinyMCE. I find it the most visually appealing, and the most well constructed from all of the offerings available on the Internet. When posting code for others to see, I prefer using SyntaxHighlighter. This javascript-based formatting tool by Alex Gorbatchev allows you to put … <a href="http://ellisweb.net/2009/11/optimal-setup-for-syntaxhighlighter-and-tinymce/"> Continue reading <span class="meta-nav">&#8594; </span></a>]]></description>
			<content:encoded><![CDATA[<p>My favorite Javascript-based WYSIWYG editor is <a href="http://tinymce.moxiecode.com/">TinyMCE</a>. I find it the most visually appealing, and the most well constructed from all of the offerings available on the Internet.</p>
<p>When posting code for others to see, I prefer using <a href="http://alexgorbatchev.com/wiki/SyntaxHighlighter">SyntaxHighlighter</a>. This javascript-based formatting tool by Alex Gorbatchev allows you to put the code to be displayed into a Pre or TextArea tag, formats based on the code language, and allows for good degradation in case of NoScript.</p>
<p>I have <a href="http://ellisweb.net/2008/08/using-syntaxhighlighter-to-format-code-in-wordpress/">previously posted</a> on how to get SyntaxHighlighter to play nicely with the built-in text editor inside WordPress (TinyMCE). Now for the first time I needed to set it up on another platform (Telligent Community Server). Here are my recommendations on what to use to achieve optimal setup (this can work on any platform):</p>
<p>Problem 1: <strong>Need Friendlier Way to Input Code</strong> &#8211; The default method for adding code to be formatted woudl be to open up HTML mode in TinyMCE, type in the Pre or TextArea tag with specially formatted attributes, and put in the code. This is ok for myself (this is what I use in WordPress), but when designing a site for others, a friendlier interface is preferable. I found a plugin for TinyMCE: <strong><a href="http://github.com/RichGuk/syntaxhl">SyntaxHL</a></strong> by <a href="http://27smiles.com/2008/04/07/tinymce-syntaxhighlighter-plugin/">Richard Grundy</a>. After installing this (download and copy files to tinymce/plugins directory, and add plugin and button to TinyMCE.Init), a new button is added to TinyMCE that loads a popup which allows easy entry of the code to be formatted and customization of language and display options, without the need to enter html mode. (I would prefer something that could load up highlighted text when the button is pressed, but I will settle on this one for now)</p>
<p>Problem 2: <strong>TinyMCE adds BR Tags within PRE</strong> &#8211; When opening up TinyMCE it performs some cleanup of the Html that is input. Part of this cleanup involves (by default) substituting &lt;BR /&gt; tags instead of New Lines in the source text. For code that has already been saved, this presents a problem. When editing a post with code formatted in a &lt;PRE&gt; tag, instead of preserving the new lines, &lt;BR /&gt;&#8217;s are inserted, completely messing up the formatting. This has been noted <a href="http://drupal.org/node/297240">by</a> <a href="http://www.mainelydesign.com/blog/view/performatted-text-tinymce-pre-tag/">others</a>, and has even been reported in the TinyMCE <a href="http://tinymce.moxiecode.com/punbb/viewtopic.php?id=859">forums</a>, but so far the bug is still in there. To the rescue, another plugin for TinyMCE: <strong><a href="http://sourceforge.net/tracker/index.php?func=detail&amp;aid=2671750&amp;group_id=103281&amp;atid=738747">PreElementFix</a></strong> by <a href="http://sourceforge.net/users/tan73">T Andersen</a>. After installing the files and adding the plugin to TinyMCE.Init, PRE acts as it should: no more insertion of &lt;BR /&gt; tags, and the tab key adds a Tab to the text, rather than advancing to the next field.</p>
]]></content:encoded>
			<wfw:commentRss>http://ellisweb.net/2009/11/optimal-setup-for-syntaxhighlighter-and-tinymce/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

