<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Joel Varty</title><subtitle type="html">A software architect's thoughts from &lt;a href="http://www.edentity.ca" style="text-decoration:underline"&gt;Edentity Web Systems&lt;/a&gt; in Toronto, Canada.</subtitle><id>http://weblogs.asp.net/joelvarty/atom.aspx</id><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/default.aspx" /><link rel="self" type="application/atom+xml" href="http://weblogs.asp.net/joelvarty/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20510.895">Community Server</generator><updated>2009-06-02T08:54:12Z</updated><entry><title>Configuration, System.Diagnostics and Medium Trust</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/11/12/configuration-system-diagnostics-and-medium-trust.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/11/12/configuration-system-diagnostics-and-medium-trust.aspx</id><published>2009-11-12T14:46:28Z</published><updated>2009-11-12T14:46:28Z</updated><content type="html">&lt;p&gt;In the past, I have widely used, and been a fan of, TextWriterTraceListener and EventLogTraceListener configured via the web.config in order to output diagnostics information from a web app or site.&amp;#160; These things have been there since .Net 1, so our main library of code has hooks into System.Diagnostics.&amp;#160; We even implemented a messaging aspect to this so that certain critical errors would trigger an SMTP message to us.&amp;#160; This has been invaluable in determining what is happening with a site as content changes, or something happens that we need to take action on before a complaint comes in.&amp;#160; (Who am I kidding – this is how we find out about bugs that got missed for whatever reason).&lt;/p&gt;  &lt;p&gt;A few months ago, a site we had hosted on a 3rd party provider decided they would switch the site to Medium trust, so all of that diagnostics code was busted.&amp;#160;&amp;#160; The diagnostics config was done using a custom configuration section, so that didn’t work, neither did any method that referenced any class from System.Diagnostics.&lt;/p&gt;  &lt;p&gt;To make matters worse, our error emails weren’t sending out either, since the smtp server was working using a drop folder that was outside out our app folder… gah.&amp;#160; It wasn’t good.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So how did we get around this problem?&lt;/p&gt;  &lt;p&gt;The configuration section was easy to fix – you just need to read the web.config as an XmlDocument and populate your configuration object manually.&amp;#160; I also recommend caching this in Application (remember to use lock() when accessing this collection..) so that the Xml parsing only has to happen once per application life cycle.&lt;/p&gt;  &lt;p&gt;The Diagnostics stuff is a complete wash – you need to switch out all of this code (luckily ours was all routing through a single method, so it wasn’t too crazy) and replace it was custom logic to write to files, event logs, whatever.&amp;#160; I went with the quick and dirty approach and used the System.IO.File.AppendAllText() method.&amp;#160; This may not be as efficient as keeping the file handle open throughout the application, but it also means that you don’t have to worry about having an open file-handle either…&amp;#160; of course the AppendAllText call is wrapped in a lock() so that only one thread can write to the log at once.&amp;#160; The general idea is that your app shouldn’t be spitting out copious amounts of logging unless you are in a problem situation anyways…&lt;/p&gt;  &lt;p&gt;As for the SMTP issue – the provider gave us credentials to send messages through a normal SMTP relay, so that ended up being fine.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The moral of this story?&amp;#160; Think twice before using System.Diagnostics on a site that will be hosted on a third part provider…&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;(Special Note: apparently Azure will be &lt;a href="http://blogs.msdn.com/windowsazure/archive/2009/03/18/hosting-roles-under-net-full-trust.aspx" target="_blank"&gt;NOT be limited to medium trust&lt;/a&gt;… sweet!)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;more later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7252533" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="Azure" scheme="http://weblogs.asp.net/joelvarty/archive/tags/Azure/default.aspx" /><category term="Trace" scheme="http://weblogs.asp.net/joelvarty/archive/tags/Trace/default.aspx" /></entry><entry><title>Shrinking your SQL Server 2005 Transaction Log</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/11/05/shrinking-your-sql-server-2005-transaction-log.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/11/05/shrinking-your-sql-server-2005-transaction-log.aspx</id><published>2009-11-05T14:27:31Z</published><updated>2009-11-05T14:27:31Z</updated><content type="html">&lt;p&gt;I get this question all of the time, and there is a great support article from Microsoft on how to do this.&lt;/p&gt;  &lt;p&gt;One of the ways to truncate the log file is to simply detach the database and re-attach it without the log.&lt;/p&gt;  &lt;p&gt;I DO NOT recommend that unless it is a development db that you don’t care about.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The proper way to do this is to first backup the TRANSACTION LOG portion of the database by using the following command:&lt;/p&gt;  &lt;pre&gt;&lt;strong&gt;&lt;font color="#0000ff"&gt;BACKUP LOG &amp;lt;DatabaseName&amp;gt; TO DISK = '&amp;lt;BackupFile&amp;gt;'&lt;/font&gt;&lt;/strong&gt;&lt;/pre&gt;

