<?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>Gabe Hilado&#039;s SharePoint &#38; ASP.NET Blog &#187; ASP.NET</title>
	<atom:link href="http://spdeveloper.net/category/asp-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://spdeveloper.net</link>
	<description>Microsoft, SharePoint, ASP.NET, Software Solutions</description>
	<lastBuildDate>Thu, 29 Sep 2011 15:13:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Web Part &#8220;Error Creating Control&#8221; in SharePoint Designer</title>
		<link>http://spdeveloper.net/2011/08/web-part-error-creating-control-spd/</link>
		<comments>http://spdeveloper.net/2011/08/web-part-error-creating-control-spd/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 00:34:28 +0000</pubDate>
		<dc:creator>Gabe Hilado</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[SharePoint Designer]]></category>
		<category><![CDATA[Web Parts]]></category>

		<guid isPermaLink="false">http://spdeveloper.net/?p=478</guid>
		<description><![CDATA[When you are developing custom SharePoint web parts using SharePoint Object Model, it’s not enough that you can properly render contents in “Browse mode”.  Your web part must also take into account when the page it is attached to goes into “Edit mode”. In this blog post, I enumerate the different states the web part [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://spdeveloper.net/wp-content/uploads/2011/08/SPD-Error-Creating-Control.png"></a>When you are developing custom SharePoint web parts using SharePoint Object Model, it’s not enough that you can properly render contents in “<strong>Browse mode</strong>”.  Your web part must also take into account when the page it is attached to goes into “<strong>Edit mode</strong>”. In this <a href="http://spdeveloper.net/2009/12/programmatically-check-the-web-part-state/">blog post</a>, I enumerate the different states the web part can be in in any given time. Sometimes, you would want to limit the functionality of the web part when it is not in “Browse mode”. And this is why you <a href="http://spdeveloper.net/2009/12/programmatically-check-the-web-part-state/">check what state</a> the part is in before rendering contents for it.</p>
<p>You must also take into consideration the following use-cases that your web part will participate in:</p>
<ul>
<li>From the site’s <em>Web Part Gallery</em>, clicking the web part and rendering it in “<strong>Preview mode</strong>”.</li>
<li>When editing the page that has the web part in <strong>SharePoint Designer 2010</strong>, that the web part renders properly as a user-control.</li>
</ul>
<p>I want to focus on properly rendering the Web part in SharePoint Designer because this is a use-case that can be commonly missed. Today, I was testing a web part I am developing for Zenpo Software Innovations when I encountered the following error in SharePoint Designer 2010:</p>
<div class="wp-caption aligncenter" style="width: 661px"><a href="http://spdeveloper.net/wp-content/uploads/2011/08/SPD-Error-Creating-Control.png"><img title="SPD-Error-Creating-Control" src="http://spdeveloper.net/wp-content/uploads/2011/08/SPD-Error-Creating-Control.png" alt="Error Creating Control in SharePoint Designer" width="651" height="422" /></a><p class="wp-caption-text">“Error Creating Control” – what does that mean?</p></div>
<p style="text-align: left;">&nbsp;</p>
<p style="text-align: left;">The web part’s <strong>OnLoad </strong>and <strong>OnInit </strong>event-handlers didn’t check that the page is in “<strong>design mode</strong>”. So, it tried to render its content as if it was in browse-mode.</p>
<p style="text-align: left;">The web part uses custom JavaScript. I have to register the scripts in order for the web part to use them. I implement the <a href="http://msdn.microsoft.com/en-us/library/xxc4wkxx.aspx" target="_blank">script-registration</a> during the OnInit event of the web part like the following:</p>
<pre class="brush: csharp;">
        protected override void OnInit(EventArgs e)
        {
                if (!Page.ClientScript.IsClientScriptIncludeRegistered(&quot;Script1&quot;))
                {
                     scriptRegistered = false;
                     Page.ClientScript.RegisterClientScriptInclude(&quot;Script1&quot;,
                            Page.ClientScript.GetWebResourceUrl(this.GetType(),
                            &quot;Zenposoft.Script1.js&quot;));
                }
        }
</pre>
<p>This script registration code works fine on the web browser. The problem is when this code is invoked during SPD-editing of the web part page, <strong>Page.ClientScript.GetWebResourceUrl</strong> returns empty string (under normal browsing state, it would have returned the URL to the WebResource.axd file). And you cannot pass an empty string URL to the Page.ClientScript.RegisterClientScriptInclude method (it will throw an exception if you pass an empty URL). The web part really had no business trying to register scripts during design-time.</p>
<p>You might say to yourself, “this shouldn’t be an issue since Web part pages are edited through the browser anyway”. Think again! Web designers at your organization will use SharePoint Designer at some point to edit SharePoint pages and if your web part cannot handle “design mode” correctly, the designers will see the ugly “<strong>Error Creating Control</strong>” in SPD. You cannot instill confidence in the use of your web part if it’s throwing exceptions in SharePoint Designer!!!</p>
<p>So, how do we fix this? You can use the one of the following or both:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontext.isdesigntime.aspx" target="_blank">SPContext.Current.IsDesignTime</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/system.web.ui.control.designmode.aspx" target="_blank">Control.DesignMode</a></li>
</ul>
<p>I found this <a href="http://blogs.msdn.com/b/sharepointdesigner/archive/2008/10/03/best-practice-to-create-designer-friendly-server-controls.aspx" target="_blank">Microsoft SharePoint Designer Team Blog post</a> that has nice explanation on how to create “designer friendly controls”. <strong>SPContext.Current.IsDesignTime</strong> and <strong>Control.DesignMode</strong> are mentioned in that blog post.</p>
<p>First, I modify the OnInit event-handler such that I register scripts only when “not in design mode”:</p>
<pre class="brush: csharp;">
        protected override void OnInit(EventArgs e)
        {
            if (!this.DesignMode &amp;&amp; !SPContext.Current.IsDesignTime)
            {
                if (!Page.ClientScript.IsClientScriptIncludeRegistered(&quot;Script1&quot;))
                {
                    scriptRegistered = false;
                    Page.ClientScript.RegisterClientScriptInclude(&quot;Script1&quot;,
                            Page.ClientScript.GetWebResourceUrl(this.GetType(),
                            &quot;Zenposoft.Script1.js&quot;));
                }
            }
        }
</pre>
<p>After deploying the modified Web part, we check SharePoint Designer and the errors are gone:</p>
<div id="attachment_486" class="wp-caption aligncenter" style="width: 671px"><a href="http://spdeveloper.net/wp-content/uploads/2011/08/SPD-Error-Gone.png"><img class="size-full wp-image-486" title="SPD-Error-Gone" src="http://spdeveloper.net/wp-content/uploads/2011/08/SPD-Error-Gone.png" alt="SPD-Error-Gone" width="661" height="408" /></a><p class="wp-caption-text">SharePoint Designer Errors - Gone</p></div>
<p>Yes, the errors are gone but we need to display something where the web part(s) are embedded. If the web part in on the page, the designer should render something there; it can’t be just white-space.</p>
<p>In order to render something in “design mode”, we override the <strong>Render</strong> method of the web part:</p>
<pre class="brush: csharp;">
        protected override void Render(HtmlTextWriter writer)
        {
            if (this.DesignMode || SPContext.Current.IsDesignTime)
            {
                writer.Write(&quot;&lt;input type=&quot;button&quot; value=&quot;Web part is in edit mode...&quot; /&gt;&quot;);
            }
            else
            {
                base.Render(writer);
            }
        }
</pre>
<p>If the web part is in “design mode”, we render a simple HTML button. Otherwise, we let the base class (WebPart) handle the rendering. Deploy the updated web part and you should now see the following in SharePoint Designer:</p>
<div id="attachment_487" class="wp-caption aligncenter" style="width: 448px"><a href="http://spdeveloper.net/wp-content/uploads/2011/08/SPD-Render-Control.png"><img class="size-full wp-image-487" title="SPD-Render-Control" src="http://spdeveloper.net/wp-content/uploads/2011/08/SPD-Render-Control.png" alt="SPD-Render-Control" width="438" height="261" /></a><p class="wp-caption-text">Render HTML button in Desing Mode</p></div>
<p>To summarize, you will want to render web parts correctly in designers such as SPD 2010.  The likelihood that Web designers will edit SharePoint pages in SPD is high enough that you will want to “design mode” for your web part to run properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://spdeveloper.net/2011/08/web-part-error-creating-control-spd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS10-070 out &#8211; addresses ASP.NET Padding Oracle Attack Vulnerability</title>
		<link>http://spdeveloper.net/2010/09/ms10-070-addresses-aspnet-padding-oracle-attack-vulnerability/</link>
		<comments>http://spdeveloper.net/2010/09/ms10-070-addresses-aspnet-padding-oracle-attack-vulnerability/#comments</comments>
		<pubDate>Wed, 29 Sep 2010 20:48:02 +0000</pubDate>
		<dc:creator>Gabe Hilado</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://spdeveloper.net/?p=373</guid>
		<description><![CDATA[Microsoft came out today with an out-of-band security update for the ASP.NET Padding Oracle Attack Vulnerability. If you didn&#8217;t perform the recommended workaround last week (when this vulnerability was disclosed) because you thought the Microsoft update was going to come out soon&#8211;well, I think you got lucky today now that the update is out. BUT, I hope [...]]]></description>
			<content:encoded><![CDATA[<p>Microsoft came out today with an out-of-band security update for the <a href="http://spdeveloper.net/2010/09/security-advisory-2416728-released-asp-net-vulnerability/">ASP.NET Padding Oracle Attack Vulnerability</a>. If you didn&#8217;t perform the <a href="http://spdeveloper.net/2010/09/asp-net-vulnerability-homogenize-the-response-codes/">recommended workaround</a> last week (when this vulnerability was disclosed) because you thought the Microsoft update was going to come out soon&#8211;well, I think you got lucky today now that the update is out. BUT, I hope your public ASP.NET sites didn&#8217;t get exploited during all that time! Now that the update is out, you should look into the following Microsoft Security Bulletin as soon as possible:</p>
<p><a href="http://www.microsoft.com/technet/security/bulletin/MS10-070.mspx">http://www.microsoft.com/technet/security/bulletin/MS10-070.mspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://spdeveloper.net/2010/09/ms10-070-addresses-aspnet-padding-oracle-attack-vulnerability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET Vulnerability Workaround &#8211; Homogenize the App&#8217;s Response Codes</title>
		<link>http://spdeveloper.net/2010/09/asp-net-vulnerability-homogenize-the-response-codes/</link>
		<comments>http://spdeveloper.net/2010/09/asp-net-vulnerability-homogenize-the-response-codes/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 21:28:48 +0000</pubDate>
		<dc:creator>Gabe Hilado</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[IIS 7]]></category>

		<guid isPermaLink="false">http://spdeveloper.net/?p=366</guid>
		<description><![CDATA[Yesterday, I blogged about the newest ASP.NET Vulnerability. As of this writing, there is still no patch for the ASP.NET Security Advisory 2416728. If the detection tool as part of the workaround provided by Microsoft reports that your apps are okay, then you don’t have nothing to worry about—just wait for the security update (what [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I blogged about the <a href="http://spdeveloper.net/2010/09/security-advisory-2416728-released-asp-net-vulnerability">newest ASP.NET Vulnerability</a>. As of this writing, there is still no patch for the <a href="http://www.microsoft.com/technet/security/advisory/2416728.mspx" target="_blank">ASP.NET Security Advisory 2416728</a>. If the <a href="http://blogs.technet.com/b/srd/archive/2010/09/17/understanding-the-asp-net-vulnerability.aspx" target="_blank">detection tool as part of the workaround</a> provided by Microsoft reports that your apps are okay, then you don’t have nothing to worry about—just wait for the security update (what else can you do?).</p>
<p>Now, if the detection tool reports that your apps are vulnerable, and the apps are public-facing (on the Web), you will really want to consider the workaround.</p>
<p>The emphasis of the workaround is to “<strong>homogenize the error codes</strong>”. The exploit relies on error codes returned by the application to an attacker. The more differentiated the error codes, the more it learns about the encryption, and the better chance it has on cracking the encryption (read-up on “Padding Oracle Attack”).</p>
<p>I created a stripped-down test ASP.NET Web application project that initially has <strong>customErrors=&#8221;Off&#8221;</strong>. Within the project, I created pages that will deliberately throw errors. I have a “Divide by Zero” page, a “Throw Error” page, a “View State Exception” page, and a link from the default page to a non-existent page. I used Fiddler to monitor the traffic to and from the app while customErrors=&#8221;Off&#8221;. Next, I apply <a href="http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx" target="_blank">Scott Guthrie’s ASP.NET workaround</a> for this vulnerability. I set <strong>customErrors=&#8221;On&#8221;</strong> and initially, I use <strong>redirectMode=&#8221;ResponseRedirect&#8221;</strong>. The <strong>HTTP 500</strong> response codes disappeared but there are still HTTP 302 (redirect) responses. See the evolution of the response codes as I changed the customErrors section:</p>
<p><a href="http://spdeveloper.net/wp-content/uploads/2010/09/Fiddler-with-mixed-error-codes.jpg"><img class="aligncenter size-full wp-image-367" title="Fiddler Screenshot of Mixed Error-Codes" src="http://spdeveloper.net/wp-content/uploads/2010/09/Fiddler-with-mixed-error-codes.jpg" alt="Fiddler Screenshot of Mixed Error-Codes" width="764" height="390" /></a></p>
<p><strong>customErrors=&#8221;On&#8221;</strong> starts at line 13 in the screenshot above. No more HTTP 500 once customErrors was turned on. However, there are still HTTP 302, which may clue-in the attacker that an error occurred and hence the redirect to a generic page.</p>
<p>So we change the customErrors element once more time. I set <strong>redirectMode=&#8221;ResponseRewrite&#8221;</strong>:</p>
<pre class="brush: xml;">   

&lt;customErrors mode=&quot;On&quot; defaultRedirect=&quot;fatwhale.htm&quot; redirectMode=&quot;ResponseRewrite&quot; /&gt;
</pre>
<p>(By the way, in case you’re wondering what the “fatwhale.htm” page is, it is in reference to the <a href="http://farm3.static.flickr.com/2006/2535960917_b589357e4d.jpg" target="_blank">twitter whale</a> whenever twitter service gets overloaded.)</p>
<p>After setting redirectMode=”ResponseRewrite”, the traffic captured by Fiddler shows that everything is consistently HTTP 200, even though we know that run-time errors were occurring on the individual pages:</p>
<p><a href="http://spdeveloper.net/wp-content/uploads/2010/09/Fiddler-homogenized-HTTP-codes.jpg"><img class="size-full wp-image-368 alignnone" title="Fiddler Screenshot - All HTTP 200 Response" src="http://spdeveloper.net/wp-content/uploads/2010/09/Fiddler-homogenized-HTTP-codes.jpg" alt="Fiddler Screenshot - All HTTP 200 Response" width="444" height="289" /></a></p>
<p>Scott responded to some of the comments in his blog post and he strongly encouraged people to homogenize the response/error codes. The Fiddler screenshots I showed above is what I think Scott Gu means by “homogenizing the codes”.</p>
]]></content:encoded>
			<wfw:commentRss>http://spdeveloper.net/2010/09/asp-net-vulnerability-homogenize-the-response-codes/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Security Advisory 2416728 Released &#8211; ASP.NET Vulnerability</title>
		<link>http://spdeveloper.net/2010/09/security-advisory-2416728-released-asp-net-vulnerability/</link>
		<comments>http://spdeveloper.net/2010/09/security-advisory-2416728-released-asp-net-vulnerability/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 02:55:08 +0000</pubDate>
		<dc:creator>Gabe Hilado</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[IIS 7]]></category>

		<guid isPermaLink="false">http://spdeveloper.net/?p=358</guid>
		<description><![CDATA[I&#8217;ve been wanting to write this earlier today but it was a typical busy Monday. It&#8217;s about the recently published vulnerability in ASP.NET. I was looking at my twitter feeds this past Sunday to see what people I’m following are up to. I came across Tom Resing’s tweet about Security Advisory 2416728. The advisory came [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been wanting to write this earlier today but it was a typical busy Monday. It&#8217;s about the recently published vulnerability in ASP.NET. I was looking at my twitter feeds this past Sunday to see what people I’m following are up to. I came across <a href="http://twitter.com/resing" target="_blank">Tom Resing</a>’s tweet about <strong><a href="http://blogs.technet.com/b/msrc/archive/2010/09/17/security-advisory-2416728-released.aspx" target="_blank">Security Advisory 2416728</a></strong>. The advisory came out Friday night (September 17) but I didn&#8217;t read about it till yesterday. I looked into it and was troubled by what was described in the article. In the article, it says;</p>
<blockquote><p><em>At this time we are not aware of any attacks using this vulnerability and we <strong>encourage customers to review the advisory for mitigations and workarounds</strong>.</em></p></blockquote>
<p>Oh yeah, add the fact that the article starts with:</p>
<blockquote><p><em>Today we released </em><a href="http://www.microsoft.com/technet/security/advisory/2416728.mspx"><em>Security Advisory 2416728</em></a><em> describing a<strong> publicly disclosed vulnerability</strong> in ASP.NET that affects all versions of the .NET Framework.</em></p></blockquote>
<p>If those lines don’t get your attention, I don’t know what will!</p>
<p>A detection script was made available also at the TechNet article “<a href="http://blogs.technet.com/b/srd/archive/2010/09/17/understanding-the-asp-net-vulnerability.aspx" target="_blank">Understanding the ASP.NET Vulnerability</a>”. The script is ran as a VBScript and will report all Web app configurations that are vulnerable. If your apps are not vulnerable, the script will report “OK” on the app. The report looks like the following:</p>
<p><span style="font-family: Courier New; font-size: 0.9em;">Microsoft (R) Windows Script Host Version 5.6<br />
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. </span></p>
<p><span style="font-family: Courier New; font-size: 0.9em;">Enumerating possible paths with ASP.Net configuration that have custom errors turned off. </span></p>
<p><span style="font-family: Courier New; font-size: 0.9em;">C:\inetpub\wwwroot\web.config: ** Vulnerable configuration found **<br />
C:\Inetpub\wwwroot\TestApp1\web.config: ** Vulnerable configuration found **<br />
C:\Inetpub\wwwroot\wss\VirtualDirectories\2639\wpresources\web.config: ** Vulnerable configuration found **<br />
C:\Inetpub\wwwroot\wss\VirtualDirectories\4444\web.config: ** Vulnerable configuration found **<br />
C:\Inetpub\wwwroot\TestApp2\web.config: ok</span></p>
<p>If your app shows “Vulnerable configuration found”, then the Security Advisory is applicable for that app. You want to see “ok” like in the last line of the example above.</p>
<p>The vulnerability is called <strong><a href="http://blogs.iis.net/nazim/archive/2010/09/18/asp-net-zero-day-vulnerability-padding-oracle-exploit.aspx" target="_blank">“Padding Oracle Exploit”</a></strong>. The attacker will attempt to send tampered data to the web server and the web server will generate error messages. As more error codes get returned to the attacker for the tampered requests, the attacker can learn what the encryption is. Once the encryption is compromised, the exploit beings. This vulnerability will allow an attacker to read data, even encrypted ones such as data stored in the View State, and even download files such as the <strong>web.config</strong> file from the target server. (But requests for web.config files cannot be served by IIS, right???) Scott Guthrie <a href="http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx" target="_blank">explains in his blog</a> how this vulnerability works. Scott also explains how to workaround this issue. Before a patch or security update appears, this is the best tool against the exploit provided by Microsoft.</p>
<p>You say “But I never store sensitive information in the View State!” Well, read on. In the <a href="http://www.microsoft.com/technet/security/advisory/2416728.mspx" target="_blank">Microsoft TechNet Security Advisory</a> (and even <a href="http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx" target="_blank">Scott’s blog post</a>), the workaround’s main theme is homogenizing the error page. The TechNet security advisory says “<em><strong>Homogenizing errors is a crucial component to help protect against this attack</strong></em>.” This means turning <strong>customErrors</strong> to “On” and explicitly specifying the <strong>defaultRedirect</strong> page. For full details, please read Scott Guthrie’s blog post.</p>
<p>Now, you might say, this is just another over-hyped, exaggerated propaganda by the Microsoft haters. Well you can throw that argument out the window since it is Microsoft itself that is telling its customers about the vulnerability. There is also a <a href="http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-3332" target="_blank">Common Vulnerabilities and Exposure entry</a> for this. The CVE entry says it just has a “candidate” status on it right now and may even be “rejected in the future”.  Is that grounds for ignoring it because it’s just a “candidate” CVE entry? Is it really worth ignoring because the probability and severity of the exploit has not been fully established yet? For public-facing sites, I recommend you implement the workaround as soon as possible. The workaround is fairly cheap to implement—just do it! There will be many apps that will be fine and no workarounds would be necessary (their customErrors configuration is already protected against this exploit). But if the detection tool above says “vulnerable” on your site, and the site is public facing, all I can say is “Wow!” should you decide to ignore it.</p>
]]></content:encoded>
			<wfw:commentRss>http://spdeveloper.net/2010/09/security-advisory-2416728-released-asp-net-vulnerability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Visual Studio 2010 Visual Web Part Project</title>
		<link>http://spdeveloper.net/2010/06/visual-studio-2010-visual-web-part-project/</link>
		<comments>http://spdeveloper.net/2010/06/visual-studio-2010-visual-web-part-project/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 03:06:19 +0000</pubDate>
		<dc:creator>Gabe Hilado</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Developers]]></category>
		<category><![CDATA[MOSS 2007]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Web Parts]]></category>
		<category><![CDATA[WSP]]></category>

		<guid isPermaLink="false">http://spdeveloper.net/?p=334</guid>
		<description><![CDATA[I am in the process of getting up to speed with the new Visual Studio 2010 IDE and how it can be used to develop custom SharePoint 2010 solutions. It’s so easy to do a “Hello World” Web part project now. These days, my Hello World projects typically involve opening up a database table and [...]]]></description>
			<content:encoded><![CDATA[<p>I am in the process of getting up to speed with the new <strong>Visual Studio 2010</strong> IDE and how it can be used to develop custom SharePoint 2010 solutions.</p>
<p>It’s so easy to do a “Hello World” Web part project now. These days, my Hello World projects typically involve opening up a database table and displaying records in a table. I was able to do this with minimal coding and got it up and running—a full blown Web part—in under 15 minutes!</p>
<p>I created a sample project that opens up the <a href="http://msftdbprodsamples.codeplex.com/" target="_blank">AdventureWorks</a> database and displays employee records in a table:</p>
<p style="text-align: center;">
<div class="wp-caption aligncenter" style="width: 344px"><a href="http://spdeveloper.net/wp-content/uploads/2010/06/image1.png"><img style="display: block; border: 0px;" title="Sample Visual Web Part Project using Adventure Works Database" src="http://spdeveloper.net/wp-content/uploads/2010/06/image_thumb1.png" border="0" alt="Sample Visual Web Part Project using Adventure Works Database" width="334" height="430" /></a><p class="wp-caption-text">Sample Visual Web Part Project using Adventure Works Database</p></div>
<p style="text-align: left;">The Web-part looks like the following when used inside SharePoint:</p>
<p style="text-align: center;">
<div class="wp-caption aligncenter" style="width: 733px"><a href="http://spdeveloper.net/wp-content/uploads/2010/06/image2.png"><img style="display: inline; border: 0px;" title="AdventureWorks Employees Web Part" src="http://spdeveloper.net/wp-content/uploads/2010/06/image_thumb2.png" border="0" alt="AdventureWorks Employees Web Part" width="723" height="384" /></a><p class="wp-caption-text">AdventureWorks Employees Web Part So far, I like it!Here are my first impressions:SharePoint project templates come out-of-the-box install of VS 2010. After installing VS 2010, the SharePoint project templates are ready for use. No need to do installations of VS-extensions.SharePoint Project Templates in Visual Studio 2010</p></div>
<p style="text-align: center;"> </p>
<ul>
<li>The <strong>Visual Web Part</strong> project cannot be deployed as a “sandboxed solution”. It has to be deployed as a <strong>farm solution</strong>.</li>
<li><strong>Project-debugging became a lot easier</strong> even with a full-blow farm-deployment. Press F5 in the VS 2010 IDE and Visual Studio will build, package, deploy, and activate your feature, and launch the debug-browser all in one click! When you’re done debugging, terminate Internet Explorer, Visual Studio will deactivate and retract the solution out of SharePoint.</li>
<li>IIS-reset (for the target Web app) even for full-blown deployments when debugging is fast!</li>
<li>Remember in VSeWSS 1.3 where you had to Google first <a href="http://www.google.com/#hl=en&amp;rlz=1W1ADRA_en&amp;q=vsewss+1.3+specify+web+part+group+element.xml&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=vsewss+1.3+specify+web+part+group+element.xml&amp;gs_rfai=&amp;fp=7b315f504f01d538" target="_blank">how to specify the group the Web part appears in</a> because it wasn’t so obvious? Well, it got easier in VS 2010! Now, the E<strong>lements.xml</strong> file has a place-holder for the <strong>Web-part group</strong>. All you have to do, is change it from “<em>Custom</em>” to whatever value you want it to be. It’s so visible now you can’t miss it.</li>
</ul>
<p style="text-align: center;">
<div class="wp-caption aligncenter" style="width: 626px"><a href="http://spdeveloper.net/wp-content/uploads/2010/06/image4.png"><img style="display: block; border: 0px;" title="Web-Part Group Place-Holder in Elements.xml File" src="http://spdeveloper.net/wp-content/uploads/2010/06/image_thumb4.png" border="0" alt="Web-Part Group Place-Holder in Elements.xml File" width="616" height="277" /></a><p class="wp-caption-text">Web-Part Group Place-Holder in Elements.xml File</p></div>
<p style="text-align: center;"> </p>
<ul>
<li>You can now <strong>add Web User Controls (ASCX files) into the project!</strong> As a matter of fact, the project template adds one ASCX file for you. This just made Web Part development a HECK of a lot easier! This is HUGE! Back in VS 2008 developing SharePoint 2007 Web parts, there were no designers available. If developers wanted to use ASCX files, they had to create regular ASP.NET Web apps, design the ASCX files there, write the code-behind, compile the project so the code-behind logic gets packaged with the ASCX files, deploy the ASCX files to UserControls folder within the SharePoint virtual Web app folder, deploy and enable Smart Part, add a Smart Part Web part to the SharePoint pages, then finally, hook-up the Smart Part to the ASCX files. Whew!!! Talk about LOTS of steps! In VS 2010, you don’t need Smart Part or that lengthy way to integrate ASCX file in SharePoint anymore. The challenge of “imagining” what your Web part will look like as you write your C# code is no more. The designer is built in to the Visual Web Part project. Leverage your ASP.NET skills to the max.</li>
<li>Despite all the improvements, Web part development veterans should recognize familiar concepts and project files such as Elements.xml, .webpart file, strong-named key file, packages and features. </li>
</ul>
<p>I have many ASP.NET developer friends who didn’t want to get into SharePoint development because:</p>
<ul>
<li>The Web part project wasn’t easy in SharePoint 2007. No designers, hard to design a visual element.</li>
<li>ASP.NET developers got accustomed to easy debugging of their projects by simply pressing F5 key or the play button on the IDE toolbar. In 2007, ASP.NET developers thought deploying the app and then attaching to the w3wp.exe process (multiple manual steps, not one) was too cumbersome.</li>
<li>It took forever to even debug the code because the SharePoint Web app always recycled on deployments.</li>
</ul>
<p>If you are an ASP.NET developer contemplating if you should try SharePoint development, I highly recommend you try it NOW! SharePoint 2010 development feels like traditional ASP.NET development more than ever!</p>
]]></content:encoded>
			<wfw:commentRss>http://spdeveloper.net/2010/06/visual-studio-2010-visual-web-part-project/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>iPhone App Development and .NET Development</title>
		<link>http://spdeveloper.net/2010/05/iphone-app-development-and-net-development/</link>
		<comments>http://spdeveloper.net/2010/05/iphone-app-development-and-net-development/#comments</comments>
		<pubDate>Sun, 23 May 2010 07:21:28 +0000</pubDate>
		<dc:creator>Gabe Hilado</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[iPhone Apps]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://spdeveloper.net/?p=256</guid>
		<description><![CDATA[If you are a .NET developer and if you happen to also have a Mac environment, I highly recommend that you learn iPhone development. Why? Read on. I purchased a Macbook Pro a week ago and started coding an app within the first 2 hours of getting home! I tell you what, I&#8217;ve been a [...]]]></description>
			<content:encoded><![CDATA[<p>If you are a .NET developer and if you happen to also have a Mac environment, I highly recommend that you learn iPhone development. Why? Read on.</p>
<p>I purchased a <a href="http://www.apple.com/r/store/government/">Macbook Pro</a> a week ago and started coding an app within the first 2 hours of getting home! I tell you what, I&#8217;ve been a PC for a long, long time and a first-time Mac owner. This Macbook Pro Unibody plus the Snow Leopard OS is a really one sweet device. Am I done with PC laptops? Nope&#8211;I&#8217;m just waiting for the HP Envy 14 series to come out&#8211;16Gb RAM config with newest iCore 7 chip plus SSD drives&#8211;that&#8217;s going to be my configuration for SharePoint 2010 mobile development. Anyway, back to the Macbook. So, I started coding my first night owning the Mac. I saw some samples on the Web and started coding iPhone apps. Holy-moly! I saw and typed keywords that I haven&#8217;t used since college (I think)&#8211;the <em>malloc</em> and <em>dealloc</em> commands/keywords!!! I dreaded those things as a young programmer. Memory leaks, buffer overruns&#8211;yep, I got burned many times when I was starting out and I didn&#8217;t allocate/deallocate memory properly in my programs.</p>
<p>So, <strong>what does iPhone development got to do with .NET development</strong>? Well, technology-wise, they are different worlds. XCode uses Objective-C while .NET (mostly) uses C#. They&#8217;re kind of like distant cousins; they&#8217;re similar in some ways but different in many ways. No, I&#8217;m not recommending you abandon .NET and totally convert to XCode. I&#8217;m recommending that you try iPhone development because it will bring you back to fundamentally sound programming practices. As a developer, I felt like <strong>it brought me back to my roots</strong>.  Developers need to <strong>be mindful of performance and memory use</strong> when developing for the iPhone.  In XCode and .NET, there are garbage collectors. Developers don&#8217;t worry about memory-allocation thanks to the garbage-collectors. iPhone apps don&#8217;t have garbage-collectors. Also, device memory is limited on the iPhone. No gigs of RAM. No swap files. Should you try iPhone development, you will see <em>malloc</em> and <em>dealloc</em> again and you will be constantly asking yourself &#8220;maybe I should clean-up stuff in memory and make room for new objects&#8221;. If you&#8217;ve never seen <em>malloc</em> and <em>dealloc</em>, we&#8217;ll I hope it&#8217;s a fun experience discovering for the first time what it&#8217;s like to develop where you are constrained by limited memory. </p>
<p>.NET developer with a Mac: go try iPhone development. If anything, because you&#8217;re forced to think limited CPU cycles and limited memory, it should improve your overall programming skills!</p>
]]></content:encoded>
			<wfw:commentRss>http://spdeveloper.net/2010/05/iphone-app-development-and-net-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a Feature-Receiver to modify the Web.Config File</title>
		<link>http://spdeveloper.net/2010/04/using-a-feature-receiver-to-modify-the-web-config-file/</link>
		<comments>http://spdeveloper.net/2010/04/using-a-feature-receiver-to-modify-the-web-config-file/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 20:26:43 +0000</pubDate>
		<dc:creator>Gabe Hilado</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://spdeveloper.net/?p=221</guid>
		<description><![CDATA[We had a previous SharePoint project where we installed a custom HTTPModule to the SharePoint Web application. Since the SharePoint manifest file cannot inject entries into the httpModules section of the Web.config file (the manifest file can only insert entries inside the SharePoint section of the Web.config such SafeControl entries), we had to use a [...]]]></description>
			<content:encoded><![CDATA[<p>We had a previous SharePoint project where we installed a custom HTTPModule to the SharePoint Web application. Since the SharePoint manifest file cannot inject entries into the <em>httpModules</em> section of the <strong>Web.config</strong> file (the manifest file can only insert entries inside the SharePoint section of the Web.config such SafeControl entries), we had to use a custom <strong>feature-receiver</strong> class, based on the <strong>SPFeatureReceiver</strong>.<strong> </strong>The custom feature-receiver class did it&#8217;s job nicely; whenever the feature got activated, the required entry in the <em>httpModules</em> section of the Web.config file got inserted.</p>
<p>Sequence property of the WebConfigModification can be used to figure out the uninstall order.</p>
<p>Unnamed sections such as <em><strong>connectionStrings</strong></em> and <em><strong>bindings</strong></em> sections, appear to have an XPATH expression that may result in duplicate matching. But, the <strong>ApplyWebConfigModifications</strong> method of the WebConfigModifications object will do it correctly as long as:</p>
<ul>
<li>EnsureChildNode is used as the type</li>
<li>Add/Remove in order that is logical. Example: add <em>connectionStrings</em> section first then the <em>add</em> elements inside the connectionString section.</li>
<li>If you are worried that de-activating a feature will obliterate the connectionStrings section because your feature created it, don&#8217;t. SharePoint will only take out the connectionStrings if there are no other entries created by the <strong>ApplyWebConfigModifications</strong> inside the connectionStrings section. If other features inserted 1 or more connection-string entries there, your feature-receiver will not remove the connectionStrings section. Now, if the connectionString section got edited manually, the SharePoint WebConfigModifcations object will not know this and it doesn&#8217;t matter how many child-nodes there are inside the  connectionString object. The root element (connectionString) in this case will be removed because in SharePoint&#8217;s perspective, there are no existing Web-config modifications inside connectionString.</li>
</ul>
<p><span style="text-decoration: underline;">Conclusion</span>: if you are going to adopt feature-receivers to install web.config entries such as connection-strings and bindings (for Service-References), you must also adopt to policy to discourage manual insert/modification of the web.config entries. Be consistent.</p>
]]></content:encoded>
			<wfw:commentRss>http://spdeveloper.net/2010/04/using-a-feature-receiver-to-modify-the-web-config-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SharePoint Developer Skills</title>
		<link>http://spdeveloper.net/2010/04/sharepoint-developer-skills/</link>
		<comments>http://spdeveloper.net/2010/04/sharepoint-developer-skills/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 14:57:58 +0000</pubDate>
		<dc:creator>Gabe Hilado</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Career]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Developers]]></category>
		<category><![CDATA[Enterprise]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://spdeveloper.net/?p=215</guid>
		<description><![CDATA[There is big SharePoint team in one of my customers and it&#8217;s a good blend of developers, engineers, analysts, and managers. When this team started in 2007, only a handful (2 people really) was knowledgeable in the ways of SharePoint. But because the user-base for this organization is so big, technical resources of other backgrounds [...]]]></description>
			<content:encoded><![CDATA[<p>There is big SharePoint team in one of my customers and it&#8217;s a good blend of developers, engineers, analysts, and managers. When this team started in 2007, only a handful (2 people really) was knowledgeable in the ways of SharePoint. But because the user-base for this organization is so big, technical resources of other backgrounds started getting recruited to become part of the SharePoint team. Traditional network engineers became SharePoint farm admins. ASP.NET developers became SharePoint developers (that’s how I got into SharePoint). Other Web developers (Coldfusion) became SharePoint developers too.</p>
<p>There are still some Coldfusion developers in this organization but these Coldfusion apps are being phased out and eventually  will be converted to ASP.NET and/or SharePoint. These Coldfusion developers do not have a background on ASP.NET programming model, which is really different, closer to VB6 model if you look at it that it is closer to “classic ASP” model. “Classic ASP”, Coldfusion, and PHP are in the same category in my book—they are server-side scripting. ASP.NET and  SharePoint on the other hand are more object-oriented.</p>
<p>One of the Coldfusion developers asked me which topics on <strong>ASP.NET and SharePoint</strong> should they learn and in what order. They are excited to develop SharePoint stuff such as Web parts and workflows but need some guidance on where to start.</p>
<p>Here’s the list of high-level <strong>skills</strong>/topics I pointed out one should in order to <strong>develop SharePoint solutions</strong>:</p>
<ul>
<li><strong>ASP.NET model</strong>
<ul>
<li>ASP.NET User Controls</li>
<li>Intrinsic Objects (HttpContext, Application, Request, Response, Server, etc.)</li>
<li>ASP.NET Page life-cycle</li>
<li>C#</li>
<li>ASP.NET Web App configuration files</li>
<li>.NET Namespaces</li>
</ul>
</li>
<li><strong>Object-Oriented/Component Programming</strong>
<ul>
<li>Properties and Methods</li>
<li>Events</li>
<li>Delegates</li>
<li>Inheritance</li>
<li>Implementation (interfaces and abstracts)</li>
</ul>
</li>
<li><strong>SharePoint Features Development</strong>
<ul>
<li>Visual Studio SharePoint Project Extensions/Templates</li>
<li>SharePoint Object Model</li>
<li>Deploying Features using STSADM</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://spdeveloper.net/2010/04/sharepoint-developer-skills/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dispose SharePoint Objects Correctly</title>
		<link>http://spdeveloper.net/2010/03/dispose-sharepoint-objects-correctly/</link>
		<comments>http://spdeveloper.net/2010/03/dispose-sharepoint-objects-correctly/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 22:01:33 +0000</pubDate>
		<dc:creator>Gabe Hilado</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Developers]]></category>
		<category><![CDATA[Web Parts]]></category>

		<guid isPermaLink="false">http://spdeveloper.net/?p=180</guid>
		<description><![CDATA[In the world of managed-code, the garbage-collector typically clears objects in memory automatically for you. Remember malloc() and free() in C++? In managed code, you just typically write &#8220;variable = new Object()&#8221; and the CLR will allocate the memory for you. In unmanaged world like C++, you had to allocated memory and then deallocate memory [...]]]></description>
			<content:encoded><![CDATA[<p>In the world of managed-code, the garbage-collector typically clears objects in memory automatically for you. Remember malloc() and free() in C++? In managed code, you just typically write &#8220;variable = new Object()&#8221; and the CLR will allocate the memory for you. In unmanaged world like C++, you had to allocated memory and then deallocate memory after use.</p>
<p>Most objects in ASP.NET Framework are allocated/deallocated in memory automatically. However, there are objects that inherit from the <strong>IDisposable. You have to explicitly dispose objects that implement the IDisposable interface or you will run the risk of memory leaks.</strong> Some examples of ASP.NET objects that implement IDisposable include Connection, Command, Adapater, and Reader objects (in the System.Data namespace). You can perform any of the following to dispose these objects properly:</p>
<pre class="brush: csharp;">

SQLConnection connection = new SQLConnection(connectionString);

//use the connection object here

connection.Dispose();
</pre>
<p> </p>
<p>Or, you can using the <strong><em>using </em></strong>statement:</p>
<pre class="brush: csharp;">

using(SQLConnection connection = new SQLConnection(connectionString))

{

                //use connection object here

} // don't have to call Dispose(); the using statement will dispose connection correctly
</pre>
<p>When working with SharePoint API (SharePoint .NET libraries and not the SharePoint Web services), <strong>it is important to know when and when not to dispose SharePoint objects.</strong> If you do not dispose objects in SharePoint, your server will run the risk of memory leaks which can lead to performance issues. If you dispose objects that you&#8217;re not supposed to call Dispose() on, you might inadvertently kill the SharePoint application! For example, the following code will definitely kill the SharePoint Web application:</p>
<pre class="brush: csharp;">

SPContext.Current.Web.Dispose(); // expect calls to your help-desk with this line in your code!
</pre>
<p> </p>
<p>If you are the custodian of the SharePoint farm, you might want to use the <strong><a href="http://code.msdn.microsoft.com/SPDisposeCheck">SP Dispose Checker Tool</a></strong> to ensure that the custom .NET assemblies being installed on your farm will not cause memory leaks.</p>
<p>For complete guidance on when and how to dispose SharePoint objects, you can read the <a href="http://blogs.msdn.com/rogerla/archive/2008/02/12/sharepoint-2007-and-wss-3-0-dispose-patterns-by-example.aspx">SP Dispose Team blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://spdeveloper.net/2010/03/dispose-sharepoint-objects-correctly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Disconnected ODP.Net and System.Data.OracleClient Connections</title>
		<link>http://spdeveloper.net/2009/10/disconnected-odp-net-and-system-data-oracleclient-connections/</link>
		<comments>http://spdeveloper.net/2009/10/disconnected-odp-net-and-system-data-oracleclient-connections/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 06:14:56 +0000</pubDate>
		<dc:creator>Gabe Hilado</dc:creator>
				<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Connection Sring]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[ODP.NET]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[Session]]></category>

		<guid isPermaLink="false">http://spdeveloper.net/?p=24</guid>
		<description><![CDATA[Wow, talk about Mondays! I&#8217;ve been developing an ASP.NET Web service that connects to an Oracle backend.  Up to today, we&#8217;ve only tested on an isolated network and guess what&#8211;the configuration of this environment didn&#8217;t exactly mirror the QA or the production environment. When we were testing on this isolated network, the application never had Oracle [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, talk about Mondays! I&#8217;ve been developing an ASP.NET Web service that connects to an Oracle backend.  Up to today, we&#8217;ve only tested on an isolated network and guess what&#8211;the configuration of this environment didn&#8217;t exactly mirror the QA or the production environment. When we were testing on this isolated network, the application never had Oracle connectivity problems. Today, we go to the staging or QA environment and the Oracle connections would just die after 20 minutes or so. &#8220;<strong><em>ORA-; exceeded maximum idle time </em></strong>&#8220;. If you reload the erroneous page, you get a different error: &#8220;<strong><em>ORA-01012; not logged on</em></strong>&#8220;. Keep reloading the page but the app is stuck with the &#8220;not logged on&#8221; exception. After 30 minutes or so, the application can connect to the Oracle server again! So what happened here?</p>
<p>Here&#8217;s what happened. Apparently, due to security policies set forth by the organization, all Oracle connections must time-out (Oracle session status=&#8221;SNIPE&#8221;) if the connection has exceeded the &#8220;Idle Time&#8221; specification in the Oracle Profile. Without getting deep into Oracle, the server will kill the connections after the Idle Time limit. I actually had our Oracle DBA helped me diagnose the problem. The Oracle DBA set traces and we monitored the Oracle sessions. That&#8217;s when I saw that even if initially, the application will keep several connections open (connection pooling is turned on for the OracleConnection object and you will see INACTIVE status in the Oracle sessions&#8211;inactive is okay&#8211;it just wasn&#8217;t executing commands at that time), after several minutes (15 minutes is the set Idle Time), the Oracle sessions would disappear. In a few rare occassions, we actually saw the Oracle sessions for the app time-out. The sessions appear with a &#8220;SNIPE&#8221; status for a little bit and then the server eventually cleans them up.</p>
<p>Is this behavior reproducable? Absolutely! Create an Oracle Profile (get your DBA if you don&#8217;t have rights to do this) and set the Idle Time to a short interval like 5 minutes. Next, associate the Oracle user-name that the application will use to the profile that has the 5-minute Idle Time limit. Run the app and you should be able to connect to Oracle. Wait like 10 minutes; your next call will generate the Oracle errors. Another way to reproduce this is the run the app for the first time and then watch the Oracle sessions. Kill the sessions created by the app. You will get &#8220;<strong><em>ORA-00028: your session has been killed</em></strong>&#8221; instead of the &#8220;idle time exceeded error&#8221;. But the following Oracle commands after that error will now generate the &#8220;not logged on&#8221; error. The ODP.NET pool manager gave the application a connection that should have been discarded because it&#8217;s already dead!</p>
<p>The ODP.NET provider will keep threads in the pool even though the server has already killed them! What&#8217;s the fix? The fix is a parameter that you need to add to your connection string. On my Oracle connection string, I only specify Data Source, User Name, and Password; no other parameters. I added an additional parameter called Validate Connection and you have to set it equal to True. I googled all day to find what this does. You can learn more out about this at the <a href="http://www.oracle.com/technology/tech/windows/odpnet/tom.html">Oracle site</a>. When you say <strong><em>Validate Connection=True</em></strong> on the connnection string, the ODP.NET connection pool will test the connection first before it returns the connection to the requesting app. The connection string look something like:</p>
<pre class="brush: xml;">
&lt;add key=&quot;connectionString&quot;
     value=&quot;Data Source=ORCL;
            User ID=me;
            Password=myPassword;
            Validate Connection=True;&quot; /&gt;
</pre>
<p> By putting <strong><em>Validate Connection=True</em></strong> on the connection string, connectionObject.Open() will get you a connection that is either:</p>
<ul>
<li>Valid open connection from the connection pool</li>
<li>A fresh new connection the connection pool</li>
</ul>
<p>You&#8217;ll stop getting crappy, dead connections from the pool. What&#8217;s downside? The pool manager will now ping the Oracle server using the connection first (to test if it&#8217;s still valid) before it returns to the application. A small price to pay I say to make the application stable.</p>
<p>I&#8217;ve tested using the <strong>Validation Connection=True</strong> method and it works. I can kill sessions in Oracle and the app will just re-open valid connections. The Oracle instance can be shutdown and restarted&#8211;when it restarts, the pool will simply create new database connections. Another possible approach is to set the <strong>Connection Lifetime</strong> parameter to a time value that is below the Idle Time limit in the server. In theory, this method will make the ODP.NET connection pool will discard the connections before the server kills it. My only problem with this latter strategy is that this doesn&#8217;t take into account Oracle server &#8220;bounce&#8221;, firewall disconnects, physical disconnects and the like. Just go with the Validate Connection parameter&#8211;it is still application pooling; just a bit busier.</p>
<p> </p>
<p><strong><span style="text-decoration: underline;">NOTE</span></strong>: the stuff I wrote above is applicable to ODP.NET only. The System.Data.OracleClient namespace also has OracleConnection, OracleCommand, and adapter and reader objects as well. But they&#8217;re not the same. The System.Data.OracleClient, by default, does not use application pool. I tested this several times, again, by monitoring the Oracle sessions. If you put Pooling=True in your connection string, then the application will use connection pooling. What happens when the sessions are killed or sniped and you are using System.Data.OracleClient.OracleConnection in you app? First, you get &#8220;<strong><em>ORA-00028: your session has been killed</em></strong>&#8221; just like in ODP.NET. The difference between System.Data.OracleClient and ODP.NET OracleConnection is that in the former, it&#8217;s smart enough to not keep giving the cut-off connection back to application. You&#8217;ll get ORA-00028 error once and the succeeding calls should be fine. ODP.NET on the other hand, will keep that bad connection in the pool even though it&#8217;s been bad for a while; only when the ODP.NET connection has exceeded it&#8217;s TTL that it is removed from the pool.</p>
]]></content:encoded>
			<wfw:commentRss>http://spdeveloper.net/2009/10/disconnected-odp-net-and-system-data-oracleclient-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

