<?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>Codepolice.net &#187; ASP.NET</title>
	<atom:link href="http://codepolice.net/category/aspnet/feed/" rel="self" type="application/rss+xml" />
	<link>http://codepolice.net</link>
	<description>C#, ASP.NET, MVC, LINQ, Wordpress and stuff like that</description>
	<lastBuildDate>Mon, 26 Jul 2010 08:58:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Problems with debuging in VS 2010</title>
		<link>http://codepolice.net/2010/07/26/problems-with-debuging-in-vs-2010/</link>
		<comments>http://codepolice.net/2010/07/26/problems-with-debuging-in-vs-2010/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 08:58:47 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=333</guid>
		<description><![CDATA[I opened up an old bloated project today in Visual Studio 2010 and i had huge issues with debugging. I usually use the attach to process way in this project but that suddenly that didn&#8217;t work anymore. Then i tried to debug with F5 but that caused my entire Visual Studio to hang. As i [...]]]></description>
			<content:encoded><![CDATA[<p>I opened up an old bloated project today in Visual Studio 2010 and i had huge issues with debugging. I usually use the attach to process way in this project but that suddenly that didn&#8217;t work anymore. Then i tried to debug with F5 but that caused my entire Visual Studio to hang. As i said, this is a old and bloated project.</p>
<p>Finally i realized that for some reason the &#8220;Attach to process&#8221; dialog had change the option &#8220;Attach to:&#8221; and it was set to &#8220;Managed (4.0) code&#8221;. When i changed it to &#8220;Managed (v2.0, v1.1, v1.0) code&#8221; it worked again.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2010/07/26/problems-with-debuging-in-vs-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS10-024 and KB976323 will reset your IIS SMTP Settings</title>
		<link>http://codepolice.net/2010/04/19/ms10-024-and-kb976323-will-reset-your-iis-smtp-settings/</link>
		<comments>http://codepolice.net/2010/04/19/ms10-024-and-kb976323-will-reset-your-iis-smtp-settings/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 11:12:08 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[KB976323]]></category>
		<category><![CDATA[MS10-024]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=271</guid>
		<description><![CDATA[A client called me this Monday morning and told me there where some issues with one of their sites. The problem turned out to be some issues the SMTP server. After about 2-3 hours of debugging i desperately  tries to do a search on Twitter for &#8220;IIS SMTP&#8221; and to my surprise i could actually [...]]]></description>
			<content:encoded><![CDATA[<p>A client called me this Monday morning and told me there where some issues with one of their sites. The problem turned out to be some issues the SMTP server. After about 2-3 hours of debugging i desperately  tries to do a search on Twitter for &#8220;IIS SMTP&#8221; and to my surprise i could actually use <a href="http://search.twitter.com/search?q=iis+smtp">Twitter&#8217;s real time functionality</a> (an area where Google sucks) to figure out the solution to my problem.</p>
<p>Apparently the update <a href="http://www.microsoft.com/technet/security/bulletin/MS10-024.mspx">KB976323</a> (Microsoft Security Bulletin MS10-024) <a href="http://support.microsoft.com/kb/976323">removed all settings on your SMTP-server</a>. How lovely and a big fail for the QA department on Microsoft. I quickly added my own server as a mail relay and everything worked again.</p>
<p>But the worst part of this was not that MS wiped all my settings. The worst part was that it also caused my Application Pool to crash with this fine message.</p>
<blockquote><p>A process serving application pool &#8216;MyApplication&#8217; suffered a fatal communication error with the Windows Process Activation Service. The process id was &#8217;388&#8242;. The data field contains the error number.</p></blockquote>
<p>And this actually made my website crash and just give the user a Http 503 error (and made quite a disturbance when i celebrated a friends birthday and started to get alerts that the site was down). Any way .. when i uninstalled KB976323 the error message changed to.</p>
<blockquote><p>A process serving application pool &#8216;MyApplication&#8217; terminated unexpectedly. The process id was &#8217;2624&#8242;. The process exit code was &#8217;0xe0434f4d&#8217;.</p></blockquote>
<p>Both of these errors went away after i fixed the settings on the SMTP server but FFS Microsoft. Try to do some test on the updates you push. I want to have automatic updates turned on but i don&#8217;t know if i dare after this debacle.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2010/04/19/ms10-024-and-kb976323-will-reset-your-iis-smtp-settings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problems with MSBUILD tasks after playing with Visual Studio 2010</title>
		<link>http://codepolice.net/2010/02/22/problems-with-msbuild-tasks-after-playing-with-visual-studio-2010/</link>
		<comments>http://codepolice.net/2010/02/22/problems-with-msbuild-tasks-after-playing-with-visual-studio-2010/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 11:16:46 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[visual studio 2010]]></category>
		<category><![CDATA[vs2010]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=225</guid>
		<description><![CDATA[I use a custom MSBUILD xml file to build some of my projects so that i can run stuff to compress CSS/JS files and stuff like that. After installing Visual Studio 2010 and playing around a bit with suddenly my builds started to fail. C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets(132,11): error MSB4064: The "Retries" parameter is not supported [...]]]></description>
			<content:encoded><![CDATA[<p>I use a custom MSBUILD xml file to build some of my projects so that i can run stuff to compress CSS/JS files and stuff like that. After installing Visual Studio 2010 and playing around a bit with suddenly my builds started to fail.</p>
<pre class="brush:shell">C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets(132,11):
error MSB4064: The "Retries" parameter is not supported by the "Copy" task. Verify the parameter exists on the task, and it is a settable public instance property.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets(130,5):
error MSB4063: The "Copy" task could not be initialized with its input parameters.</pre>
<p>After some debugging i realized that Visual Studio 2010 had changed a line in the csproj file of my web application project.</p>
<p><strong>From: </strong></p>
<p><strong>To: </strong></p>
<p>I just had to change this line back to v9.0 to get it to work again. Hopefully this can help someone that has the same problem as me.</p>
<h3>UPDATE!</h3>
<p>Now when the RTM of Visual Studio was released i of course ran into this problem again. This time i tried to find a better solution and found this <a href="http://devlicio.us/blogs/derik_whittaker/archive/2010/02/27/issues-compiling-vs2010-solutions-with-web-projects-from-nant.aspx">post on devlicio</a>. In the comments to that post i found a solution that worked great for me.</p>
<blockquote><p>I had the same issue. I had to alter the MSbuild WebApplication file  located: C:\Program Files  (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications and remove  these entries.</p>
<p>Retries=&#8221;$(CopyRetryCount)&#8221;</p>
<p>and          RetryDelayMilliseconds=&#8221;$(CopyRetryDelayMilliseconds)&#8221;</p>
<p>Once both of these were removed (in 13 places) everything worked  fine. Hope it helps you too.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2010/02/22/problems-with-msbuild-tasks-after-playing-with-visual-studio-2010/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>ASP.NET postback via JQuery / Javascript</title>
		<link>http://codepolice.net/2009/10/14/asp-net-postback-via-jquery-javascript/</link>
		<comments>http://codepolice.net/2009/10/14/asp-net-postback-via-jquery-javascript/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 11:35:04 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[webforms]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=172</guid>
		<description><![CDATA[ASP.NET Webforms isn&#8217;t the best platform to build web applications. I can&#8217;t wait to migrate my apps to ASP.NET MVC but until i have the time to do that i have to coup with some of asp.net strange parts. Today i wanted to invoke a postback via JQuery wich actually was fairly easy but i [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET Webforms isn&#8217;t the best platform to build web applications. I can&#8217;t wait to migrate my apps to ASP.NET MVC but until i have the time to do that i have to coup with some of asp.net strange parts.</p>
<p>Today i wanted to invoke a postback via JQuery wich actually was fairly easy but i wanted to write a small post about it.</p>
<p>The trick was to get the Javascript that asp.net call to do a postback, save it somewhere and then executed via the eval() method. I used a hidden form to store the postback script.</p>
<p><strong>In the asp.net file</strong></p>
<div class="codecolorer-container csharp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">hdnSearchPostBack<span style="color: #008000;">.</span><span style="color: #0000FF;">Value</span> <span style="color: #008000;">=</span> Page<span style="color: #008000;">.</span><span style="color: #0000FF;">ClientScript</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetPostBackEventReference</span><span style="color: #008000;">&#40;</span>SearchButton, <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>
<p><strong>In the js file</strong></p>
<div class="codecolorer-container csharp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">function<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span> eval<span style="color: #008000;">&#40;</span>$<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;#ctl00_ctl00_hdnSearchPostBack&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">val</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span></div></div>
<p>Simple as that!</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2009/10/14/asp-net-postback-via-jquery-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick attach to process in Visual Studio</title>
		<link>http://codepolice.net/2009/09/01/quick-attach-to-process-in-visual-studio/</link>
		<comments>http://codepolice.net/2009/09/01/quick-attach-to-process-in-visual-studio/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 09:09:47 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[attach]]></category>
		<category><![CDATA[macro]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=162</guid>
		<description><![CDATA[When i debug web applications i like to go with the attach to process instead of pressing F5 when i use IIS as the development web server. It has lot of advantages: If you are &#8220;deep down&#8221; in your application you do not have to start from the beginning again. Attach to process lets you [...]]]></description>
			<content:encoded><![CDATA[<p>When i debug web applications i like to go with the <strong>attach to process</strong> instead of pressing F5 when i use IIS as the development web server. It has lot of advantages:</p>
<ul>
<li>If you are &#8220;deep down&#8221; in your application you do not have to start from the beginning again. Attach to process lets you debug the tab/window you already using.</li>
<li>When you &#8220;press play&#8221; in VS and have Firefox as the default search engine you Visual Studio opens a new tab each time you start and you end up with X number of tabs with your app.</li>
<li>Probably more that i can&#8217;t think of right now.</li>
</ul>
<p>Anyway the big disadvantage with this is that it is a pretty tedious process to attach to a process.</p>
<ul>
<li>Press <strong><em>ctrl-alt-p</em></strong> to bring up the attach to process dialog.</li>
<li>Scroll down to w3wp.exe and &#8220;attach&#8221; it. For some reason it doesn&#8217;t work to press &#8220;w&#8221; here either so you have to scroll down manually.</li>
<li>Click ok and then you have to confirm that you really have to do it.</li>
</ul>
<p>I have been doing this for months but today i decided to see if Google had any answer to my problem and surely it did. I found <a href="http://stackoverflow.com/questions/894848/how-can-i-attach-to-a-process-in-visual-studio">this question</a> on Stackoverflow. The answer to the question was to record a macro in Visual Studio that do this for you.</p>
<ul>
<li>Press <strong><em>ctrl-shift-r</em></strong> to start record the Macro.</li>
<li>Do the steps i described above to attach to the process.</li>
<li>Press <strong><em>ctrl-shift-r</em></strong> again to stop the recording.</li>
</ul>
<p>Now you have the attach to process as a temporary macro and can run it with <strong><em>ctrl-shift-p</em></strong>. You will get an error if you try to run it when you already attach to a process and so on but it work. If you want to you can look for the error 0x8971001E and add DTE.Debugger.Stop(True) in the catch part of the macro.</p>
<p>You can also save the macro and add it to your toolbar, attach your own keyboard shortcut to it and so on. Check out <a href="http://www.switchonthecode.com/tutorials/how-to-configure-and-use-visual-studio-macros">this article about macros</a> on &#8220;Switch on the code&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2009/09/01/quick-attach-to-process-in-visual-studio/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My favorite Visual Studio dark theme</title>
		<link>http://codepolice.net/2009/08/11/my-favorite-visual-studio-dark-theme/</link>
		<comments>http://codepolice.net/2009/08/11/my-favorite-visual-studio-dark-theme/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 07:37:51 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[dark theme]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[vs]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=158</guid>
		<description><![CDATA[Every time i reinstall my computer i spend 30 minutes trying to find my favorite dark Visual Studio theme from the web. So i thought i better write about it here so i do not have to look for it again. So for my own pleasure, download the theme here. Link: Rob Conery]]></description>
			<content:encoded><![CDATA[<p>Every time i reinstall my computer i spend 30 minutes trying to find my favorite dark Visual Studio theme from the web. So i thought i better write about it here so i do not have to look for it again. So for my own pleasure, <a href="http://blog.wekeroad.com/2007/10/17/textmate-theme-for-visual-studio-take-2/">download the theme here</a>.</p>
<p><a href="http://codepolice.net/wp-content/uploads/2009/08/codefile.gif"><img class="aligncenter size-full wp-image-159" title="codefile" src="http://codepolice.net/wp-content/uploads/2009/08/codefile.gif" alt="codefile" width="496" height="422" /></a></p>
<p>Link: <a href="http://blog.wekeroad.com/2007/10/17/textmate-theme-for-visual-studio-take-2/">Rob Conery</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2009/08/11/my-favorite-visual-studio-dark-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>404 redirects in code with ASP.NET</title>
		<link>http://codepolice.net/2009/04/14/404-redirects-in-code-with-aspnet/</link>
		<comments>http://codepolice.net/2009/04/14/404-redirects-in-code-with-aspnet/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 14:09:45 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[http-statuscode]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=151</guid>
		<description><![CDATA[I have had problems doing proper 404 redirects in ASP.NET ever since i started to care about proper 404 pages. I do not have any troubles if the page really does not exist. But say for example that i require a querystring on some page and for some reason i do not get a querystring. [...]]]></description>
			<content:encoded><![CDATA[<p>I have had problems doing proper 404 redirects in ASP.NET ever since i <a href="http://googlewebmastercentral.blogspot.com/2008/08/farewell-to-soft-404s.html">started to care about proper 404 pages</a>. I do not have any troubles if the page really does not exist. But say for example that i require a querystring on some page and for some reason i do not get a querystring. Then i guess it&#8217;s proper to give a 404 error.  Today i decided to give it another try and finally i think i have found the solution thanks to two great tips on the amazing Stackoverflow.com.</p>
<p>The first one is that if you want to throw a 404 error you can just do.</p>
<p><strong>throw new HttpException(404, &#8220;Article not found&#8221;);</strong></p>
<p>As simple as that. In almost all other articles i read about this people are talking about doing Response.Status = 404 and stuff like. The problem with that is that the page will continue to execute and you most likley get some kind of error if something vital is missing.</p>
<p>The next thing i learned where that you could do like this.</p>
<div class="codecolorer-container xml twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;</div></div>
<p>Notice the &#8220;redirectMode&#8221; property. It will cause asp.net to not change the url but do a &#8220;Server.Transfer&#8221; like redirect to the error page but keep the URL that thrown the error.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2009/04/14/404-redirects-in-code-with-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slow IIS on Vista with Firefox, Chrome or Safari</title>
		<link>http://codepolice.net/2009/02/19/slow-iis-on-vista-with-firefox-chrome-or-safari/</link>
		<comments>http://codepolice.net/2009/02/19/slow-iis-on-vista-with-firefox-chrome-or-safari/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 20:54:06 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[Safari]]></category>
		<category><![CDATA[Slow]]></category>
		<category><![CDATA[Vista]]></category>
		<category><![CDATA[Webkit]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=145</guid>
		<description><![CDATA[Ever noticed that sites are way slower in Firefox / Safari / Chrome and so on when you try to debug a website localhost on Vista.  Apperently there is some kind of DNS bug caused by IPv6. To fix it in Firefox you can type about:config and look up network.dns.disableIPv6 but this doesn&#8217;t fix the [...]]]></description>
			<content:encoded><![CDATA[<p>Ever noticed that sites are way slower in Firefox / Safari / Chrome and so on when you try to debug a website localhost on Vista.  Apperently there is some kind of <a href="http://weblogs.asp.net/dwahlin/archive/2007/06/17/fixing-firefox-slowness-with-localhost-on-vista.aspx">DNS bug caused by IPv6</a>. To fix it in Firefox you can type<strong> <em>about:config</em></strong> and look up <em><strong>network.dns.disableIPv6</strong> </em>but this doesn&#8217;t fix the issues for other browser.</p>
<p>To fix it system-wide for all browsers edit your hosts file. You find it in %SystemRoot%\System32\drivers\etc.</p>
<p>127.0.0.1       localhost<br />
::1             localhost &lt;- Comment this line<br />
127.0.0.1       .host</p>
<p>Thanks to commenter in<a href="http://weblogs.asp.net/bleroy/archive/2008/12/29/why-are-scripts-slow-to-load-in-firefox-when-using-visual-studio-s-built-in-development-web-server-a-k-a-cassini.aspx"> this post</a> for this.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2009/02/19/slow-iis-on-vista-with-firefox-chrome-or-safari/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>file_get_contents() in asp.net/C#</title>
		<link>http://codepolice.net/2009/02/13/file_get_contents-in-aspnetc/</link>
		<comments>http://codepolice.net/2009/02/13/file_get_contents-in-aspnetc/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 11:25:59 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[bit.ly]]></category>
		<category><![CDATA[file_get_contents()]]></category>
		<category><![CDATA[StreamReader]]></category>
		<category><![CDATA[WebRequest]]></category>

		<guid isPermaLink="false">http://codepolice.net/?p=137</guid>
		<description><![CDATA[The URL shortening service http://bit.ly has a really simple and convient API that lets just get a short url like this. http://bit.ly/api?url=http://www.myreallylong.com/url/with/lots?of=crap I&#8217;ve used this in a wordpress installation with PHP before and there i could just do. $twitter_url .= file_get_contents&#40;'http://bit.ly/api?url=' . get_permalink&#40;&#41;&#41;; Simple and clean. But today i wanted to do the same thing [...]]]></description>
			<content:encoded><![CDATA[<p>The URL shortening service http://bit.ly has a really simple and convient API that lets just get a short url like this.</p>
<p>http://bit.ly/api?url=http://www.myreallylong.com/url/with/lots?of=crap</p>
<p>I&#8217;ve used this in a wordpress installation with PHP before and there i could just do.</p>
<div class="codecolorer-container php twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000088;">$twitter_url</span> <span style="color: #339933;">.=</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://bit.ly/api?url='</span> <span style="color: #339933;">.</span> get_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>Simple and clean. But today i wanted to do the same thing with asp.net and found myself kind of lost. At last i came up with this, not as simple solution. But it works.</p>
<div class="codecolorer-container csharp twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="csharp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #6666cc; font-weight: bold;">string</span> shortUrl <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> StreamReader<span style="color: #008000;">&#40;</span>WebRequest<span style="color: #008000;">.</span><span style="color: #0000FF;">Create</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;http://bit.ly/api?url=http://fragor.ohsohightech.se&quot;</span> <span style="color: #008000;">+</span> Url<span style="color: #008000;">.</span><span style="color: #0000FF;">Action</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Question&quot;</span>, <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #008000;">&#123;</span> number <span style="color: #008000;">=</span> question<span style="color: #008000;">.</span><span style="color: #0000FF;">Number</span>, title <span style="color: #008000;">=</span> question<span style="color: #008000;">.</span><span style="color: #0000FF;">Title</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ConvertTextToUrl</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#125;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetResponse</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetResponseStream</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ReadToEnd</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></div></div>

]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2009/02/13/file_get_contents-in-aspnetc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Publish web application project failed</title>
		<link>http://codepolice.net/2009/01/14/publish-web-application-project-failed/</link>
		<comments>http://codepolice.net/2009/01/14/publish-web-application-project-failed/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 17:58:19 +0000</pubDate>
		<dc:creator>Ola</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[Publish failed]]></category>
		<category><![CDATA[Publish fails]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[visual studio 2008]]></category>

		<guid isPermaLink="false">http://www.codepolice.net/?p=133</guid>
		<description><![CDATA[I have had huge problems on various projects with the &#8220;publish&#8221; functionality in Visual Studio 2008. I like the feature, you just click publish, choose a directory and the files that is needed on the webserver is placed in the folder and you can easliy copy it to your server or whatever. The problem with [...]]]></description>
			<content:encoded><![CDATA[<p>I have had huge problems on various projects with the &#8220;publish&#8221; functionality in Visual Studio 2008. I like the feature, you just click publish, choose a directory and the files that is needed on the webserver is placed in the folder and you can easliy copy it to your server or whatever.</p>
<p>The problem with it is that it seems to fail from time to time. The output window gives no clues what so ever what has gone wrong so it&#8217;s kind of hard to debug. When you google it you get all sorts of threads and post about people having problems with this but it seems like it a diffrent solution for it everywhere.</p>
<p>Anyway i gave up and started looking towards MSBUILD and found <a href="http://codingcockerel.co.uk/2008/05/18/how-to-publish-a-web-site-with-msbuild/">this great post</a> about how to simulate the behavior of the publish feature with MSBUILD. You just create a Build.xml file and then you run msbuild.exe build.xml. My Build.xml file looks like this.</p>
<div class="codecolorer-container xml twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Project</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://schemas.microsoft.com/developer/msbuild/2003&quot;</span> <span style="color: #000066;">DefaultTargets</span>=<span style="color: #ff0000;">&quot;Run&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Import</span> <span style="color: #000066;">Project</span>=<span style="color: #ff0000;">&quot;C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;PropertyGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;OutputFolder<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Publish<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/OutputFolder<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ProjectDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>C:\code\<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ProjectDir<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;CompilationDebug</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;CustomErrorsMode</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ContentEditorsEmail</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;AdministratorsEmail</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/PropertyGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;PropertyGroup</span> <span style="color: #000066;">Condition</span>=<span style="color: #ff0000;">&quot;$(Environment) == 'Test'&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DeploymentFolder<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>C:\Staging\Test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DeploymentFolder<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/PropertyGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;PropertyGroup</span> <span style="color: #000066;">Condition</span>=<span style="color: #ff0000;">&quot;$(Environment) == 'Live'&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;DeploymentFolder<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>C:\Staging\Live<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/DeploymentFolder<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/PropertyGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Target</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Run&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;CallTarget</span> <span style="color: #000066;">Targets</span>=<span style="color: #ff0000;">&quot;Compile&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;CallTarget</span> <span style="color: #000066;">Targets</span>=<span style="color: #ff0000;">&quot;Publish&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Target</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Clean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ItemGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;BinFiles</span> <span style="color: #000066;">Include</span>=<span style="color: #ff0000;">&quot;bin\*.*&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ItemGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Delete</span> <span style="color: #000066;">Files</span>=<span style="color: #ff0000;">&quot;@(BinFiles)&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Target</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Compile&quot;</span> <span style="color: #000066;">DependsOnTargets</span>=<span style="color: #ff0000;">&quot;Clean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;MSBuild</span> <span style="color: #000066;">Projects</span>=<span style="color: #ff0000;">&quot;myproject.csproj&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Target</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;Publish&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;RemoveDir</span> <span style="color: #000066;">Directories</span>=<span style="color: #ff0000;">&quot;$(OutputFolder)&quot;</span> <span style="color: #000066;">ContinueOnError</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;MSBuild</span> <span style="color: #000066;">Projects</span>=<span style="color: #ff0000;">&quot;myproject.csproj&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">Targets</span>=<span style="color: #ff0000;">&quot;ResolveReferences;_CopyWebApplication&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">Properties</span>=<span style="color: #ff0000;">&quot;WebProjectOutputDir=$(OutputFolder);OutDir=$(WebProjectOutputDir)\&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>This works great for me for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://codepolice.net/2009/01/14/publish-web-application-project-failed/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->