&lt;p&gt;And then running a shrinkfile command:&lt;/p&gt;

&lt;pre&gt;&lt;strong&gt;&lt;font color="#0000ff"&gt;DBCC SHRINKFILE (&amp;lt;FileName&amp;gt;, &amp;lt;TargetSize&amp;gt;) WITH NO_INFOMSGS&lt;/font&gt;&lt;/strong&gt;&lt;/pre&gt;

&lt;p&gt;If you run the shrinkfile command without first doing a log backup, all it will remove is the empty space in the ldf file, no matter what target size you specify.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://support.microsoft.com/kb/907511" target="_blank"&gt;Here&lt;/a&gt; is the Microsoft support article that explains this.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;More later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7247823" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="SQL Server 2005" scheme="http://weblogs.asp.net/joelvarty/archive/tags/SQL+Server+2005/default.aspx" /></entry><entry><title>CNET News: Visual Studio 2010 to launch in March</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/10/22/cnet-new-visual-studio-2010-to-launch-in-march-cnet.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/10/22/cnet-new-visual-studio-2010-to-launch-in-march-cnet.aspx</id><published>2009-10-22T13:02:59Z</published><updated>2009-10-22T13:02:59Z</updated><content type="html">&lt;p&gt;According to &lt;a href="http://news.cnet.com/8301-13860_3-10376107-56.html" target="_blank"&gt;this article from CNET News&lt;/a&gt; from October 19th, Visual Studio 2010 will launch in March, 2010.&amp;#160; This sort of follows the current timeline, where the Beta 2 has just been released, and we can probably expect another beta and/or a Release Candidate drop to evaluate before the final release.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://i.i.com.com/cnwk.1d/i/bto/20091015/VS_h_rgb_270x39.png" /&gt; &lt;/p&gt;  &lt;p&gt;Scanning through some of the comments in the CNET post, it seems that many people are debating the usefulness of upgrading their development environment.&amp;#160; I personally don’t understand this.&amp;#160; As of Visual Studio 2008, the ability to target multiple versions of the framework has been there, and the newer tools are miles ahead of their predecessors.&amp;#160; The only distinction that I would make on that is the Business Intelligence tools (which seem to be target more specifically for a given version of Visual Studio and SQL Server) and the legacy C++ tools that have been phased out of Visual Studio over time.&lt;/p&gt;  &lt;p&gt;My only question is whether the new environment, which apparently is based upon Window Presentation Foundation (WPF), will be more or less responsive than the current IDE.&amp;#160; More importantly, will it be more stable, especially with respect to add-ons like Team Explorer and the various “extra” project types, like the Database Professional Edition projects.&amp;#160; &lt;/p&gt;  &lt;p&gt;Possibly the biggest boon from moving to Visual Studio 2010 will be built-in (although I have yet to use it) Azure support.&amp;#160; I believe that building and deploying applications and services to Azure (an other cloud services environments) will be a massive shift in the next generation of .Net.&amp;#160; &lt;/p&gt;  &lt;p&gt;Here’s hoping they get it right!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;More later – joel.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7235895" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="Visual Studio" scheme="http://weblogs.asp.net/joelvarty/archive/tags/Visual+Studio/default.aspx" /><category term="VS 2010" scheme="http://weblogs.asp.net/joelvarty/archive/tags/VS+2010/default.aspx" /><category term=".Net 4.0" scheme="http://weblogs.asp.net/joelvarty/archive/tags/.Net+4.0/default.aspx" /></entry><entry><title>Closer to the finish line with VS 2010 and .Net 4.0!</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/10/20/closer-to-the-finish-line-with-vs-2010-and-net-4-0.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/10/20/closer-to-the-finish-line-with-vs-2010-and-net-4-0.aspx</id><published>2009-10-20T13:05:47Z</published><updated>2009-10-20T13:05:47Z</updated><content type="html">&lt;p&gt;Today on his blog, Scott Guthrie announced on the availability of beta 2 for VS 2010 and .Net 4.0.&lt;/p&gt;  &lt;p&gt;This is bug news for those of who have been waiting anxiously for a product that we can feel confident is close to the final version.&lt;/p&gt;  &lt;p&gt;I normally wait for this release (beta 2) since it usually ships with a “go-live” license, meaning anything that’s in there now is pretty much guaranteed to be there in the gold version.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/19/vs-2010-and-net-4-0-beta-2.aspx" target="_blank"&gt;Here’s&lt;/a&gt; the blog post itself, and &lt;a href="http://msdn.microsoft.com/en-ca/vstudio/dd582936.aspx" target="_blank"&gt;here’s&lt;/a&gt; a direct link to the download page.&lt;/p&gt;  &lt;p&gt;&lt;img src="http://weblogs.asp.net/blogs/scottgu/image_thumb_7407CD79.png" width="483" height="382" /&gt; &lt;/p&gt;  &lt;p&gt;My only question is this: what’s going to change from here on out? &lt;/p&gt;  &lt;p&gt;I have to admit, that the thing I am most concerned about is ASP.Net 4.0 and how it will work from an Ajax and an MVC perspective.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;More later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7233823" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="VS 2010" scheme="http://weblogs.asp.net/joelvarty/archive/tags/VS+2010/default.aspx" /><category term=".Net 4.0" scheme="http://weblogs.asp.net/joelvarty/archive/tags/.Net+4.0/default.aspx" /></entry><entry><title>More URL Routing in Asp.Net 4.0…</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/10/13/more-url-routing-in-asp-net-4-0.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/10/13/more-url-routing-in-asp-net-4-0.aspx</id><published>2009-10-13T12:46:43Z</published><updated>2009-10-13T12:46:43Z</updated><content type="html">&lt;p&gt;We do our own routing with Agility CMS, however we are looking at switching to the more standardized routing built into Asp.Net (as of 3.5sp1). &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I think the capabilities built into Asp.Net 4 will be what kicks us in the pants enough to update our logic, though, as it has some cool features and enough end-to-end link management utilities to make it work for our developers without asking them to re-learn the re-invention of the wheel again.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/scottgu/default.aspx" target="_blank"&gt;Scott Guthrie&lt;/a&gt; outlines some stuff &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx" target="_blank"&gt;here&lt;/a&gt; that describes how to use this mechanism in MVC 2.0 and Web Forms 4.0.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;more later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7228774" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="Agility" scheme="http://weblogs.asp.net/joelvarty/archive/tags/Agility/default.aspx" /><category term="MVC" scheme="http://weblogs.asp.net/joelvarty/archive/tags/MVC/default.aspx" /></entry><entry><title>TFS Power Tools – Get Changeset, Rollback Changeset</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/09/16/tfs-power-tools-get-changeset-rollback-changeset.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/09/16/tfs-power-tools-get-changeset-rollback-changeset.aspx</id><published>2009-09-16T15:33:58Z</published><updated>2009-09-16T15:33:58Z</updated><content type="html">&lt;p&gt;Check it out - &lt;a title="http://blogs.msdn.com/buckh/archive/2005/11/16/493401.aspx" href="http://blogs.msdn.com/buckh/archive/2005/11/16/493401.aspx"&gt;http://blogs.msdn.com/buckh/archive/2005/11/16/493401.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It’s command line only at this point, but I like it.&lt;/p&gt;  &lt;p&gt;Build this into Visual Studio, somebody!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;More later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7208220" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="Visual Studio" scheme="http://weblogs.asp.net/joelvarty/archive/tags/Visual+Studio/default.aspx" /><category term="TFS" scheme="http://weblogs.asp.net/joelvarty/archive/tags/TFS/default.aspx" /></entry><entry><title>Getting excited about AJAX again (but will I use jQuery or Microsoft Ajax 4.0 – or both?)</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/09/16/getting-excited-about-ajax-again-but-will-i-use-jquery-or-microsoft-ajax-4-0-or-both.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/09/16/getting-excited-about-ajax-again-but-will-i-use-jquery-or-microsoft-ajax-4-0-or-both.aspx</id><published>2009-09-16T13:26:18Z</published><updated>2009-09-16T13:26:18Z</updated><content type="html">&lt;p&gt;Dave Reed has a great example of how to do few different things in Preview 5 of Microsoft Ajax 4.0.&lt;/p&gt;  &lt;p&gt;A fee highlights:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Declarative binding of data to templates&lt;/li&gt;    &lt;li&gt;onitemrendering event (is this the same as onitembind?&amp;#160; it looks like it…)&lt;/li&gt;    &lt;li&gt;Dynamically choosing the template for a given data item and its placeholder at render-time.&lt;/li&gt;    &lt;li&gt;Declarative bind of a template to a JSONP call (sweet and powerful)&lt;/li&gt;    &lt;li&gt;Hints of better “imperative,” or pure code interactions with templates (as opposed to declarative bindings).&amp;#160; &lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;&lt;strong&gt;This &lt;/strong&gt;is something I look forward to – I want to be able to have my javascript code easily placed in proper namespaces and in a proper anonymous function without having to boilerplate it all the time.&amp;#160; I think a VS 2010 JavaScript snippet could do this (I copy and paste it everytime I start a new js file at this point).&lt;/li&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;Read the post here - &lt;a title="http://weblogs.asp.net/infinitiesloop/archive/2009/09/10/microsoft-ajax-4-preview-5-the-dataview-control.aspx" href="http://weblogs.asp.net/infinitiesloop/archive/2009/09/10/microsoft-ajax-4-preview-5-the-dataview-control.aspx"&gt;http://weblogs.asp.net/infinitiesloop/archive/2009/09/10/microsoft-ajax-4-preview-5-the-dataview-control.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;PS: This got me think about JSONP and how it normally wraps a JSON object in a single function call.&amp;#160; It would be neat to have multiple calls wrapped in a single JSONP request that simple called more than one function (or the same function multiple times) when it returned.&amp;#160; That would allow a developer to choose (depending on the scenario or even the amount of data involved) whether to call the server 10 times versus say 100 times. &lt;/p&gt;  &lt;p&gt;Thoughts?&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;More later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7208091" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="AJAX" scheme="http://weblogs.asp.net/joelvarty/archive/tags/AJAX/default.aspx" /><category term="VS 2010" scheme="http://weblogs.asp.net/joelvarty/archive/tags/VS+2010/default.aspx" /></entry><entry><title>Always check for null on Request.UserAgent…</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/09/14/always-check-for-null-on-request-useragent.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/09/14/always-check-for-null-on-request-useragent.aspx</id><published>2009-09-14T13:50:00Z</published><updated>2009-09-14T13:50:00Z</updated><content type="html">&lt;p&gt;Personally, I love the “Browser Capabilities” project on codeplex (&lt;a href="http://browserdetection.codeplex.com/" title="http://browserdetection.codeplex.com/" mce_href="http://browserdetection.codeplex.com/"&gt;http://browserdetection.codeplex.com/&lt;/a&gt;) that does a nice job of extracting the actual things that a browser can do, saving you from doing things the following:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;if&lt;/span&gt; (Request.UserAgent.IndexOf(&lt;span class="str"&gt;"AppleWebKit"&lt;/span&gt;) &amp;gt; 0)&lt;br&gt;{&lt;br&gt;   &lt;span class="rem"&gt;//DO SOMETHING&lt;/span&gt;&lt;br&gt;}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;But if you find yourself in a situation where you have custom logic you need to implement around a piece of logic (like I did with a &lt;a href="http://m.cineplex.com" mce_href="http://m.cineplex.com" target="_blank"&gt;mobile site&lt;/a&gt; I recently worked on), rememeber to always do a null check on the UserAgent before performing string operations on it.&lt;/p&gt;

&lt;p&gt;While you’re at it, please don’t do these things either (I won’t say why not – if you don’t know why not, ask somebody):&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Request.QueryString[&lt;span class="str"&gt;"page"&lt;/span&gt;].ToString();&lt;br&gt;DataRow[&lt;span class="str"&gt;"column"&lt;/span&gt;].ToString();&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;p&gt;More later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7205098" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="C#" scheme="http://weblogs.asp.net/joelvarty/archive/tags/C_2300_/default.aspx" /></entry><entry><title>A new blog I’ve started reading (and should have read earlier…)</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/09/14/a-new-blog-i-ve-started-reading-and-should-have-read-earlier.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/09/14/a-new-blog-i-ve-started-reading-and-should-have-read-earlier.aspx</id><published>2009-09-14T13:39:09Z</published><updated>2009-09-14T13:39:09Z</updated><content type="html">&lt;p&gt;I’ve started read Dave Reed’s blog “&lt;a href="http://weblogs.asp.net/infinitiesloop/default.aspx" target="_blank"&gt;Infinities Loop&lt;/a&gt;”.&amp;#160; He’s a member of the ASP.NET team and has some great insight on what’s happening now and in the future of ASP.NET.&lt;/p&gt;  &lt;p&gt;Check it out!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;More later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7205086" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /></entry><entry><title>How JSONP works</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/09/08/how-jsonp-works.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/09/08/how-jsonp-works.aspx</id><published>2009-09-08T17:00:34Z</published><updated>2009-09-08T17:00:34Z</updated><content type="html">&lt;p&gt;There are a plethora of explanations for JSONP (JSON with Padding, I think it stands for) out there – just search for “how JSONP works” and you’ll get a ton of descriptions.&amp;#160; JSONP is provided as an alternative to normal JSON by jQuery on the client side to enable the invocation of services outside of the current domain.&lt;/p&gt;  &lt;p&gt;Some of them are incorrect in explaining that this technology uses a server-server proxy to call out to another server outside of the current domain.&lt;/p&gt;  &lt;p&gt;This is NOT a server-server technology, but rather more like the way a lot of Ad servers by injection javascript into the page using document.write() with a script tag.&lt;/p&gt;  &lt;p&gt;The url for the script tag has a querystring parameter which become that javascript function that wraps up the JSON return value of the web method.&amp;#160; Essentially, a document.write() call creates a script tag on the page which goes to whatever server you want to, and then returns a javascript function object which will get invoked when the script’s response is evaluated by the browser.&amp;#160; This means that the server code has to be tweaked to wrap the JSON return in that function call.&lt;/p&gt;  &lt;p&gt;One thing you will not get from JSONP is notification of network errors or anything that responds nicely to badly formed responses, so you have to accept that as a tradeoff with the ability to invoke services on other domains.&lt;/p&gt;  &lt;p&gt;This is a very high level explanation of JSON, but I hope it gets you started in right direction.&lt;/p&gt;  &lt;p&gt;More later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7196636" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="AJAX" scheme="http://weblogs.asp.net/joelvarty/archive/tags/AJAX/default.aspx" /><category term="jQuery" scheme="http://weblogs.asp.net/joelvarty/archive/tags/jQuery/default.aspx" /></entry><entry><title>TFS: Who edited this text? – Annotations in source control…</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/08/18/tfs-who-edited-this-text-annotations-in-source-control.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/08/18/tfs-who-edited-this-text-annotations-in-source-control.aspx</id><published>2009-08-18T20:22:59Z</published><updated>2009-08-18T20:22:59Z</updated><content type="html">&lt;p&gt;If you were ever looking at some code and wondered who actually changed the line of text you were currently looking at, there is a way to do just that!&lt;/p&gt;  &lt;p&gt;It is called Annotations, and it is a visual tracking of the history of that file’s history in source control, along with any additional annotations added to it manually.&lt;/p&gt;  &lt;p&gt;Get there by right clicking the actual source file and choosing “Source Control | Annotate”&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/joelvarty/image_66ECC26E.png" width="414" height="475" /&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;When you click “Annotate”, a new tab will open in Visual Studio that outlines each change to the file.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/joelvarty/image_7B7211EC.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/joelvarty/image_thumb_341CBBFA.png" width="342" height="312" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;You can see the editor for each version, as well as the clickable change set link associated with the version.&amp;#160; &lt;/p&gt;  &lt;p&gt;Awesome.&lt;/p&gt;  &lt;p&gt;more later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7172597" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="Visual Studio" scheme="http://weblogs.asp.net/joelvarty/archive/tags/Visual+Studio/default.aspx" /><category term="TFS" scheme="http://weblogs.asp.net/joelvarty/archive/tags/TFS/default.aspx" /></entry><entry><title>Run threads and async handlers under the same impersonated identity as the website</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/08/04/run-threads-and-async-handlers-under-the-same-impersonated-identity-as-the-website.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/08/04/run-threads-and-async-handlers-under-the-same-impersonated-identity-as-the-website.aspx</id><published>2009-08-04T13:54:09Z</published><updated>2009-08-04T13:54:09Z</updated><content type="html">&lt;p&gt;When you run a background thread or async handler in asp.net, the thread will not run with the same identity specified in the impersonate tag of the web.config.&amp;nbsp; You can easily get around this by grabbing the identity before the thread starts and either storing it in a variable or passing it to the thread as part of the ParameterizedThreadStart delegate.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Here are some code chunks to copy and paste:&lt;/p&gt;&lt;pre class="csharpcode"&gt;WindowsIdentity appID= System.Security.Principal.WindowsIdentity.GetCurrent();

ParameterizedThreadStart ts = &lt;span class="kwrd"&gt;new&lt;/span&gt; ParameterizedThreadStart(RunSyncThread);
Thread workerThread = &lt;span class="kwrd"&gt;new&lt;/span&gt; Thread(ts);
workerThread.Start(appID);&lt;/pre&gt;
&lt;p&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;
&lt;/p&gt;
&lt;p&gt;Now, from the thread itself, you only need to take the Identity object and impersonate using it.&lt;/p&gt;&lt;pre class="csharpcode"&gt;WindowsImpersonationContext wi = appID.Impersonate();&lt;/pre&gt;&lt;pre class="csharpcode"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;Your thread will now operate under the proper identity!&lt;/p&gt;
&lt;p&gt;more later – joel&lt;/p&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7161069" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="Threading" scheme="http://weblogs.asp.net/joelvarty/archive/tags/Threading/default.aspx" /></entry><entry><title>ResolveUrl in Javascript</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/07/17/resolveurl-in-javascript.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/07/17/resolveurl-in-javascript.aspx</id><published>2009-07-17T18:00:24Z</published><updated>2009-07-17T18:00:24Z</updated><content type="html">&lt;p&gt;This is something that is super easy, yet I get asked about it quite often.&lt;/p&gt;  &lt;p&gt;Here’s how you do it:&lt;/p&gt;  &lt;p&gt;In the master page for the site, put this:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;text/javascript&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="kwrd"&gt;var&lt;/span&gt; baseUrl = &lt;span class="str"&gt;&amp;quot;&amp;lt;%= ResolveUrl(&amp;quot;&lt;/span&gt;~/&lt;span class="str"&gt;&amp;quot;) %&amp;gt;&amp;quot;&lt;/span&gt;;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;Then, in your javascript file, put this function:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;function&lt;/span&gt; ResolveUrl(url) {
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (url.indexOf(&lt;span class="str"&gt;&amp;quot;~/&amp;quot;&lt;/span&gt;) == 0) {
        url = baseUrl + url.substring(2);
    }
    &lt;span class="kwrd"&gt;return&lt;/span&gt; url;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;You could have put the function right in the master page, but then you wouldn’t get intelli-sense on it for the rest of your code.&lt;/p&gt;

&lt;p&gt;Now you can call ResolveUrl with ~/ right from javascript.&amp;#160; &lt;/p&gt;

&lt;p&gt;Super easy, but also super useful!&lt;/p&gt;

&lt;p&gt;If you use themes, you might even want to write something that does a “get themed url” where the current theme is output from the master page via Page.Theme.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;more later – joel.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7149653" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="Javascript" scheme="http://weblogs.asp.net/joelvarty/archive/tags/Javascript/default.aspx" /></entry><entry><title>CSS: Get rid of dashed border on focused elements</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/06/22/css-get-rid-of-dashed-border-on-focused-elements.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/06/22/css-get-rid-of-dashed-border-on-focused-elements.aspx</id><published>2009-06-22T22:12:56Z</published><updated>2009-06-22T22:12:56Z</updated><content type="html">&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: This is meant to be use ONLY ff you do NOT want your user to be able to Tab through the links on your site, or if you have already coded the :focus subclasses or onfocus script events for all of the elements in your site that you wish your user to be able to visually tab through.&lt;/p&gt;  &lt;p&gt;Do you want to get rid of the dashed border that appears when you click on links, flash controls, etc?&lt;/p&gt;  &lt;p&gt;Try this!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;* 
{
    -moz-outline-style: none;     
    outline-style: none;
    outline-width: 0px;
    outline-color: -moz-use-text-color;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;more later - joel&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7132233" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author></entry><entry><title>Visual Studio Team System 2008 Database Edition GDR R2</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/joelvarty/archive/2009/06/02/visual-studio-team-system-2008-database-edition-gdr-r2.aspx" /><id>http://weblogs.asp.net/joelvarty/archive/2009/06/02/visual-studio-team-system-2008-database-edition-gdr-r2.aspx</id><published>2009-06-02T12:54:12Z</published><updated>2009-06-02T12:54:12Z</updated><content type="html">&lt;blockquote&gt;   &lt;p&gt;This is the update to the VS 2008 Database Edition and adds support for SQL Server 2008 and no longer requires a local database server to operate.&amp;#160; It was released back in April, but I just realized I needed it when I installed SQL Server 2008 on my local development machine, and found out that the base install does NOT support SQL Server 2008.&lt;/p&gt;    &lt;p&gt;Now it does!&lt;/p&gt;    &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/joelvarty/2008projecttypes_71C184F8.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="2008-project-types" border="0" alt="2008-project-types" src="http://weblogs.asp.net/blogs/joelvarty/2008projecttypes_thumb_513A4546.png" width="595" height="166" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&amp;amp;displaylang=en#filelist" target="_blank"&gt;Here is the link&lt;/a&gt; to the download.&lt;/p&gt;    &lt;p&gt;This is an update to the VS Database Edition, which is now included if you have Team Developer Edition (or possibly Professional Edition, not sure on that), so be sure to install that first.&lt;/p&gt;    &lt;p&gt;I can’t believe ANYONE does database work these days without using database edition.&lt;/p&gt;    &lt;p&gt;It has become a part of every project I start in Visual Studio.&lt;/p&gt;    &lt;p&gt;&amp;#160;&lt;/p&gt;    &lt;p&gt;more later – joel.&lt;/p&gt;&lt;/blockquote&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7106011" width="1" height="1"&gt;</content><author><name>joelvarty</name><uri>http://weblogs.asp.net/members/joelvarty.aspx</uri></author><category term="ASP.NET" scheme="http://weblogs.asp.net/joelvarty/archive/tags/ASP.NET/default.aspx" /><category term="VS 2010" scheme="http://weblogs.asp.net/joelvarty/archive/tags/VS+2010/default.aspx" /><category term="SQL Server" scheme="http://weblogs.asp.net/joelvarty/archive/tags/SQL+Server/default.aspx" /></entry></feed>