<?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>All Free Tech</title>
	<atom:link href="http://www.allfreetech.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.allfreetech.com</link>
	<description>For developers</description>
	<lastBuildDate>Fri, 29 Jan 2010 14:12:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Create an ASP.NET Modal Popup Login</title>
		<link>http://www.allfreetech.com/ajax/how-to-create-an-asp-net-modal-popup-login-158.html</link>
		<comments>http://www.allfreetech.com/ajax/how-to-create-an-asp-net-modal-popup-login-158.html#comments</comments>
		<pubDate>Fri, 29 Jan 2010 14:12:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Ajax]]></category>

		<guid isPermaLink="false">http://www.allfreetech.com/?p=158</guid>
		<description><![CDATA[In this article, Yi demonstrates how to create a modal popup login page in ASP.NET. By using Login controls, AJAX Extensions, and the AJAX Control Toolkit, you can easily accomplish this task without much coding. The demo project is based on Visual Web Developer Express 2008 and the .NET Framework 3.5. It also assumes you [...]]]></description>
			<content:encoded><![CDATA[<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">In this article, Yi demonstrates how to create a modal popup login page in ASP.NET. By using Login controls, AJAX Extensions, and the AJAX Control Toolkit, you can easily accomplish this task without much coding. The demo project is based on Visual Web Developer Express 2008 and the .NET Framework 3.5. It also assumes you have installed the AJAX Control Toolkit.<span id="more-158"></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><span id="intellitTxt"><a class="pageTitle" id="#Page1" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">Introduction</a></span></span></p>
<div class="backToTop" style="font-size: 11px; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">In this article, I will demonstrate how to create a modal popup login page in&nbsp;<a class="kLink" href="http://aspalliance.com/1882_How_to_Create_an__ASPNET_Modal_Popup_Login.all#" id="KonaLink0" style="color: blue !important; background-color: transparent !important; border-bottom-style: none !important; text-decoration: underline !important; cursor: pointer; font-family: verdana; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-top-style: none !important; border-right-style: none !important; border-left-style: none !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; text-transform: none !important; display: inline !important; font-variant: normal; top: 0px; right: 0px; bottom: 0px; left: 0px; position: static; background-position: initial initial !important; background-repeat: initial initial !important; " target="undefined"><font color="blue" style="color: blue !important; font-family: Verdana, sans-serif; font-weight: normal; font-size: 13px; position: static; "><span class="kLink" style="border-top-width: 0px !important; border-top-style: none !important; border-top-color: initial !important; border-left-width: 0px !important; border-left-style: none !important; border-left-color: initial !important; border-right-width: 0px !important; border-right-style: none !important; border-right-color: initial !important; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: initial; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 1px !important; padding-left: 0px !important; color: blue !important; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; width: auto !important; float: none !important; display: inline !important; font-family: Verdana, sans-serif; font-weight: normal; font-size: 13px; position: static; background-position: initial initial; background-repeat: initial initial; ">ASP.NET</span></font></a>. By using Login controls, AJAX Extensions and Toolkit, you can easily accomplish this task without much coding.</span></div>
<div class="KonaBody">
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">The demo project is based on Visual Web&nbsp;<a class="kLink" href="http://aspalliance.com/1882_How_to_Create_an__ASPNET_Modal_Popup_Login.all#" id="KonaLink1" style="color: blue !important; background-color: transparent !important; border-bottom-style: none !important; text-decoration: underline !important; cursor: pointer; font-family: verdana; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-top-style: none !important; border-right-style: none !important; border-left-style: none !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; text-transform: none !important; display: inline !important; font-variant: normal; top: 0px; right: 0px; bottom: 0px; left: 0px; position: static; background-position: initial initial !important; background-repeat: initial initial !important; " target="undefined"><font color="blue" style="color: blue !important; font-family: Verdana, sans-serif; font-weight: normal; font-size: 13px; position: static; "><span class="kLink" style="border-top-width: 0px !important; border-top-style: none !important; border-top-color: initial !important; border-left-width: 0px !important; border-left-style: none !important; border-left-color: initial !important; border-right-width: 0px !important; border-right-style: none !important; border-right-color: initial !important; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: blue; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 1px !important; padding-left: 0px !important; color: blue !important; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; width: auto !important; float: none !important; display: inline !important; font-family: Verdana, sans-serif; font-weight: normal; font-size: 13px; position: static; background-position: initial initial; background-repeat: initial initial; ">Developer</span></font></a></span>&nbsp;Express 2008 and .NET Framework 3.5. It also assumes you have installed AJAX Toolkit. You can&nbsp;<a class="kLink" href="http://aspalliance.com/1882_How_to_Create_an__ASPNET_Modal_Popup_Login.all#" id="KonaLink2" style="color: blue !important; background-color: transparent !important; border-bottom-style: none !important; text-decoration: underline !important; cursor: pointer; font-family: verdana; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-top-style: none !important; border-right-style: none !important; border-left-style: none !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; text-transform: none !important; display: inline !important; font-variant: normal; top: 0px; right: 0px; bottom: 0px; left: 0px; position: static; background-position: initial initial !important; background-repeat: initial initial !important; " target="undefined"><font color="blue" style="color: blue !important; font-family: Verdana, sans-serif; font-weight: normal; font-size: 13px; position: static; "><span class="kLink" style="border-top-width: 0px !important; border-top-style: none !important; border-top-color: initial !important; border-left-width: 0px !important; border-left-style: none !important; border-left-color: initial !important; border-right-width: 0px !important; border-right-style: none !important; border-right-color: initial !important; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: initial; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 1px !important; padding-left: 0px !important; color: blue !important; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; width: auto !important; float: none !important; display: inline !important; font-family: Verdana, sans-serif; font-weight: normal; font-size: 13px; position: static; background-position: initial initial; background-repeat: initial initial; ">download</span></font></a>&nbsp;source code from here.</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">[<span class="MsoHyperlink"><a href="http://authors.aspalliance.com/YLiu/ModalPopupLogin.zip" style="color: rgb(144, 11, 9); background-color: transparent; ">Download Sample</a></span>]</p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 1 &ndash; Login page with modal popup</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><img border="0" height="343" id="Picture 7" src="http://aspalliance.com/ArticleFiles/1882/image001.jpg" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " width="432" /></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">Key features of this project include:</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>Place login part in MasterPage and content in ContentPage.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>Utilize Login, LoginStatus controls.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>Use ModalPopupExtender and UpdatePanel to avoid postback.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>Take advantage of Forms Authentication.</p>
</div>
<p><span id="intellitTxt"><a class="pageTitle" id="#Page2" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">Walkthrough</a></span></p>
<div class="backToTop" style="font-size: 11px; "><span class="Apple-style-span" style="font-size: 12px; ">Let&rsquo;s get started by creating a new website, and then add a MasterPage. Based on the MasterPage, add a ContentPage and rename it to Login.aspx. You should have files similar to Listing 2 by then.</span></div>
<div class="KonaBody">
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 2 -&nbsp;<a class="kLink" href="http://aspalliance.com/1882_How_to_Create_an__ASPNET_Modal_Popup_Login.all#" id="KonaLink3" style="color: blue !important; background-color: transparent !important; border-bottom-style: none !important; text-decoration: underline !important; cursor: pointer; font-family: verdana; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-top-style: none !important; border-right-style: none !important; border-left-style: none !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; text-transform: none !important; display: inline !important; font-variant: normal; top: 0px; right: 0px; bottom: 0px; left: 0px; position: static; background-position: initial initial !important; background-repeat: initial initial !important; " target="undefined"><font color="blue" style="color: blue !important; font-family: Verdana, sans-serif; font-weight: bold; font-size: 13px; position: static; "><span class="kLink" style="border-top-width: 0px !important; border-top-style: none !important; border-top-color: initial !important; border-left-width: 0px !important; border-left-style: none !important; border-left-color: initial !important; border-right-width: 0px !important; border-right-style: none !important; border-right-color: initial !important; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: initial; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 1px !important; padding-left: 0px !important; color: blue !important; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; width: auto !important; float: none !important; display: inline !important; font-family: Verdana, sans-serif; font-weight: bold; font-size: 13px; position: static; background-position: initial initial; background-repeat: initial initial; ">Files</span></font></a>&nbsp;created for the project</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><img border="0" height="260" id="Picture 4" src="http://aspalliance.com/ArticleFiles/1882/image002.jpg" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " width="296" /></p>
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">web.config</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">To restrict anonymous access and allow only authenticated user, we need to add a few lines in web.config file. Note that the authentication mode is set to Forms.</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; "><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">authentication</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">mode</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;Forms&quot;</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">/&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">authorization</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">deny</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">users</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;?&quot;</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">/&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">allow</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">users</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;*&quot;</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">/&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;/</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">authorization</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span></span></pre>
</div>
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">MasterPage.master</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">Now go to MasterPage.master and we will do the most important work here. Follow steps below.</p>
<p class="MsoListNumber" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; ">1.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span>Add a ScriptManager on MasterPage, which enables the website to run AJAX.</p>
<p class="MsoListNumber" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; ">2.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span>On the same page, create a LoginStatus and place it right above ContentPlaceHolder.</p>
<p class="MsoListNumber" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; ">3.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span>Right click the LoginStatus and select Add Extender. Choose the ModalPopupExtender.</p>
<p class="MsoListNumber" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; ">4.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span>Right below the ContentPlaceHolder, create a Panel. Within the ContentPlaceHolder, add a UpdatePanel.</p>
<p class="MsoListNumber" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; ">5.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span>At last, put a Login control in the UpdatePanel.</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">In design view, you should get a page similar to Listing 3.</p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 3 &#8211; design view of Login.aspx</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><img border="0" height="206" id="Picture 10" src="http://aspalliance.com/ArticleFiles/1882/image003.jpg" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " width="272" /></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">However, to make things work we have to add a few more lines. First, let&rsquo;s add two styles in the markup; we will use them very soon. The first style is for the transparent background on top of regular content. Second one tells how the small popup dialog looks like.</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; "><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">style</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">type</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;text/css&quot;</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.modalBackground&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background-color:&nbsp;Gray;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filter:&nbsp;alpha(opacity=30);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opacity:&nbsp;0.3;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.modalPopup&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width:&nbsp;250px;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;height:&nbsp;150px;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;background-color:&nbsp;#076DAB;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;color:&nbsp;#FFFFFF;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;border-color:&nbsp;#000000;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;border-width:&nbsp;1px;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;border-style:&nbsp;solid;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;text-align:&nbsp;center;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor:&nbsp;move;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;font-size:&nbsp;medium;}
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;/</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">style</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span></span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">Next, go to ModalPopupExtender&rsquo;s properties: set the style for BackgroundCssClass and assign the panel ID to PopupControlID. As a result, the extender markup should look like:</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; "><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">cc1:ModalPopupExtender</span> <span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">ID</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;LoginStatus1_ModalPopupExtender&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">runat</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;server&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">DynamicServicePath</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;&quot;</span>
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">Enabled</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;True&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">TargetControlID</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;LoginStatus1&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">BackgroundCssClass</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;modalBackground&quot;</span>
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">PopupControlID</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;Panel1&quot;</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;/</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">cc1:ModalPopupExtender</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span></span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">Go to the panel&rsquo;s markup (NOT UpdatePanel): set the CssClass.</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; "><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">asp:Panel</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">ID</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;Panel1&quot;</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">runat</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;server&quot;</span> <span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">CssClass</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;modalPopup&quot;</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">Style</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;display:&nbsp;none&quot;</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span></span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">It is worth to note that if you don&rsquo;t set the display style to none, users will have an unpleasant experience: the popup dialog would&nbsp;<a class="kLink" href="http://aspalliance.com/1882_How_to_Create_an__ASPNET_Modal_Popup_Login.all#" id="KonaLink4" style="color: blue !important; background-color: transparent !important; border-bottom-style: none !important; text-decoration: underline !important; cursor: pointer; font-family: verdana; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-top-style: none !important; border-right-style: none !important; border-left-style: none !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; text-transform: none !important; display: inline !important; font-variant: normal; top: 0px; right: 0px; bottom: 0px; left: 0px; position: static; background-position: initial initial !important; background-repeat: initial initial !important; " target="undefined"><font color="blue" style="color: blue !important; font-family: Verdana, sans-serif; font-weight: normal; font-size: 13px; position: static; "><span class="kLink" style="border-top-width: 0px !important; border-top-style: none !important; border-top-color: initial !important; border-left-width: 0px !important; border-left-style: none !important; border-left-color: initial !important; border-right-width: 0px !important; border-right-style: none !important; border-right-color: initial !important; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: initial; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 1px !important; padding-left: 0px !important; color: blue !important; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; width: auto !important; float: none !important; display: inline !important; font-family: Verdana, sans-serif; font-weight: normal; font-size: 13px; position: static; background-position: initial initial; background-repeat: initial initial; ">flash</span></font></a>&nbsp;in and out when it is loaded first time. You may also wonder why not to place this style into CssClass. Doing that will keep the popup from showing forever!</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">Now we are going to work on the Login control a little bit. Here is the markup for it.</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; "><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">asp:Login</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">ID</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;Login1&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">runat</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;server&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">DestinationPageUrl</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;~/Login.aspx&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">DisplayRememberMe</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;False&quot;</span>
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">TitleText</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">UserNameLabelText</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;Employee:&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">OnAuthenticate</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;Login1_Authenticate&quot;</span>
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">FailureText</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;Incorrect&nbsp;employee&nbsp;or password&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">Width</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;100%&quot;</span>&nbsp;
<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">VisibleWhenLoggedIn</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;False&quot;</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;/</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">asp:Login</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span></span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">We have almost everything but a Cancel button. Change to design view again. Click on Login control and select Convert to Template. Drag and drop a Button next to Login button. We make it as a Cancel button. The OnClick event handler will be implemented later.</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; "><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">asp:Button</span>&nbsp;&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">ID</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;btnCancel&quot;</span> <span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">runat</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;server&quot;</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">OnClick</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;btnCancel_Click&quot;</span> <span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">Text</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;Cancel&quot;</span>&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">/&gt;</span></span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">Go to source view. This time we will move around those controls in the Login template to make it pretty. Our work on MasterPage.master is done. Let&rsquo;s visit the C# code behind it.</p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 4 &#8211; Finished Login.aspx</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><img border="0" height="238" id="Picture 1" src="http://aspalliance.com/ArticleFiles/1882/image004.jpg" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " width="338" /></p>
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">MasterPage.master.cs</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">Copy and paste following codes to this file. Explanations are in comments.</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; "><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">using</span>&nbsp;System;
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">using</span>&nbsp;System.Web.UI.WebControls;
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">using</span>&nbsp;System.Web.Security;
&nbsp;
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">public</span>&nbsp;partial&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">class</span>&nbsp;MasterPage&nbsp;: System.Web.UI.MasterPage
{
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">protected</span>&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">void</span>&nbsp;Page_Load(<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">object</span>&nbsp;sender, EventArgs&nbsp;e)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">//&nbsp;Popup&nbsp;dialog&nbsp;won&#39;t&nbsp;fire&nbsp;if&nbsp;user&nbsp;is already&nbsp;in.</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">if</span>&nbsp;(Request.IsAuthenticated)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LoginStatus1_ModalPopupExtender.Enabled&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=</span>&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">false</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">else</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LoginStatus1_ModalPopupExtender.Enabled&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=</span>&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">true</span>;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">//&nbsp;Authenticate&nbsp;user&#39;s&nbsp;crendential&nbsp;if&nbsp;Login button&nbsp;is&nbsp;clicked.</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">protected</span>&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">void</span>&nbsp;Login1_Authenticate(<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">object</span> sender,&nbsp;AuthenticateEventArgs&nbsp;e)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">//&nbsp;You&nbsp;can&nbsp;add&nbsp;authentication&nbsp;logic here.</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.Authenticated&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=</span>&nbsp;((Login1.UserName&nbsp;== <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&quot;test&quot;</span>)&nbsp;&amp;&amp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Login1.Password&nbsp;== <span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&quot;test&quot;</span>));
&nbsp;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">//&nbsp;Continue&nbsp;to&nbsp;display&nbsp;the&nbsp;popup&nbsp;dialog and&nbsp;failure&nbsp;text&nbsp;if&nbsp;login&nbsp;failed.</span>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">if</span>&nbsp;(!e.Authenticated)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LoginStatus1_ModalPopupExtender.Show();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: green; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">//&nbsp;Hide&nbsp;the&nbsp;popup&nbsp;dialog&nbsp;if&nbsp;Cancel&nbsp;button&nbsp;is clicked.</span>
&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">protected</span>&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">void</span>&nbsp;btnCancel_Click(<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">object</span> sender,&nbsp;EventArgs&nbsp;e)
&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LoginStatus1_ModalPopupExtender.Hide();
&nbsp;&nbsp;&nbsp;&nbsp;}
}</span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">At last, I add a few texts and a horizontal rule to this page. Listing 5 and 6 are the login failure page and success page. It&rsquo;s done!</p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 5 &#8211; Login failure</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><img border="0" height="214" src="http://aspalliance.com/ArticleFiles/1882/image005.jpg" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " width="269" /></p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 6 &#8211; Login success</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><img border="0" height="214" id="Picture 13" src="http://aspalliance.com/ArticleFiles/1882/image006.jpg" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " width="269" /></p>
</div>
<p><span id="intellitTxt"><a class="pageTitle" id="#Page3" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">Summary</a></span></p>
<div class="backToTop" style="font-size: 11px; "><span class="Apple-style-span" style="font-size: 12px; ">In this article, you learn to create a modal popup login page. AJAX makes it easy to implement. With UpdatePanel, the page won&rsquo;t post back if login failed. By adding your own authentication logic, you can expand this demo easily to real world&nbsp;<a class="kLink" href="http://aspalliance.com/1882_How_to_Create_an__ASPNET_Modal_Popup_Login.all#" id="KonaLink5" style="color: blue !important; background-color: transparent !important; border-bottom-style: none !important; text-decoration: underline !important; cursor: pointer; font-family: verdana; border-top-width: 0px !important; border-right-width: 0px !important; border-bottom-width: 0px !important; border-left-width: 0px !important; border-top-style: none !important; border-right-style: none !important; border-left-style: none !important; border-top-color: transparent !important; border-right-color: transparent !important; border-bottom-color: transparent !important; border-left-color: transparent !important; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; text-transform: none !important; display: inline !important; font-variant: normal; top: 0px; right: 0px; bottom: 0px; left: 0px; position: static; background-position: initial initial !important; background-repeat: initial initial !important; " target="undefined"><font color="blue" style="color: blue !important; font-family: Verdana, sans-serif; font-weight: normal; font-size: 13px; position: static; "><span class="kLink" style="border-top-width: 0px !important; border-top-style: none !important; border-top-color: initial !important; border-left-width: 0px !important; border-left-style: none !important; border-left-color: initial !important; border-right-width: 0px !important; border-right-style: none !important; border-right-color: initial !important; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: initial; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 1px !important; padding-left: 0px !important; color: blue !important; background-image: none; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; width: auto !important; float: none !important; display: inline !important; font-family: Verdana, sans-serif; font-weight: normal; font-size: 13px; position: static; background-position: initial initial; background-repeat: initial initial; ">application</span></font></a>.</span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.allfreetech.com/ajax/how-to-create-an-asp-net-modal-popup-login-158.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solution to ASP.net Theme Conflict with FCKEditor</title>
		<link>http://www.allfreetech.com/microsoft-net/asp-net/solution-to-asp-net-theme-conflict-with-fckeditor-153.html</link>
		<comments>http://www.allfreetech.com/microsoft-net/asp-net/solution-to-asp-net-theme-conflict-with-fckeditor-153.html#comments</comments>
		<pubDate>Fri, 29 Jan 2010 14:01:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.allfreetech.com/?p=153</guid>
		<description><![CDATA[
According to me, FCKeditor is the coolest HTML editor. It is very popular among web developers because of its rich set of useful features. It&#39;s also compatible with ASP.NET. But it has some issues with the ASP.NET page theme. When uploading files or images through the editor, it displays an wired XML parse error stating [...]]]></description>
			<content:encoded><![CDATA[<div class="KonaBody">
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">According to me, FCKeditor is the coolest HTML editor. It is very popular among web developers because of its rich set of useful features. It&#39;s also compatible with ASP.NET. But it has some issues with the ASP.NET page theme. When uploading files or images through the editor, it displays an wired XML parse error stating that &quot;Using themed CSS files requires a header control on the page.&quot;</span></p>
</div>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><span id="intellitTxt"><a class="pageTitle" id="#Page2" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">Solution</a></span></span></p>
<div class="backToTop" style="font-size: 11px; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br />
	</span></div>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br />
	</span></p>
<div class="KonaBody">
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">What happen basically because of page theme or site theme, FCKeditor&#39;s default theme is not loaded and the editor throws parse error as because FCKeditor try to load the style attributes beside asp.net web forms theme. I have dug through the configuration files inside FCKeditor and do some R&amp;D over different forum posts and found that it&#39;s a common error while integrating with ASP.NET 2.0 web forms &nbsp;that use themes. After going through different forums and digging the source codes, I got the solution. Basically we need to make some configuration changes to be compatible with asp.net page themes at &nbsp;&quot;~/fckeditor/filemanager/connectors/aspx/config.ascx&quot; file under our webservers FCKeditor folder where all configuration files resides.</span></p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Figure 1</span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><img height="332" src="http://aspalliance.com/ArticleFiles/1908/image001.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " width="640" /></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">As you can see above, &quot;UserFilesPath&quot; is specified, we need to put Page.ResolveUrl when specifying the value, i.e. we need to put something like:</span></p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">UserFilesPath&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=</span>&nbsp;Page.ResolveUrl(<span style="color: rgb(102, 102, 102); background-color: rgb(228, 228, 228); font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&quot;~/userfiles/&quot;</span>);</span></span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">In this case, my default user files upload folder is &quot;userfiles&quot; under web servers root directory.</span></p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Figure 2</span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><img height="796" src="http://aspalliance.com/ArticleFiles/1908/image002.gif" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " width="289" /></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Another point is that we don&#39;t need ASP.NET themes within the fckeditor folder, so simply add a web.config file in the folder as shown in the above screenshot, with the following content:</span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">&nbsp;</span></p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; "><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">configuration</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">appSettings</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">/&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">connectionStrings</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">/&gt;</span>
&lt;system.web&gt;
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">pages</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">styleSheetTheme</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;&quot;</span> <span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">theme</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;&quot;</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>&nbsp;<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;/</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">pages</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
&lt;/system.web&gt;
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;/</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">configuration</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span></span></span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">For these lines the default style of FCKeditor will be loaded. It will disable the page theme inside FCKeditor&#39;s configuration folder and no page-specific or site-specific theme will be available. Hope this will help developers and prevent them from wasting their time just to find out this silly solution.</span></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.allfreetech.com/microsoft-net/asp-net/solution-to-asp-net-theme-conflict-with-fckeditor-153.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Client Centric Approach of AJAX using Toolkit</title>
		<link>http://www.allfreetech.com/ajax/client-centric-approach-of-ajax-using-toolkit-151.html</link>
		<comments>http://www.allfreetech.com/ajax/client-centric-approach-of-ajax-using-toolkit-151.html#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:58:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ASP]]></category>

		<guid isPermaLink="false">http://www.allfreetech.com/?p=151</guid>
		<description><![CDATA[In this article, the author discusses the client-centric approach for AJAX using the ASP.NET AJAX Toolkit. In general, server-centric (use of Update panel) is very popular in this field. But when it comes to performance, the client-centric approach is preferred. Sandeep also demonstrates how to call a webservice using javascript.
&#160;



Introduction



&#160;
Today everything is changing very rapidly [...]]]></description>
			<content:encoded><![CDATA[<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">In this article, the author discusses the client-centric approach for AJAX using the ASP.NET AJAX Toolkit. In general, server-centric (use of Update panel) is very popular in this field. But when it comes to performance, the client-centric approach is preferred. Sandeep also demonstrates how to call a webservice using javascript.<span id="more-151"></span></span></p>
<p>&nbsp;</p>
<table class="articleViewer" style="width: 670px; position: relative; top: -21px; ">
<tbody>
<tr>
<td class="subtitle" colspan="2" style="text-align: left; vertical-align: top; color: rgb(204, 0, 0); font-size: 11px; font-weight: bolder; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 13px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><span id="intellitTxt"><a class="pageTitle" id="#Page1" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">Introduction</a></span></span></td>
</tr>
<tr>
<td class="content" colspan="2" style="text-align: left; vertical-align: top; ">
<div class="backToTop" style="font-size: 11px; ">&nbsp;</div>
<div class="backToTop" style="font-size: 11px; "><span class="Apple-style-span" style="font-size: 13px; ">Today everything is changing very rapidly and technology is of no exception. Traditional web page with boring look and feel has gone obsolete. In that rhythm requirements are also changing. Among all these changes AJAX has become very popular now a days. And why not, it is so attractive and beautiful that everybody would love to have it on their web pages. It saves time for end user, saves resources for server and after all gives a new look and new experience for web browsing.</span></div>
</td>
</tr>
<tr>
<td class="subtitle" colspan="2" style="text-align: left; vertical-align: top; color: rgb(204, 0, 0); font-size: 11px; font-weight: bolder; "><span id="intellitTxt"><a class="pageTitle" id="#Page2" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">System Requirements</a></span></td>
</tr>
<tr>
<td class="content" colspan="2" style="text-align: left; vertical-align: top; ">
<div class="backToTop" style="font-size: 11px; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 13px;"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 11px;"><br />
					</span></font></span></font></div>
<div class="KonaBody">
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>Microsoft Windows XP Professional</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>VS 2005</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>AJAXToolkit 1.0</p>
</p></div>
</td>
</tr>
<tr>
<td class="subtitle" colspan="2" style="text-align: left; vertical-align: top; color: rgb(204, 0, 0); font-size: 11px; font-weight: bolder; "><span id="intellitTxt"><a class="pageTitle" id="#Page3" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">Server Centric Vs Client Centric</a></span></td>
</tr>
<tr>
<td class="content" colspan="2" style="text-align: left; vertical-align: top; ">
<div class="backToTop" style="font-size: 11px; ">&nbsp;</div>
<p></p>
<div class="KonaBody">
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">Server Centric</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; text-align: justify; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; There are two ways of AJAX that can be implemented using AJAXToolkit. One is the most popular method, Server Centric (using Update panel) and another one is Client Centric. There are several reasons (given below) why the server centric became so much popular.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>Server centric takes very less time to implement.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>From a developer point of view, it is very easy to implement. Just put your controls inside an UpdatePanel and ScriptManager will do rest of the job.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>It keeps the developer free from JavaScript and developer can concentrate only on server side.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>Requires less effort.</p>
<p class="MsoBodyTextIndent">But everything in this world comes with a cost. There are also several drawbacks that come along with this approach.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>Though it does not show but internally it completes the whole page life cycle once again, which actually violates the basics of AJAX. But for an end user it never matters.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>As it completes the total page life cycle again and hence for better performance client centric is having an edge.</p>
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">Client Centric</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>This is the most preferred approach for better performance.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>It is completely in adherence to the rules of AJAX.</p>
<p class="MsoListBullet" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-indent: -0.25in; font-size: 10pt; font-family: Verdana; "><span style="font-family: Symbol; ">&middot;<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>Though its time taking to implement, but its worthy to spent time on it.</p>
</p></div>
</td>
</tr>
<tr>
<td class="subtitle" colspan="2" style="text-align: left; vertical-align: top; color: rgb(204, 0, 0); font-size: 11px; font-weight: bolder; "><span id="intellitTxt"><a class="pageTitle" id="#Page4" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">How to accomplish Client Centric &ndash; Example</a></span></td>
</tr>
<tr>
<td class="content" colspan="2" style="text-align: left; vertical-align: top; ">
<div class="backToTop" style="font-size: 11px; ">&nbsp;</div>
<p></p>
<div class="KonaBody">
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">Lets move step by step to get a complete hold on this.</p>
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">Create an AJAX enabled website</p>
<p class="MsoBodyText">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create an AJAX Enabled web site for this example. Ajax enabled website is same as normal .net website but having few more additional tags in web.config.</p>
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">Add Webservice and Javascript</p>
<p class="MsoBodyText">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Add a webservice (MyService.asmx) to the project. Also add a JS file (Jscript.js) to do the client side activities. Basically we are going to call the Webmethods present in the websevice through java script.</p>
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">Add ScriptManager</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Add a ScriptManager to the MasterPage with tags as shown below.</p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 1</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; "><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">asp:ScriptManager</span> <span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">ID</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;ScriptManager1&quot;</span>&nbsp;<span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">runat</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;server&quot;</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">Scripts</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">asp:ScriptReference</span> <span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">Path</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;JScript.js&quot;</span> <span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">/&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;/</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">Scripts</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">Services</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">asp:ServiceReference</span> <span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">Path</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;MyService.asmx&quot;</span> <span style="color: red; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">InlineScript</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">=&quot;true&quot;</span> <span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">/&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;/</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">Services</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span>
<span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&lt;/</span><span style="color: maroon; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">asp:ScriptManager</span><span style="color: blue; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">&gt;</span></span></pre>
</div>
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">Do necessary changes to the webservice</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; text-align: justify; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; You need to add the&nbsp;<span style="font-family: 'Microsoft Sans Serif', sans-serif; color: teal; ">ScriptService&nbsp;</span>attribute to the webservice class. Then add your own webmethod. Here we have added a GetServerTime() method.</p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 2</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">[WebMethod]
public&nbsp;string&nbsp;GetServerTime()
{
&nbsp;&nbsp;&nbsp;&nbsp;return DateTime.Now.ToString();
}</span></pre>
</div>
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">Test the Webservice, see if it generates the client proxy</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; text-align: justify; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; After this you should be able to test whether your webservice is ready to receive calls from the javascript. Basically the webservice URL followed with &ldquo;/js&rdquo; or &ldquo;/jsdebug&rdquo; will allow you to download the resulting client proxy. This is possible because of the presence of Scriptservice Attribute for Webservice class.</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; text-align: justify; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; text-align: justify; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If you will save and open this file, you will find that there will be necessary client proxy entry for each of the webmethods present in webservice.</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; text-align: justify; ">The following prompt ensures that the webservice is correct and ready to use.</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">&nbsp;</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><b><u>Figure 1</u></b></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><img height="356" src="http://aspalliance.com/ArticleFiles/1909/image001.jpg" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " width="662" /></p>
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">Get the result by running the application</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; After this, create a button and run the following javascript function on the button click.</p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 3</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">//&nbsp;JScript&nbsp;File
function&nbsp;GetTime()
{
&nbsp;&nbsp;&nbsp; MyService.GetServerTime(onSuccess,onFailed);
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;false;
}</span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Here onSuccess and onFailed are the name of the functions (similar to delegates) that will be executed eventually at the success and failure of the AJAX Call. The definitions of them are given below.</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">&nbsp;</p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 4</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">function&nbsp;onSuccess(result)
{
&nbsp;&nbsp;&nbsp;&nbsp;alert(&quot;Current&nbsp;time&nbsp;is:&nbsp;&quot;&nbsp;+ result);
}</span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">&nbsp;</p>
<p class="CodeListingHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; font-weight: bold; text-decoration: underline; ">Listing 5</p>
<div class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">
<pre><span style="color: black; background-color: transparent; font-family: 'Courier New'; font-size: 11px; font-weight: normal; ">function&nbsp;onFailed(result)
{
&nbsp;&nbsp;&nbsp;&nbsp;alert(&quot;Error&nbsp;[&quot;&nbsp;+ result._statusCode&nbsp;+&nbsp;&quot;]&nbsp;:&nbsp;&quot;&nbsp;+&nbsp;result._message);
}</span></pre>
</div>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">&nbsp;</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">Finally it will look like this:</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; "><img height="244" src="http://aspalliance.com/ArticleFiles/1909/image002.jpg" style="border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " width="392" /></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">&nbsp;</p>
</p></div>
</td>
</tr>
<tr>
<td class="subtitle" colspan="2" style="text-align: left; vertical-align: top; color: rgb(204, 0, 0); font-size: 11px; font-weight: bolder; "><span id="intellitTxt"><a class="pageTitle" id="#Page5" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">Similarities with PageMethods</a></span></td>
</tr>
<tr>
<td class="content" colspan="2" style="text-align: left; vertical-align: top; ">
<div class="backToTop" style="font-size: 11px; ">&nbsp;</div>
<p></p>
<div class="KonaBody">
<p class="MsoBodyText">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This is almost similar to the PageMethods concept. In PageMethods there is no need to create a web service for AJAX functionality. Rather your javascript can directly call a method (should be marked as [WebMethod]) present on the code behind file of a .aspx page.</p>
</p></div>
</td>
</tr>
<tr>
<td class="subtitle" colspan="2" style="text-align: left; vertical-align: top; color: rgb(204, 0, 0); font-size: 11px; font-weight: bolder; "><span id="intellitTxt"><a class="pageTitle" id="#Page6" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">Differences with IcallbackEventHandler</a></span></td>
</tr>
<tr>
<td class="content" colspan="2" style="text-align: left; vertical-align: top; ">
<div class="backToTop" style="font-size: 11px; ">&nbsp;</div>
<p></p>
<div class="KonaBody">
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; text-align: justify; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; It can be said that Client centric approach might have evolved from the<span style="font-family: 'Courier New'; ">ICallbackEventHandler</span>, but actually it is much ahead of&nbsp;<span style="font-family: 'Courier New'; ">ICallbackEventHandler.</span>&nbsp;Few differences are given below:</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-align: justify; text-indent: -0.25in; "><b>1.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span></b>In ICallbackEventHandler, only string types can be supplied to the server as argument. And only string types can be received from server. But in client centric approach&nbsp;<b>the parameter types and number of parameters are of no constraint</b>.&nbsp;<b>One can supply n number of parameters to the server and these can be of anytype.</b></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-align: justify; text-indent: -0.25in; ">2.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span>ICallbackEventHandler was never Jserialisable. But through this newer approach Jserialization is possible.&nbsp;<b>As a result of which a server can return a datatable, dataset and your Javascript is now capable enough to receive them</b>. (Yes, it was never ever possible in ICallbackEventHandler).</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0.25in; text-align: justify; text-indent: -0.25in; ">3.<span style="font: normal normal normal 7pt/normal 'Times New Roman'; ">&nbsp;&nbsp;&nbsp;&nbsp;</span>One more magic, now using Jserialization of Client Centric,&nbsp;<b>you can create objects of your server side classes at client side</b>. It may not sound so interesting, but if you start thinking, it was also never possible to create an instance of a class in your javascript. But now this is also very much possible.</p>
</p></div>
</td>
</tr>
<tr>
<td class="subtitle" colspan="2" style="text-align: left; vertical-align: top; color: rgb(204, 0, 0); font-size: 11px; font-weight: bolder; "><span id="intellitTxt"><a class="pageTitle" id="#Page7" style="color: rgb(204, 0, 0); font-size: medium; font-weight: bolder; ">Conclusion</a></span></td>
</tr>
<tr>
<td class="content" colspan="2" style="text-align: left; vertical-align: top; ">
<div class="backToTop" style="font-size: 11px; "><span class="Apple-style-span" style="font-size: 13px; ">By now one must have realized that why AJAX is so popular and why client centric approach is advisable. It brought a new era to the world of AJAX. AJAX programming has never been so interesting till date. I remember few years back in the age of manual AJAX, developers used to have a headache for such things, which is now very much doable in seconds using Client Centric approach of AJAX Toolkit. And think of the widely opened possibilities. Yes, we all have to agree that the new era of web development has stepped in and a long way to go.</span></div>
<div class="KonaBody">
<p class="SectionHeading" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; font-size: 10pt; font-family: Verdana, sans-serif; color: rgb(206, 0, 0); font-weight: bold; ">Download</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 6pt; margin-left: 0in; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Link:&nbsp;<a href="http://authors.aspalliance.com/Sacharya/AJAXEnabledWebSite1.zip" style="color: rgb(144, 11, 9); background-color: transparent; ">http://authors.aspalliance.com/Sacharya/AJAXEnabledWebSite1.zip</a></p>
</p></div>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.allfreetech.com/ajax/client-centric-approach-of-ajax-using-toolkit-151.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Routing with ASP.NET Web Forms</title>
		<link>http://www.allfreetech.com/microsoft-net/asp-net/routing-with-asp-net-web-forms-149.html</link>
		<comments>http://www.allfreetech.com/microsoft-net/asp-net/routing-with-asp-net-web-forms-149.html#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:52:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://www.allfreetech.com/?p=149</guid>
		<description><![CDATA[&#160;
Service Pack 1 for the Microsoft .NET Framework 3.5 introduced a routing engine to the ASP.NET runtime. The routing engine can decouple the URL in an incoming HTTP request from the physical Web Form that responds to the request, allowing you to build friendly URLs for your Web applications. Although you&#39;ve been able to use [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<div class="ArticleNormalPara" id="id0070001" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">Service Pack 1 for the Microsoft .NET Framework 3.5 introduced a routing engine to the ASP.NET runtime. The routing engine can decouple the URL in an incoming HTTP request from the physical Web Form that responds to the request, allowing you to build friendly URLs for your Web applications. Although you&#39;ve been able to use friendly URLs in previous versions of ASP.NET, the routing engine provides an easier, cleaner, and more testable approach.<span id="more-149"></span></span></div>
<div class="ArticleNormalPara" id="id0070002" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">The routing engine began as a part of the ASP.NET Model View Controller (MVC) framework, which is in a preview stage as of this writing. However, Microsoft packaged the routing logic into the System.Web.Routing assembly and released the assembly with SP1. The assembly currently provides routing for Web sites using ASP.NET Dynamic Data features (which were also released with SP1), but in this column I will demonstrate how to use the routing functionality with ASP.NET Web Forms.</span></div>
<p><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; "><br />
	</span></p>
<div class="ArticleTypeTitle" id="id0070003" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: normal; font-family: 'Segoe UI', Arial; margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 16px; font-variant: normal; text-transform: none; color: rgb(38, 8, 89); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">What Is Routing?</span></div>
<div class="ArticleNormalPara" id="id0070004" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">Imagine you have an ASP.NET Web Form named RecipeDisplay.aspx, and this form lives inside a folder named Web Forms. The classic approach to viewing a recipe with this Web Form is to build a URL pointing to the physical location of the form and encode some data into the query string to tell the Web Form which recipe to display. The end of such a URL might look like the following: /WebForms/RecipeDisplay.aspx?id=5, where the number 5 represents a primary key value in a database table full of recipes.</span></div>
<div class="ArticleNormalPara" id="id0070005" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">Routing is fundamentally about decomposing a URL endpoint into parameters and then using those parameters to steer the HTTP request processing to a specific component. Let&#39;s take the URL /recipe/5 as an example. With the proper routing configuration, you can still respond to this URL with the Web Form RecipeDisplay.aspx.</span></div>
<div class="ArticleNormalPara" id="id0070006" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">The URL no longer represents a physical path. Instead, the word recipe represents a parameter that the routing engine can use to locate a component for processing recipe requests. The number 5 represents a second parameter that you&#39;ll need during processing to display a specific recipe. Instead of encoding database keys into the URL, a better idea might be to use a URL like /recipe/tacos. This URL not only includes enough parameters to display a specific recipe, but is also human readable, reveals its intent to end users, and includes important keywords for search engines to see.</span></div>
<p><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; "><br />
	</span></p>
<div class="ArticleTypeTitle" id="id0070007" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: normal; font-family: 'Segoe UI', Arial; margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 16px; font-variant: normal; text-transform: none; color: rgb(38, 8, 89); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">A Brief History of URL Rewriting</span></div>
<div class="ArticleNormalPara" id="id0070008" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">In ASP.NET, using a URL ending with /recipe/tacos traditionally required one to work with a URL rewriting scheme. For detailed information on URL rewriting, see Scott Mitchell&#39;s definitive article &quot;<a href="http://msdn.microsoft.com/library/ms972974" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: rgb(0, 102, 221); cursor: pointer; text-decoration: none; ">URL Rewriting in ASP.NET</a>.&quot; The article describes the common implementation of URL rewriting in ASP.NET using an HTTP module and the static RewritePath method of the HttpContext class. Scott&#39;s article also details the benefits of friendly, hackable URLs.</span></div>
<div class="ArticleNormalPara" id="id0070009" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">Those of you who have used the RewritePath API in the past are probably familiar with some of the quirks and weaknesses in the rewriting approach. The primary problem with RewritePath is how the method changes the virtual path used during the processing of a request. With URL rewriting, you needed to fix up the postback destination of each Web Form (often by rewriting the URL a second time during the request) to avoid postbacks to the internal, rewritten URL.</span></div>
<div class="ArticleNormalPara" id="id0070010" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">In addition, most developers would implement URL rewriting as a one-way translation because there was no easy mechanism to let the URL rewriting logic work in two directions. For example, it was easy to give the URL rewriting logic a public-facing URL and have the logic return the internal URL of a Web Form. It was difficult to give the rewriting logic the internal URL of a Web Form and have it return the public URL required to reach the form. The latter is useful when generating hyperlinks to other Web Forms that hide behind rewritten URLs. As you&#39;ll see in the rest of this column, the URL routing engine circumvents these problems.</span></div>
<div class="imgleft1" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: inherit; font-family: 'Segoe UI', Arial; margin-top: 5px; margin-right: 10px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: left; width: 504px; font-size: 14px; color: rgb(0, 51, 153); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; "><img alt="" src="http://i.msdn.microsoft.com/dd347546.fig01_L(en-us).gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /></span></p>
<div class="ArticleImageCaptionText" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: inherit; font-family: 'Segoe UI', Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 7px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; font-size: 14px; color: rgb(38, 37, 42); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">Figure 1&nbsp;<strong style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Routes, Route Handlers, and the Routing Module</strong></span></div>
</div>
<div class="ArticleTypeTitle" id="id0070011" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: normal; font-family: 'Segoe UI', Arial; margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 16px; font-variant: normal; text-transform: none; color: rgb(38, 8, 89); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">Of Routes and Route Handlers</span></div>
<div class="ArticleNormalPara" id="id0070012" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">There are three fundamental players in the URL routing engine: routes, route handlers, and the routing module. A route associates a URL with a route handler. An instance of the Route class from the System.Web.Routing namespace represents a route during run time and describes the route&#39;s parameters and constraints. A route handler inherits from the System.Web.Routing.IRouteHandler interface. This interface requires the route handler to implement a GetHttpHandler method that returns an object implementing the IHttpHandler interface. The IHttpHandler interface has been a part of ASP.NET since the beginning, and a Web Form (a System.Web.UI.Page) is an IHttpHandler. When using routing with Web Forms, your route handlers need to locate, instantiate, and return the proper Web Form. Finally, the routing module plugs into the ASP.NET processing pipeline. The module will intercept incoming requests, examine the URL, and discover if there are any matching routes defined. The module will retrieve the associated route handler for a matching route and ask the routing handler for the IHttpHandler that will process the request.</span></div>
<div class="ArticleNormalPara" id="id0070013" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">The three primary types I&#39;ve mentioned are shown in&nbsp;<strong style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Figure 1</strong>. In the next section, I&#39;ll put these three players to work.</span></div>
<p><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; "><br />
	</span></p>
<div class="ArticleTypeTitle" id="id0070014" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: normal; font-family: 'Segoe UI', Arial; margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 16px; font-variant: normal; text-transform: none; color: rgb(38, 8, 89); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">Configuring ASP.NET for Routing</span></div>
<div class="ArticleNormalPara" id="id0070015" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">To configure an ASP.NET Web site or Web application for routing, you first need to add a reference to the System.Web.Routing assembly. The SP1 installation for the .NET Framework 3.5 will install this assembly into the global assembly cache, and you can find the assembly inside the standard &quot;Add Reference&quot; dialog box.</span></div>
<div class="ArticleNormalPara" id="id0070016" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; ">You&#39;ll also need to configure the routing module into the ASP.NET pipeline. The routing module is a standard HTTP module. For IIS 6.0 and earlier and for the Visual Studio Web development server, you install the module using the &lt;httpModules&gt; section of web.config, as you see here:</span></div>
<div class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl05_" style="border-top-width: 5px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 20px; padding-left: 0px; width: 614px; border-top-color: rgb(255, 255, 255); border-top-style: solid; display: block; ">
<div class="CodeSnippetTitleBar" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-color: rgb(221, 221, 221); white-space: nowrap; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); height: 15px; word-spacing: normal; letter-spacing: normal; ">
<div class="CodeDisplayLanguage" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: left; text-align: left; ">&nbsp;</div>
</p></div>
<div dir="ltr" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-color: rgb(221, 221, 221); ">
<pre class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl05_code" space="preserve" style="border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: Courier, Verdana, Arial, Helvetica, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 5px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); border-top-color: rgb(200, 205, 222); border-top-style: solid; display: block; color: rgb(0, 0, 102); white-space: pre-wrap; word-wrap: break-word; overflow-x: hidden; overflow-y: hidden; background-position: initial initial; background-repeat: initial initial; "><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: Verdana; line-height: 15px; "><span id="ctl00_MTContentSelector1_mainContentContainer_ctl05" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " xmlns:msxsl="urn:schemas-microsoft-com:xslt">&lt;httpModules&gt;
    &lt;add name=&quot;RoutingModule&quot;
         type=&quot;System.Web.Routing.UrlRoutingModule,
               System.Web.Routing,
               Version=3.5.0.0, Culture=neutral,
               PublicKeyToken=31bf3856ad364e35&quot;/&gt;

    &lt;!-- ... --&gt;

&lt;/httpModules&gt;
</span></span></pre>
</div>
</div>
<div class="ArticleNormalPara" id="id0070027" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">To run a Web site with routing in IIS 7.0, you need two entries in web.config. The first entry is the URL routing module configuration, which is found in the &lt;modules&gt; section of &lt;system.webServer&gt;. You also need an entry to handle requests for UrlRouting.axd in the &lt;handlers&gt; section of &lt;system.webServer&gt;. Both of these entries are shown in&nbsp;<strong style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Figure 2</strong>. Also, see the sidebar &quot;IIS 7.0 Configuration Entries.&quot;</div>
<div class="figmargin" id="id017" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div class="MTPS_CollapsibleRegion" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div class="CollapseRegionLink" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; cursor: pointer; color: rgb(0, 0, 0); text-decoration: none; "><span style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><img class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; background-image: url(http://i3.msdn.microsoft.com/global/Images/LibC.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 16px; height: 16px; vertical-align: middle; background-position: 0px 0px; background-repeat: initial initial; " />&nbsp;&nbsp;Figure 2 URL Routing Module Configuration</span></div>
<div class="MTPS_CollapsibleSection" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 10px; clear: both; display: block; ">
<div class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl21_ctl00_ctl00_" style="border-top-width: 5px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 20px; padding-left: 0px; width: 604px; border-top-color: rgb(255, 255, 255); border-top-style: solid; display: block; ">
<div class="CodeSnippetTitleBar" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-color: rgb(221, 221, 221); white-space: nowrap; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); height: 15px; word-spacing: normal; letter-spacing: normal; ">
<div class="CodeDisplayLanguage" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: left; text-align: left; ">&nbsp;</div>
</p></div>
<div dir="ltr" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-color: rgb(221, 221, 221); ">
<pre class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl21_ctl00_ctl00_code" space="preserve" style="border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: Courier, Verdana, Arial, Helvetica, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 5px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); border-top-color: rgb(200, 205, 222); border-top-style: solid; display: block; color: rgb(0, 0, 102); white-space: pre-wrap; word-wrap: break-word; overflow-x: hidden; overflow-y: hidden; background-position: initial initial; background-repeat: initial initial; "><span style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span id="ctl00_MTContentSelector1_mainContentContainer_ctl21_ctl00_ctl00" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " xmlns:msxsl="urn:schemas-microsoft-com:xslt">&lt;system.webServer&gt;
   &lt;modules runAllManagedModulesForAllRequests=&quot;true&quot;&gt;

      &lt;add name=&quot;UrlRoutingModule&quot;
             type=&quot;System.Web.Routing.UrlRoutingModule,
                   System.Web.Routing, Version=3.5.0.0,
                   Culture=neutral,
                   PublicKeyToken=31BF3856AD364E35&quot; /&gt;
      &lt;!-- ... --&gt;

    &lt;/modules&gt;
    &lt;handlers&gt;

      &lt;add name=&quot;UrlRoutingHandler&quot;
            preCondition=&quot;integratedMode&quot;
            verb=&quot;*&quot; path=&quot;UrlRouting.axd&quot;
            type=&quot;System.Web.HttpForbiddenHandler,
                  System.Web, Version=2.0.0.0, Culture=neutral,
                  PublicKeyToken=b03f5f7f11d50a3a&quot; /&gt;
      &lt;!-- ... --&gt;

    &lt;/handlers&gt;
&lt;/system.webServer&gt;
</span></span></pre>
</div></div>
</p></div>
</p></div>
</div>
<div class="ArticleNormalPara" id="id0070028" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">Once you&#39;ve configured the URL routing module into the pipeline, it will wire itself to the PostResolveRequestCache and the PostMapRequestHandler events.&nbsp;<strong style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Figure 3</strong>&nbsp;shows a subset of the pipeline events. URL rewriting implementations typically perform their work during the BeginRequest event, which is the earliest event to fire during a request. With URL routing, the route matching and selection of a route handler occurs during the PostResolveRequestCache stage, which is after the authentication, authorization, and cache lookup stages of processing. I will need to revisit the implications of this event timing later in the column.</div>
<div class="imgright3" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: inherit; font-family: 'Segoe UI', Arial; margin-top: 5px; margin-right: 0px; margin-bottom: 10px; margin-left: 15px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: right; width: 225px; font-size: 14px; color: rgb(0, 51, 153); "><img alt="" src="http://i.msdn.microsoft.com/dd347546.fig03a(en-us).gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /></p>
<div class="ArticleImageCaptionText" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: inherit; font-family: 'Segoe UI', Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 7px; padding-right: 0px; padding-bottom: 10px; padding-left: 0px; font-size: 14px; color: rgb(38, 37, 42); ">Figure 3&nbsp;<strong style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">HTTP Request</strong></div>
</div>
<p>&nbsp;</p>
<div class="ArticleTypeTitle" id="id0070029" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: normal; font-family: 'Segoe UI', Arial; margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 16px; font-variant: normal; text-transform: none; color: rgb(38, 8, 89); ">Configuring Routes</div>
<div class="ArticleNormalPara" id="id0070030" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">Routes and route handlers go hand in hand, but I&#39;ll look at the code to configure routes first. The routing engine&#39;s RouteTable class exposes a RouteCollection via its static Routes property. You need to configure all of your custom routes into this collection before the application begins to execute the first request, which means you need to use a global.asax file and the Application_Start event.</div>
<div class="ArticleNormalPara" id="id0070031" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); "><strong style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Figure 4&nbsp;</strong>shows the route registration code you need to use for &quot;/recipe/brownies&quot; to reach the RecipeDisplay.aspx Web Form. The parameters for the Add method on the RouteCollection class include a friendly name for the route, followed by the route itself. The first parameter to the Route constructor is a URL pattern. The pattern consists of the URL segments that will appear at the end of a URL pointing to this application (after any segments required to reach the application&#39;s root). For an application rooted at localhost/food/ then, the route pattern in&nbsp;<strong style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Figure 4</strong>&nbsp;will match localhost/food/recipe/brownies.</div>
<div class="figmargin" id="id020" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div class="MTPS_CollapsibleRegion" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div class="CollapseRegionLink" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; cursor: pointer; color: rgb(0, 0, 0); text-decoration: none; "><span style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><img class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; background-image: url(http://i3.msdn.microsoft.com/global/Images/LibC.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 16px; height: 16px; vertical-align: middle; background-position: 0px 0px; background-repeat: initial initial; " />&nbsp;&nbsp;Figure 4 Route Registration Code for /recipe/brownies</span></div>
<div class="MTPS_CollapsibleSection" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 10px; clear: both; display: block; ">
<div class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl22_ctl00_ctl00_" style="border-top-width: 5px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 20px; padding-left: 0px; width: 604px; border-top-color: rgb(255, 255, 255); border-top-style: solid; display: block; ">
<div class="CodeSnippetTitleBar" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-color: rgb(221, 221, 221); white-space: nowrap; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); height: 15px; word-spacing: normal; letter-spacing: normal; ">
<div class="CodeDisplayLanguage" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: left; text-align: left; ">&nbsp;</div>
</p></div>
<div dir="ltr" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-color: rgb(221, 221, 221); ">
<pre class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl22_ctl00_ctl00_code" space="preserve" style="border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: Courier, Verdana, Arial, Helvetica, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 5px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); border-top-color: rgb(200, 205, 222); border-top-style: solid; display: block; color: rgb(0, 0, 102); white-space: pre-wrap; word-wrap: break-word; overflow-x: hidden; overflow-y: hidden; background-position: initial initial; background-repeat: initial initial; "><span style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span id="ctl00_MTContentSelector1_mainContentContainer_ctl22_ctl00_ctl00" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " xmlns:msxsl="urn:schemas-microsoft-com:xslt">protected void Application_Start(object sender, EventArgs e)
{
    RegisterRoutes();
}

private static void RegisterRoutes()
{
    RouteTable.Routes.Add(
        &quot;Recipe&quot;,
        new Route(&quot;recipe/{name}&quot;,
                  new RecipeRouteHandler(
                      &quot;~/WebForms/RecipeDisplay.aspx&quot;)));
}
</span></span></pre>
</div></div>
</p></div>
</p></div>
</div>
<div class="SidebarContainer" id="id011" style="border-top-width: 12px; border-right-width: 0px; border-bottom-width: 12px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 20px; margin-right: 0px; margin-bottom: 20px; margin-left: 10px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 10px; padding-right: 50px; padding-bottom: 10px; padding-left: 10px; color: rgb(38, 8, 89); border-bottom-style: solid; border-bottom-color: rgb(38, 8, 89); border-top-style: solid; border-top-color: rgb(38, 8, 89); ">
<div class="SidebarHeadline" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: 'Segoe UI', Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 18px; line-height: 20px; color: rgb(38, 8, 89); ">IIS 7.0 Configuration Entries</div>
<p></p>
<div id="id014" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The runAllManagedModulesForAllRequests attribute requires a value of true if you want to use the extensionless URLs as I&#39;ve done in this sample. Also, it might seem strange to configure an HTTP handler for UrlRouting.axd. This is a small workaround that the routing engine requires in order for routing to work under IIS 7.0. The UrlRouting module actually rewrites the incoming URL to ~/UrlRouting.axd, which will rewrite the URL back to the original, incoming URL. It&#39;s likely that a future version of IIS will integrate perfectly with the routing engine and not require this workaround.</div>
</div>
<div class="ArticleNormalPara" id="id0070032" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">Segments enclosed inside curly braces denote parameters, and the routing engine will automatically extract the values there and place them into a name/value dictionary that will exist for the duration of the request. Using the previous example of localhost/food/recipe/brownies, the routing engine will extract the value &quot;brownies&quot; and store the value in the dictionary with a key of &quot;name&quot;. You&#39;ll see how to use the dictionary when I look at the code for the route handler.</div>
<div class="ArticleNormalPara" id="id0070033" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">You can add as many routes as you need into the RouteTable, but the ordering of the routes is important. The routing engine will test all incoming URLs against the routes in the collection in the order in which they appear, and the engine will select the first route with a matching pattern. For this reason, you should add the most specific routes first. If you added a generic route with the URL pattern &quot;{category}/{subcategory}&quot; before the recipe route, the routing engine would never find the recipe route. One additional note&mdash;the routing engine performs the pattern matching in a case-insensitive manner.</div>
<div class="ArticleNormalPara" id="id0070034" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">Overloaded versions of the Route constructor allow you to create default parameter values and apply constraints. Defaults allow you to specify default values for the routing engine to place into the name/value parameter dictionary when no value exists for the parameter in an incoming URL. For example, you could make &quot;brownies&quot; the default recipe name when the routing engine sees a recipe URL without a name value (like localhost/food/recipe).</div>
<div class="ArticleNormalPara" id="id0070035" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">Constraints allow you to specify regular expressions to validate parameters and fine-tune the route pattern matching on incoming URLs. If you were using primary key values to identify recipes in a URL (like localhost/food/recipe/5), you could use a regular expression to ensure the primary key value in the URL is an integer. You can also apply constraints using an object that implements the IRouteConstraint interface.</div>
<div class="ArticleNormalPara" id="id0070036" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">The second parameter to the Route constructor is a new instance of my route handler, which I&#39;ll look at in&nbsp;<strong style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Figure 5</strong>.</div>
<div class="figmargin" id="id022" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div class="MTPS_CollapsibleRegion" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 5px; margin-right: 0px; margin-bottom: 5px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div class="CollapseRegionLink" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 12px; cursor: pointer; color: rgb(0, 0, 0); text-decoration: none; "><span style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><img class="LibC_o" src="http://i.msdn.microsoft.com/Global/Images/clear.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; background-image: url(http://i3.msdn.microsoft.com/global/Images/LibC.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; width: 16px; height: 16px; vertical-align: middle; background-position: 0px 0px; background-repeat: initial initial; " />&nbsp;&nbsp;Figure 5 RecipeRouteHandler</span></div>
<div class="MTPS_CollapsibleSection" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 10px; clear: both; display: block; ">
<div class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl23_ctl00_ctl00_" style="border-top-width: 5px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 20px; padding-left: 0px; width: 604px; border-top-color: rgb(255, 255, 255); border-top-style: solid; display: block; ">
<div class="CodeSnippetTitleBar" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-color: rgb(221, 221, 221); white-space: nowrap; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); height: 15px; word-spacing: normal; letter-spacing: normal; ">
<div class="CodeDisplayLanguage" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: left; text-align: left; ">&nbsp;</div>
</p></div>
<div dir="ltr" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-color: rgb(221, 221, 221); ">
<pre class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl23_ctl00_ctl00_code" space="preserve" style="border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: Courier, Verdana, Arial, Helvetica, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 5px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); border-top-color: rgb(200, 205, 222); border-top-style: solid; display: block; color: rgb(0, 0, 102); white-space: pre-wrap; word-wrap: break-word; overflow-x: hidden; overflow-y: hidden; background-position: initial initial; background-repeat: initial initial; "><span style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><span id="ctl00_MTContentSelector1_mainContentContainer_ctl23_ctl00_ctl00" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " xmlns:msxsl="urn:schemas-microsoft-com:xslt">public class RecipeRouteHandler : IRouteHandler
 {
     public RecipeRouteHandler(string virtualPath)
     {
         _virtualPath = virtualPath;
     }

     public IHttpHandler GetHttpHandler(RequestContext requestContext)
     {
         var display = BuildManager.CreateInstanceFromVirtualPath(
                         _virtualPath, typeof(Page)) as IRecipeDisplay;

         display.RecipeName = requestContext.RouteData.Values[&quot;name&quot;] as string;
         return display;
     }

     string _virtualPath;
 }
</span></span></pre>
</div></div>
</p></div>
</p></div>
</div>
<p>&nbsp;</p>
<div class="ArticleTypeTitle" id="id0070037" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: normal; font-family: 'Segoe UI', Arial; margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 16px; font-variant: normal; text-transform: none; color: rgb(38, 8, 89); ">The Recipe Routing Handler</div>
<div class="ArticleNormalPara" id="id0070038" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">The following code snippet shows a basic implementation of a route handler for recipe requests. Since the route handler ultimately has to create an instance of an IHttpHandler (in this case, RecipeDisplay.aspx), the constructor requires a virtual path that points to the Web Form the route handler will create. The GetHttpHandler method passes this virtual path to the ASP.NET BuildManager in order to retrieve the instantiated Web Form:</div>
<div class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl13_" style="border-top-width: 5px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 20px; padding-left: 0px; width: 614px; border-top-color: rgb(255, 255, 255); border-top-style: solid; display: block; ">
<div class="CodeSnippetTitleBar" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-color: rgb(221, 221, 221); white-space: nowrap; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); height: 15px; word-spacing: normal; letter-spacing: normal; ">
<div class="CodeDisplayLanguage" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: left; text-align: left; ">&nbsp;</div>
</p></div>
<div dir="ltr" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-color: rgb(221, 221, 221); ">
<pre class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl13_code" space="preserve" style="border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: Courier, Verdana, Arial, Helvetica, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 5px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); border-top-color: rgb(200, 205, 222); border-top-style: solid; display: block; color: rgb(0, 0, 102); white-space: pre-wrap; word-wrap: break-word; overflow-x: hidden; overflow-y: hidden; background-position: initial initial; background-repeat: initial initial; "><span id="ctl00_MTContentSelector1_mainContentContainer_ctl13" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " xmlns:msxsl="urn:schemas-microsoft-com:xslt">interface IRecipeDisplay : IHttpHandler
{
    string RecipeName { get;  set; }
}
</span></pre>
</div>
</div>
<div class="ArticleNormalPara" id="id0070043" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">Notice how the route handler can also pull data from the routing engine&#39;s parameter dictionary, which is the RouteData property of the RequestContext class. The routing engine sets up the RequestContext and passes an instance when it invokes this method. There are many options available for getting the route data into the Web Form. You could pass the route data along in the HttpContext Items collection, for instance. In this example, you&#39;ve defined an interface for your Web Form to implement (IRecipeDisplay). The route handler can set strongly typed properties on the Web Form to pass along any information the Web Form requires, and this approach will work with both the ASP.NET Web site and ASP.NET application compilation models.</div>
<p>&nbsp;</p>
<div class="ArticleTypeTitle" id="id0070044" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: normal; font-family: 'Segoe UI', Arial; margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 16px; font-variant: normal; text-transform: none; color: rgb(38, 8, 89); ">Routing and Security</div>
<div class="ArticleNormalPara" id="id0070045" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">When you&#39;re using ASP.NET routing, you can still use all the ASP.NET features you&#39;ve come to love&mdash;Master Pages, output caching, themes, user controls, and more. There is one notable exception, however. The routing module works its magic using events in the pipeline that occur after the authentication and authorization stages of processing, meaning that ASP.NET will be authorizing your users using the public, visible URL and not the virtual path to the ASP.NET Web Form that the route handler selects to process the request. You need to pay careful attention to the authorization strategy for an application using routing.</div>
<div class="ArticleNormalPara" id="id0070046" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">Let&#39;s say you wanted to only allow authenticated users to view recipes. One approach would be to modify the root web.config to use the authorization settings here:</div>
<div class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl14_" style="border-top-width: 5px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 20px; padding-left: 0px; width: 614px; border-top-color: rgb(255, 255, 255); border-top-style: solid; display: block; ">
<div class="CodeSnippetTitleBar" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-color: rgb(221, 221, 221); white-space: nowrap; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); height: 15px; word-spacing: normal; letter-spacing: normal; ">
<div class="CodeDisplayLanguage" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: left; text-align: left; ">&nbsp;</div>
</p></div>
<div dir="ltr" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-color: rgb(221, 221, 221); ">
<pre class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl14_code" space="preserve" style="border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: Courier, Verdana, Arial, Helvetica, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 5px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); border-top-color: rgb(200, 205, 222); border-top-style: solid; display: block; color: rgb(0, 0, 102); white-space: pre-wrap; word-wrap: break-word; overflow-x: hidden; overflow-y: hidden; background-position: initial initial; background-repeat: initial initial; "><span id="ctl00_MTContentSelector1_mainContentContainer_ctl14" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " xmlns:msxsl="urn:schemas-microsoft-com:xslt">&lt;location path=&quot;recipe&quot;&gt;
  &lt;system.web&gt;
    &lt;authorization&gt;
      &lt;deny users=&quot;?&quot;/&gt;
    &lt;/authorization&gt;
  &lt;/system.web&gt;
&lt;/location&gt;
</span></pre>
</div>
</div>
<div class="ArticleNormalPara" id="id0070054" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">Although this approach will prevent anonymous users from viewing /recipe/tacos, it does have two fundamental weaknesses. First, the setting doesn&#39;t prevent a user from directly requesting /WebForms/RecipeDisplay.aspx (although you could add another authorization rule that prevents all users from directly requesting resources from the Web Forms folder). Second, it is easy to change the route configuration in global.asax.cs without changing the authorization rules and leave your secret recipes open to anonymous users.</div>
<div class="ArticleNormalPara" id="id0070055" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">An alternate approach to authorization would be to protect the RecipeDisplay.aspx Web Form based on its physical location, which is to place web.config files with &lt;authorization&gt; settings directly into the protected folder. However, since ASP.NET is authorizing users based on the public URL, you&#39;ll need to make the authorization checks manually on the virtual path that your route handler uses.</div>
<div class="ArticleNormalPara" id="id0070056" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">You&#39;ll need to add the following code to the beginning of your route handler&#39;s GetHttpHandler method. This code uses the static CheckUrlAccessForPrincipal method of the UrlAuthorizationModule class (the same module that performs authorization checks in the ASP.NET pipeline):</div>
<div class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl15_" style="border-top-width: 5px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 20px; padding-left: 0px; width: 614px; border-top-color: rgb(255, 255, 255); border-top-style: solid; display: block; ">
<div class="CodeSnippetTitleBar" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-color: rgb(221, 221, 221); white-space: nowrap; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); height: 15px; word-spacing: normal; letter-spacing: normal; ">
<div class="CodeDisplayLanguage" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: left; text-align: left; ">&nbsp;</div>
</p></div>
<div dir="ltr" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-color: rgb(221, 221, 221); ">
<pre class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl15_code" space="preserve" style="border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: Courier, Verdana, Arial, Helvetica, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 5px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); border-top-color: rgb(200, 205, 222); border-top-style: solid; display: block; color: rgb(0, 0, 102); white-space: pre-wrap; word-wrap: break-word; overflow-x: hidden; overflow-y: hidden; background-position: initial initial; background-repeat: initial initial; "><span id="ctl00_MTContentSelector1_mainContentContainer_ctl15" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " xmlns:msxsl="urn:schemas-microsoft-com:xslt">if (!UrlAuthorizationModule.CheckUrlAccessForPrincipal(
    _virtualPath, requestContext.HttpContext.User,
                  requestContext.HttpContext.Request.HttpMethod))
{
    requestContext.HttpContext.Response.StatusCode =
        (int)HttpStatusCode.Unauthorized;
    requestContext.HttpContext.Response.End();
}
</span></pre>
</div>
</div>
<div class="ArticleNormalPara" id="id0070065" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">In order to access the HttpContext members via the RequestContext, you&#39;ll need to add a reference to the System.Web.Abstractions assembly.</div>
<div class="ArticleNormalPara" id="id0070066" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">With a secure routing handler in place, you can now turn your attention to the page that needs to generate hyperlinks for each recipe in your database. It turns out the routing logic can help you build this page, too.</div>
<p>&nbsp;</p>
<div class="ArticleTypeTitle" id="id0070067" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: normal; font-family: 'Segoe UI', Arial; margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 16px; font-variant: normal; text-transform: none; color: rgb(38, 8, 89); ">URL Generation</div>
<div class="ArticleNormalPara" id="id0070068" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">To generate the hyperlink to any given recipe, I will once again turn to the collection of routes configured during application startup. As shown here, the RouteCollection class has a GetVirtualPath method for this purpose:</div>
<div class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl16_" style="border-top-width: 5px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 20px; padding-left: 0px; width: 614px; border-top-color: rgb(255, 255, 255); border-top-style: solid; display: block; ">
<div class="CodeSnippetTitleBar" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-color: rgb(221, 221, 221); white-space: nowrap; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); height: 15px; word-spacing: normal; letter-spacing: normal; ">
<div class="CodeDisplayLanguage" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: left; text-align: left; ">&nbsp;</div>
</p></div>
<div dir="ltr" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-color: rgb(221, 221, 221); ">
<pre class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl16_code" space="preserve" style="border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: Courier, Verdana, Arial, Helvetica, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 5px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); border-top-color: rgb(200, 205, 222); border-top-style: solid; display: block; color: rgb(0, 0, 102); white-space: pre-wrap; word-wrap: break-word; overflow-x: hidden; overflow-y: hidden; background-position: initial initial; background-repeat: initial initial; "><span id="ctl00_MTContentSelector1_mainContentContainer_ctl16" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " xmlns:msxsl="urn:schemas-microsoft-com:xslt">VirtualPathData pathData =
    RouteTable.Routes.GetVirtualPath(
                  null,
                  &quot;Recipe&quot;,
                  new RouteValueDictionary { { &quot;Name&quot;, recipeName } });

return pathData.VirtualPath;
</span></pre>
</div>
</div>
<div class="ArticleNormalPara" id="id0070076" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">You need to pass in the desired route name (&quot;Recipe&quot;) along with a dictionary of the required parameters and their associated values. This method will use the URL pattern you created earlier (/recipe/{name}) to construct the proper URL.</div>
<div class="ArticleNormalPara" id="id0070077" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">The following code uses this method to generate a collection of anonymously typed objects. The objects have Name and Url properties that you can use with data binding to generate a list or table of available recipes:</div>
<div class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl17_" style="border-top-width: 5px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 20px; padding-left: 0px; width: 614px; border-top-color: rgb(255, 255, 255); border-top-style: solid; display: block; ">
<div class="CodeSnippetTitleBar" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; background-color: rgb(221, 221, 221); white-space: nowrap; border-bottom-style: solid; border-bottom-color: rgb(170, 170, 170); height: 15px; word-spacing: normal; letter-spacing: normal; ">
<div class="CodeDisplayLanguage" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; float: left; text-align: left; ">&nbsp;</div>
</p></div>
<div dir="ltr" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; background-color: rgb(221, 221, 221); ">
<pre class="libCScode" id="ctl00_MTContentSelector1_mainContentContainer_ctl17_code" space="preserve" style="border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: Courier, Verdana, Arial, Helvetica, sans-serif; margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 5px; padding-right: 5px; padding-bottom: 0px; padding-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(221, 221, 221); border-top-color: rgb(200, 205, 222); border-top-style: solid; display: block; color: rgb(0, 0, 102); white-space: pre-wrap; word-wrap: break-word; overflow-x: hidden; overflow-y: hidden; background-position: initial initial; background-repeat: initial initial; "><span id="ctl00_MTContentSelector1_mainContentContainer_ctl17" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: inherit; font-style: inherit; font-family: inherit; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; " xmlns:msxsl="urn:schemas-microsoft-com:xslt">var recipes =
    new RecipeRepository()
        .GetAllRecipeNames()
        .OrderBy(recipeName =&gt; recipeName)
        .Select(recipeName =&gt;
          new
          {
            Name = recipeName,
            Url = GetVirtualPathForRecipe(recipeName)
          });
</span></pre>
</div>
</div>
<div class="ArticleNormalPara" id="id0070088" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">The ability to generate URLs from your routing configuration means you can change the configuration without the fear of creating broken links inside your application. Of course, you still might break your user&#39;s favorite links and bookmarks, but having the ability to change is a tremendous advantage when you are still designing the application&#39;s URL structure.</div>
<p>&nbsp;</p>
<div class="ArticleTypeTitle" id="id0070089" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: bold; font-style: normal; font-family: 'Segoe UI', Arial; margin-top: 3px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 16px; font-variant: normal; text-transform: none; color: rgb(38, 8, 89); ">Wrapping Up with Routes</div>
<div class="ArticleNormalPara" id="id0070090" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-weight: normal; font-style: normal; font-family: 'Segoe UI', Verdana, Arial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; outline-width: 0px; outline-style: initial; outline-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 7px; padding-left: 0px; font-size: 14px; font-variant: normal; text-transform: none; line-height: 18px; color: rgb(51, 51, 51); ">The URL routing engine does all of the dirty work of URL pattern matching and URL generation. All you need to do is configure your routes and implement your route handlers. With routing, you are truly isolated from file extensions and the physical layout of your file system, and you don&#39;t need to deal with the quirks of using a URL rewriter. Instead, you can concentrate on the optimum URL design for your end users and for search engines. In addition, Microsoft is working on making URL routing with Web Forms even easier and more configurable in the upcoming ASP.NET 4.0.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.allfreetech.com/microsoft-net/asp-net/routing-with-asp-net-web-forms-149.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Caching Oracle Data for ASP.NET Applications</title>
		<link>http://www.allfreetech.com/microsoft-net/asp-net/caching-oracle-data-for-asp-net-applications-144.html</link>
		<comments>http://www.allfreetech.com/microsoft-net/asp-net/caching-oracle-data-for-asp-net-applications-144.html#comments</comments>
		<pubDate>Fri, 29 Jan 2010 13:46:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://www.allfreetech.com/?p=144</guid>
		<description><![CDATA[&#160;
For building scalable and high-performance Web based applications, ASP.NET provides a feature called data caching. Data caching enables programmatic storing of frequently accessed data objects in memory. This feature can be extended to vastly improve performance for ASP.NET applications that query data stored in an Oracle database. This article describes a strategy for caching Oracle [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">For building scalable and high-performance Web based applications, ASP.NET provides a feature called data caching. Data caching enables programmatic storing of frequently accessed data objects in memory. This feature can be extended to vastly improve performance for ASP.NET applications that query data stored in an Oracle database. This article describes a strategy for caching Oracle database data in ASP.NET Web applications deployed using a Web Farm environment. This technique enables caching of frequently accessed Oracle database data in memory rather than making frequent database calls to retrieve the data. This helps to avoid unnecessary roundtrips to the Oracle database server. Further the article proposes an implementation for maintaining the cached data so it is always in sync with the corresponding data in the Oracle database.<span id="more-144"></span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span class="clsTitle" style="font-weight: bold; font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: 12pt; ">Data Caching in ASP.NET</span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">Data Caching in ASP.NET is facilitated via the Cache class and the CacheDependency class in the System.Web.Caching namespace. The Cache class provides methods for inserting data and retrieving data from the cache. The CacheDependency class enables dependencies to be specified for the data items placed in the cache. An expiration policy for an item can be specified when we add it to the cache using the Insert method or Add method. We can define the life span for an item in the cache by using the absoluteExpiration parameter in the Insert method. This parameter allows one to specify the exact datetime that the corresponding data item will expire. One can also use the slidingExpiration parameter, specifying the elapsed time before the item will expire based on the time it was accessed. Once the item expires, it is removed from the cache. Attempts to access it will return a null value unless the item is added to the Cache again.</span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span class="clsTitle" style="font-weight: bold; font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: 12pt; ">Specifying Dependencies for Cache</span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">ASP.NET allows us to define the dependency of a cached item based on an external file, a directory, or another cached item. These are described as file dependencies and key dependencies. If a dependency changes, the cached item gets automatically invalidated and removed from the cache. We can use this approach to delete items from the cache when the corresponding data source changes. For example, if we write an application that retrieves data from an XML file and displays it in a grid, we can store the data from the file in the Cache and specify a Cache dependency on the XML file. When the XML file is updated, the data item gets removed from the cache. When this event occurs, the application reads the XML file again, and the latest copy of the data item is inserted into the cache again. Further, callback event handlers can be specified as a listener for getting notified when the cache item gets deleted from the cache. This eliminates the need to continuously poll the cache to determine whether the data item has been invalidated.</span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span class="clsTitle" style="font-weight: bold; font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: 12pt; ">ASP.NET Cache Dependency on Oracle Database</span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">Let us consider a scenario where data is stored in the Oracle database and accessed by an ASP.NET application using ADO.NET. Furthermore, let us assume that the data in the database table(s) is generally static but accessed frequently by the Web application. In a nutshell, there are very few DML operations on the table but lots of Selects on the data. Such a scenario is ideal for data caching. But unfortunately, ASP.NET does not allow a dependency to be specified whereby a cache item is dependent on data stored in a database table. Furthermore, in real world Web based systems, the Web server and the Oracle database server could be potentially running on different machines, making this cache invalidation process more challenging. Also most Web-based applications are deployed using Web farms with instances of the same application running on multiple Web servers for load balancing. This scenario makes the database caching problem slightly more complex.</span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">For exploring the solution to the above problem, let&#39;s put together a sample Web application to illustrate how it can be implemented. For our example, we use ASP.NET application implemented in VB .Net communicating with the Oracle 9i database using Oracle Data Provider for .NET (ODP).</span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">In this example, consider a table named Employee in the Oracle database. We define a trigger for insert, update and delete operations on the Employee table. This trigger calls a PL/SQL function that serves as a wrapper for a Java stored procedure. This Java stored procedure in turn will be responsible for updating the Cache dependency file.</span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span class="clsTitle" style="font-weight: bold; font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: 12pt; ">ASP.NET Tier Implementation Using VB.NET</span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">On the ASP.NET tier, we have a listener class containing a callback method to handle the notification when the cache item gets invalidated.</span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">The callback method RemovedCallback is registered by using a delegate function. The callback method onRemove declaration must have the same signature as the CacheItemRemovedCallback delegate declaration.</span></span></p>
<p>&nbsp;</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span style="font-size: 10pt; font-family: 'Courier New'; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="color: blue; ">Dim</span><span>&nbsp;onRemove&nbsp;<span style="color: blue; ">As</span>&nbsp;CacheItemRemovedCallback =&nbsp;<span style="color: blue; ">Nothing<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span style="color: blue; "><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span>onRemove =&nbsp;<span style="color: blue; ">New</span>&nbsp;CacheItemRemovedCallback(<span style="color: blue; ">AddressOf</span>&nbsp;RemovedCallback)</span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">The definition for the listener event handler method RemovedCallback responsible for handling the notification from the database trigger is illustrated below. When the cache item gets invalidated, data is retrieved from the database by using the database method call getRecordFromdatabase(). The parameter &quot;key&quot; refers to the index location for the item removed from the cache. The parameter &quot;value&quot; refers to the data object removed from the cache. The parameter &quot;CacheItemRemovedReason&quot; specifies the reason causing the data item to be removed from the cache.</span></span></p>
<p>&nbsp;</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span style="color: blue; ">Public</span><span><span style="color: blue; ">Sub</span>&nbsp;RemovedCallback(<span style="color: blue; ">ByVal</span>&nbsp;key&nbsp;<span style="color: blue; ">As</span><span style="color: blue; ">String</span>,&nbsp;<span style="color: blue; ">ByVal</span>&nbsp;value&nbsp;<span style="color: blue; ">As</span><span style="color: blue; ">Object</span>,<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>ByVal reason&nbsp;<span style="color: blue; ">As</span>&nbsp;CacheItemRemovedReason)<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Dim</span>&nbsp;Source&nbsp;<span style="color: blue; ">As</span>&nbsp;DataView<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>Source = getRecordFromdatabase()<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>Cache.Insert(&quot;employeeTable &quot;, Source,&nbsp;<span style="color: blue; ">New</span><o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>System.Web.Caching.CacheDependency(&quot;d:\download\tblemployee.txt&quot;),<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration,<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>CacheItemPriority.Normal, onRemove)<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span style="color: blue; ">End</span><span><span style="color: blue; ">Sub<o:p></o:p></span></span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">The method getRecordFromdatabase() is responsible for querying the database table Employee and it returns a DataView object reference. It makes use of a stored procedure called getEmployee to abstract the SQL for retrieving the data from the Employee table. The method expects a parameter called p_empid representing the primary key for the Employee table.</span></span></p>
<p>&nbsp;</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span style="color: blue; ">Public</span><span><span style="color: blue; ">Function</span>&nbsp;getRecordFromdatabase (<span style="color: blue; ">ByVal</span>&nbsp;p_empid&nbsp;<span style="color: blue; ">As</span>&nbsp;Int32)&nbsp;<span style="color: blue; ">As</span>&nbsp;DataView<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Dim</span>&nbsp;con&nbsp;<span style="color: blue; ">As</span>&nbsp;OracleConnection =&nbsp;<span style="color: blue; ">Nothing<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span>&nbsp;&nbsp;</span><span style="color: blue; ">Dim</span>&nbsp;cmd&nbsp;<span style="color: blue; ">As</span>&nbsp;OracleCommand =&nbsp;<span style="color: blue; ">Nothing<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Dim</span>&nbsp;ds&nbsp;<span style="color: blue; ">As</span>&nbsp;DataSet =&nbsp;<span style="color: blue; ">Nothing<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span style="color: blue; ">&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Try<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>con = getDatabaseConnection(<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">&quot;UserId=scott;Password=tiger;Data Source=testingdb;&quot;</span>)<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>cmd =&nbsp;<span style="color: blue; ">New</span>&nbsp;OracleCommand(&quot;Administrator.getEmployee&quot;, con)<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>cmd.CommandType = CommandType.StoredProcedure<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>cmd.Parameters.Add(<span style="color: blue; ">New</span>&nbsp;OracleParameter(&quot;employeeId&quot;,<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>OracleDbType.Int64)).Value = p_empid<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Dim</span>&nbsp;param&nbsp;<span style="color: blue; ">As</span><span style="color: blue; ">New</span>&nbsp;OracleParameter(&quot;RC1&quot;, OracleDbType.RefCursor)<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>cmd.Parameters.Add(param).Direction = ParameterDirection.Output<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Dim</span>&nbsp;myCommand&nbsp;<span style="color: blue; ">As</span><span style="color: blue; ">New</span>&nbsp;OracleDataAdapter(cmd)<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>ds =&nbsp;<span style="color: blue; ">New</span>&nbsp;DataSet<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>myCommand.Fill(ds)<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Dim</span>&nbsp;table&nbsp;<span style="color: blue; ">As</span>&nbsp;DataTable = ds.Tables(0)<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Dim</span>&nbsp;index&nbsp;<span style="color: blue; ">As</span>&nbsp;Int32 = table.Rows.Count<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Return</span>&nbsp;ds.Tables(0).DefaultView<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Catch</span>&nbsp;ex&nbsp;<span style="color: blue; ">As</span>&nbsp;Exception<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Throw</span><span style="color: blue; ">New</span>&nbsp;Exception(&quot;Exception in Database Tier Method<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>getRecordFromdatabase () &quot; + ex.Message, ex)<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Finally<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Try<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>cmd.Dispose()<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Catch</span>&nbsp;ex&nbsp;<span style="color: blue; ">As</span>&nbsp;Exception<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Finally<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>cmd =&nbsp;<span style="color: blue; ">Nothing<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">End</span><span style="color: blue; ">Try<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Try<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>con.Close()<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Catch</span>&nbsp;ex&nbsp;<span style="color: blue; ">As</span>&nbsp;Exception<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Finally<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>con =&nbsp;<span style="color: blue; ">Nothing<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">End</span><span style="color: blue; ">Try<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">End</span><span style="color: blue; ">Try<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">End</span><span style="color: blue; ">Function<o:p></o:p></span></span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">The function getDatabaseConnection accepts a connectionstring as an argument and returns an OracleConnection object reference.</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span style="color: blue; ">&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span style="color: blue; ">Public</span><span><span style="color: blue; ">Function</span>&nbsp;getDatabaseConnection(ByVal strconnection as string)&nbsp;<span style="color: blue; ">As</span><o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>OracleConnection<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Dim</span>&nbsp;con&nbsp;<span style="color: blue; ">As</span>&nbsp;Oracle.DataAccess.Client.OracleConnection =&nbsp;<span style="color: blue; ">Nothing<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Try<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>con =&nbsp;<span style="color: blue; ">New</span>&nbsp;Oracle.DataAccess.Client.OracleConnection<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>con.ConnectionString = strconnection<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>con.Open()<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Return</span>&nbsp;con<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Catch</span>&nbsp;ex&nbsp;<span style="color: blue; ">As</span>&nbsp;Exception<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">Throw</span><span style="color: blue; ">New</span>&nbsp;Exception(&quot;Exception in Database Tier Method<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>getOracleConnection() &quot; + ex.Message, ex)<o:p></o:p></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue; ">End</span><span style="color: blue; ">Try<o:p></o:p></span></span></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span><span>&nbsp;</span><span style="color: blue; ">End</span><span style="color: blue; ">Function<o:p></o:p></span></span></span></span></p>
<p>&nbsp;</p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span class="clsTitle" style="font-weight: bold; font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: 12pt; ">Oracle Database Tier Implementation</span></span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">The Trigger body defined for DML events on the Employee Table is shown below. This trigger simply invokes a PL/SQL wrapper function for updating an operating system file called tblemployee.txt. Copies of this file are updated on two different machines called machine1 and machine2 that are running different instances of the same Web application to enable load balancing. Here administrator refers to the owner of the schema objects in the Oracle database.</span></span></span></p>
<p>&nbsp;</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">begin</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;</span>administrator.plfile(&#39;machine1\\download\\<span>&nbsp;tblemployee</span>.txt&#39;);</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;</span>administrator.plfile(&#39;machine2\\download\\<span>&nbsp;tblemployee</span>.txt&#39;);</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">end;</span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">For updating the cache dependency file, we will need to write a C function or a Java stored procedure. In our example, we chose a Java stored procedure since Oracle database server has a built-in JVM, making it easy to write Java stored procedures. Adequate memory must be allocated for the Java Pool in the System global area (SGA) of the Oracle instance. The static method updateFile accepts an absolute pathname as a parameter and creates the cache dependency file in the appropriate directory. If the file already exists, it is deleted and created again.</span></span></p>
<p>&nbsp;</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">import java.io.*;</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">&nbsp;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">public class UpdFile {</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">&nbsp;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;</span>public static void updateFile(String filename) {</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">&nbsp;<o:p></o:p></span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>try {</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>File f = new File(filename);</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>f.delete();</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>f.createNewFile();</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;</span>}</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;</span>catch (IOException e)</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;</span>{</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>// log exception</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;&nbsp;&nbsp;</span>}</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; "><span>&nbsp;&nbsp;</span>}</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">};</span></span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">The pl/sql wrapper implementation is shown below. The wrapper function accepts the filename as a parameter and invokes the method updateFile in the Java stored procedure.</span></span></p>
<p>&nbsp;</p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">(p_filename<span>&nbsp;&nbsp;</span>IN<span>&nbsp;&nbsp;</span>VARCHAR2)</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">AS LANGUAGE JAVA</span></span></p>
<p class="MsoNormal" style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman'; line-height: normal; color: windowtext; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: medium; "><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">NAME &#39;UpdFile.updateFile (java.lang.String)&#39;;</span></span></p>
<p><span class="clsTitle" style="font-weight: bold; font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: 12pt; ">Database Caching in a Web Farm Deployment</span></p>
<p><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">As illustrated in the example we have discussed, Web Servers machine1 and machine2 constitute the Web farm to provide load balancing for our Web application. Each machine runs an instance of the same Web application. In this scenario, each instance of the Web application can have its own copy of the cached data stored in its Cache object. When the employee table changes, the corresponding database trigger updates the file tblemployee.txt on both of these machines. Each instance of the Web application specifies a cache dependency on the local file tblemployee.txt, and the cache for both the instances in the Web Farm gets updated correctly, enabling the data cache on both the instances to remain in sync with the database table Employee.</span></p>
<p><span class="clsTitle" style="font-weight: bold; font-family: 'Arial, Helvetica,MS Sans Serif'; font-size: 12pt; ">Conclusion</span></p>
<p><span class="clsBlurb" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 10pt; ">Data Caching can be an effective technique for optimizing ASP.NET applications using the Oracle database. Although ASP.NET does not allow database dependency to be specified for the cache, Oracle triggers in conjunction with Java stored procedures can be used to extend the power of the ASP.NET cache to enable Oracle database caching. This technique can also be applied to Web Farm deployments.</span></p>
<p><strong><span class="Apple-style-span" style="font-family: 'Arial, Helvetica,  MS Sans Serif'; font-size: 13px; ">Narayan Veeramani</span></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.allfreetech.com/microsoft-net/asp-net/caching-oracle-data-for-asp-net-applications-144.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hacking New York Times and Twitter with Microsoft AJAX and jQuery</title>
		<link>http://www.allfreetech.com/ajax/hacking-new-york-times-and-twitter-with-microsoft-ajax-and-jquery-139.html</link>
		<comments>http://www.allfreetech.com/ajax/hacking-new-york-times-and-twitter-with-microsoft-ajax-and-jquery-139.html#comments</comments>
		<pubDate>Sun, 24 Jan 2010 08:23:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.allfreetech.com/?p=139</guid>
		<description><![CDATA[In this article by Dr. Jayaram Krishnaswamy, we look at two APIs, the Twitter API and the New York Times API and see how we can access data on them using the JavaScript libraries available on the Microsoft Edge Content Network also know as Microsoft Content Delivery Network (CDN). While jQuery is used to access [...]]]></description>
			<content:encoded><![CDATA[<p>In this article by <b>Dr. Jayaram Krishnaswamy</b>, we look at two APIs, the Twitter API and the New York Times API and see how we can access data on them using the JavaScript libraries available on the Microsoft Edge Content Network also know as Microsoft Content Delivery Network (CDN). While jQuery is used to access API retrieved data on the intranet web server, the Microsoft AJAX client templates are used in displaying them.<span id="more-139"></span></p>
<p>APIs (Application Programming Interface) are application-to-application programming interfaces that support harvesting information on the web using the known web standards. These APIs are provided by the entities who wish to expose parts of their resources that a third party can use. The APIs run transparent to the user and exposes just what they want to expose, with some providing access to material for public consumption with others giving access to resources based on authentication. In a sense they may be called a basic form of SAAS.</p>
<p>Amazon.com, Google etc have exposed their APIs for some time. Twitter and New York Times have also exposed their API&#39;s which can be used to do some digging into the information contained in them, a kind of web mining. Many others such as Netflix have provided their own APIs described on their web sites.</p>
<h1>What is Twitter API?</h1>
<p>Twitter API is provided by the Social Networking and Micro-blogging service. Twitter API adheres to the web standards and one can talk to Twitter using HTTP. You can just about access anything on the Twitter web site. One example of creating a Microsoft SQL Server Report using Twitter API is available here &#8211; <a href="http://www.sswug.org/articles/viewarticle.aspx?id=44106" target="_blank">Tweets with Reporting Services</a>, wherein the response from the Twitter API was in XML format. JSON (JavaScript Object Notation) is another format in which data is returned when an API call is made. In this article we will be looking at API call that returns a JSON response.</p>
<p>Twitter exposes a large number methods through their API&#39;s such as API&#39;s for Search, Timeline, Status, User, Direct Message, Friendship and many more. As previously mentioned the responses will be in XML or JSON. Also while some APIs may take parameters others may not.</p>
<h1>The Twitter API used in this tutorial</h1>
<p>We will be looking at <i>trends</i> in Twitter API exposed by the url, <a href="http://search.twiiter.com/trends.format" target="_blank">http://search.twiiter.com/trends.format</a>. We will be using the GET method and we will expect a JSON response. Since the volume of traffic may overwhelm, the calls that you can make to this in an hour are limited (also known as rate limiting) but not critical for the demo in this tutorial.</p>
<p>Here is a typical call to the <i>trends</i> method on the Twitter API. Herein we will search for <i>trends</i> on the Twitter site and expect a response in JSON, if we use <i>json</i> instead of <i>Format</i> in the next URL address.</p>
<pre style="margin-left: 40px;">Instead of:

http://search.twitter.com/trends.Format

type-in, the following for URL address,

http://search.twitter.com/trends.json
</pre>
<p>When you plug the above in a web Brower you would get a response <i>trends.json</i> which you may save to your hard drive or, use it in any way you like. The next quoted text is what you get in response (note that this is what I got on Saturday 31, 2009 and what you get will be different), the content of the file <i>trends.json</i> you saved to your computer. Note that presently you get about top ten trends from <a href="http://apiwiki.twitter.com/Twitter-Search-API-Method:-trends" target="_blank">this</a> API call.</p>
<pre style="margin-left: 40px;">{&quot;as_of&quot;:&quot;Sat, 31 Oct 2009 20:44:46 +0000&quot;,&quot;trends&quot;:[{&quot;name&quot;:&quot;Happy Halloween&quot;,
&quot;url&quot;:&quot;http://search.twitter.com/search?q=&quot;Happy+Halloween&quot;+OR+&quot;Feliz+
Halloween&quot;&quot;},{&quot;name&quot;:&quot;#nxzerosetechaves&quot;,&quot;url&quot;:&quot;http://search.twitter.com/
search?q=#nxzerosetechaves&quot;},{&quot;name&quot;:&quot;Danyl&quot;,&quot;url&quot;:&quot;http://search.twitter.com/
search?q=Danyl&quot;},{&quot;name&quot;:&quot;#HappyHalloween&quot;,&quot;url&quot;:&quot;http://search.twitter.com/
search?q=#HappyHalloween&quot;},{&quot;name&quot;:&quot;#potterday&quot;,&quot;url&quot;:&quot;http://search.twitter.com/
search?q =#potterday&quot;},{&quot;name&quot;:&quot;X Factor&quot;,&quot;url&quot;:&quot;http://search.twitter.com/
search?q=&quot;X+ Factor&quot;&quot;},{&quot;name&quot;:&quot;It&#39;s Halloween&quot;,&quot;url&quot;:&quot;http://search.twitter.
com/search?q=&quot;It &#39;s+Halloween&quot;+OR+&quot;Its+Halloween&quot;&quot;},{&quot;name&quot;:&quot;Trick&quot;,
&quot;url&quot;:&quot;http://search.twitter.com/search?q=Trick+OR+#trick&quot;},{&quot;name&quot;:&quot;Paranormal
Activity&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=&quot;Paranormal+Activity&quot;&quot;},
{&quot;name&quot;:&quot;This Is It&quot;,&quot;url&quot;:&quot;http://search.twitter.com/search?q=&quot;This+Is+It&quot;&quot;}]}
</pre>
<p>First of all what you see returned is a JSON object. If you are new to JSON review <a href="http://hodentek.blogspot.com/2007/07/simple-xml-file-aka-my-hello-world-for.html" target="_blank">this</a> article on my blog. The various elements that you see such as &#39;name&#39;, &#39;url&#39; etc are fields in the response that are all described in the API documentation(look for Return Values). Some of the API calls can return a ton of information and you will have to know the API method so that you can correctly parse this data. Another thing you would notice is that the JSON object you get out is a nested object with many levels. You may need a JSON Parser to get a clearer picture of this nesting and I recommend using the online parser at <a href="http://json.parser.online.fr/" target="_blank">this</a> site. Using the above site, the JSON Object would appear as shown (only a portion is shown).</p>
<p><img src="http://www.packtpub.com/files/images/msajax-article-image01.png" /></p>
<h1>New York Times API</h1>
<p>New York Times made available to the developers sometime in the middle of <a href="http://www.readwriteweb.com/archives/the_first_new_york_times_api_i.php" target="_blank">October 2008</a> APIs that can search New York Times for various kinds of information . Just like in Twitter there are a large number of APIs that you can use such as: Article Search; Best Sellers; Campaign Finance; Congress; and many others. Interested users can get on to this resource by signing up <a href="http://developer.nytimes.com/" target="_blank">here</a> requesting what APIs they would like to use. After signing up, New York Times would provide keys for the APIs that you want to access. It is important therefore, that the call should include the keys provided to you. For example, I received keys to access the following resources: Movie Reviews, Article Search, Best Sellers and Times Newswire. The key for the Movies Reviews API appears as shown here (the one shown here has been doctored and will not work).</p>
<pre style="margin-left: 40px;">Movie Reviews API
Key: b57378910b9fd80ecc73461547c93e8a:10:50673441
</pre>
<h2>Using the New York Times API</h2>
<p>It is a valuable resource since you can get for example with the Article Search API access to more than <a href="http://open.blogs.nytimes.com/2009/02/04/announcing-the-article-search-api/" target="_blank">2.8 million articles from 1981</a>. Using this is quite simple, just paste the URL shown below into the address box of your browser. Note that the key shown here is fake (but of correct format).</p>
<pre style="margin-left: 40px;">http://api.nytimes.com/svc/search/v1/article?query=India&amp;facets=
publication_year&amp;api-key=6c208890a4880093c30020be8fe17a40:0:50633441
</pre>
<p>This will display in the browser the JSON object that is returned as shown. You can use the previously mentioned site to parse it for more friendly display.</p>
<pre style="margin-left: 40px;">{&quot;facets&quot; : {&quot;publication_year&quot; : [{&quot;count&quot; : 2724 , &quot;term&quot; : &quot;2008&quot;} ,
{&quot;count&quot; : 2345 , &quot;term&quot; : &quot;2006&quot;} , {&quot;count&quot; : 2311 , &quot;term&quot; : &quot;2009&quot;} ,
{&quot;count&quot; : 2282 , &quot;term&quot; : &quot;2007&quot;} , {&quot;count&quot; : 2144 , &quot;term&quot; : &quot;2002&quot;} ,
{&quot;count&quot; : 2111 , &quot;term&quot; : &quot;2001&quot;} , {&quot;count&quot; : 1988 , &quot;term&quot; : &quot;2005&quot;} ,
{&quot;count&quot; : 1951 , &quot;term&quot; : &quot;2004&quot;} , {&quot;count&quot; : 1921 , &quot;term&quot; : &quot;1985&quot;} ,
{&quot;count&quot; : 1798 , &quot;term&quot; : &quot;2003&quot;} , {&quot;count&quot; : 1761 , &quot;term&quot; : &quot;1999&quot;} ,
{&quot;count&quot; : 1720 , &quot;term&quot; : &quot;2000&quot;} , {&quot;count&quot; : 1642 , &quot;term&quot; : &quot;1998&quot;} ,
{&quot;count&quot; : 1442 , &quot;term&quot; : &quot;1984&quot;} , {&quot;count&quot; : 1382 , &quot;term&quot; : &quot;1986&quot;}]} ,
&quot;offset&quot; : &quot;0&quot; , &quot;results&quot; :
[{&quot;body&quot; : &quot;BARSUR, India &mdash; At the edge of the Indravati River, hundreds
of miles from the nearest international border, India effectively ends.
Indian paramilitary officers point machine guns across the water.
 The dense jungles and mountains on the other side belong to Maoist rebels
dedicated to overthrowing the government. &quot;That is their liberated&quot; ,
&quot;byline&quot; : &quot;By JIM YARDLEY&quot; , &quot;date&quot; : &quot;20091101&quot; , &quot;title&quot; :
 &quot;Maoist Rebels Widen Deadly Reach Across India&quot; , &quot;url&quot; : &quot;http://www.
nytimes.com/2009/11/01/world/asia
 /01maoist.html&quot;} ,.........(there is more of this but abbreviated here)
</pre>
<h1>Response Format</h1>
<p>As you can see the responses to the API calls return JSON objects in general of the form shown belo<!--[if gte mso 9]><xml></p>
<p><w:WordDocument></p>
<p><w:View>Normal</w:View></p>
<p><w:Zoom>0</w:Zoom></p>
<p><w:TrackMoves/></p>
<p><w:TrackFormatting/></p>
<p><w:PunctuationKerning/></p>
<p><w:ValidateAgainstSchemas/></p>
<p><w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid></p>
<p><w:IgnoreMixedContent>false</w:IgnoreMixedContent></p>
<p><w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText></p>
<p><w:DoNotPromoteQF/></p>
<p><w:LidThemeOther>EN-US</w:LidThemeOther></p>
<p><w:LidThemeAsian>X-NONE</w:LidThemeAsian></p>
<p><w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript></p>
<p><w:Compatibility></p>
<p><w:BreakWrappedTables/></p>
<p><w:SnapToGridInCell/></p>
<p><w:WrapTextWithPunct/></p>
<p><w:UseAsianBreakRules/></p>
<p><w:DontGrowAutofit/></p>
<p><w:SplitPgBreakAndParaMark/></p>
<p><w:DontVertAlignCellWithSp/></p>
<p><w:DontBreakConstrainedForcedTables/></p>
<p><w:DontVertAlignInTxbx/></p>
<p><w:Word11KerningPairs/></p>
<p><w:CachedColBalance/></p>
<p></w:Compatibility></p>
<p><w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel></p>
<p><m:mathPr></p>
<p><m:mathFont m:val="Cambria Math"/></p>
<p><m:brkBin m:val="before"/></p>
<p><m:brkBinSub m:val="--"/></p>
<p><m:smallFrac m:val="off"/></p>
<p><m:dispDef/></p>
<p><m:lMargin m:val="0"/></p>
<p><m:rMargin m:val="0"/></p>
<p><m:defJc m:val="centerGroup"/></p>
<p><m:wrapIndent m:val="1440"/></p>
<p><m:intLim m:val="subSup"/></p>
<p><m:naryLim m:val="undOvr"/></p>
<p></m:mathPr></w:WordDocument></p>
<p></xml><![endif]--><!--[if gte mso 9]><xml></p>
<p><w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"</p>
<p>DefSemiHidden="true" DefQFormat="false" DefPriority="99"</p>
<p>LatentStyleCount="267"></p>
<p><w:LsdException Locked="false" Priority="0" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Normal"/></p>
<p><w:LsdException Locked="false" Priority="9" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="heading 1"/></p>
<p><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/></p>
<p><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/></p>
<p><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/></p>
<p><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/></p>
<p><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/></p>
<p><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/></p>
<p><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/></p>
<p><w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/></p>
<p><w:LsdException Locked="false" Priority="39" Name="toc 1"/></p>
<p><w:LsdException Locked="false" Priority="39" Name="toc 2"/></p>
<p><w:LsdException Locked="false" Priority="39" Name="toc 3"/></p>
<p><w:LsdException Locked="false" Priority="39" Name="toc 4"/></p>
<p><w:LsdException Locked="false" Priority="39" Name="toc 5"/></p>
<p><w:LsdException Locked="false" Priority="39" Name="toc 6"/></p>
<p><w:LsdException Locked="false" Priority="39" Name="toc 7"/></p>
<p><w:LsdException Locked="false" Priority="39" Name="toc 8"/></p>
<p><w:LsdException Locked="false" Priority="39" Name="toc 9"/></p>
<p><w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/></p>
<p><w:LsdException Locked="false" Priority="10" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Title"/></p>
<p><w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/></p>
<p><w:LsdException Locked="false" Priority="11" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/></p>
<p><w:LsdException Locked="false" Priority="22" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Strong"/></p>
<p><w:LsdException Locked="false" Priority="20" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/></p>
<p><w:LsdException Locked="false" Priority="59" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Table Grid"/></p>
<p><w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/></p>
<p><w:LsdException Locked="false" Priority="1" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/></p>
<p><w:LsdException Locked="false" Priority="60" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Shading"/></p>
<p><w:LsdException Locked="false" Priority="61" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light List"/></p>
<p><w:LsdException Locked="false" Priority="62" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Grid"/></p>
<p><w:LsdException Locked="false" Priority="63" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 1"/></p>
<p><w:LsdException Locked="false" Priority="64" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 2"/></p>
<p><w:LsdException Locked="false" Priority="65" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 1"/></p>
<p><w:LsdException Locked="false" Priority="66" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 2"/></p>
<p><w:LsdException Locked="false" Priority="67" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 1"/></p>
<p><w:LsdException Locked="false" Priority="68" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 2"/></p>
<p><w:LsdException Locked="false" Priority="69" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 3"/></p>
<p><w:LsdException Locked="false" Priority="70" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Dark List"/></p>
<p><w:LsdException Locked="false" Priority="71" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Shading"/></p>
<p><w:LsdException Locked="false" Priority="72" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful List"/></p>
<p><w:LsdException Locked="false" Priority="73" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Grid"/></p>
<p><w:LsdException Locked="false" Priority="60" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Shading Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="61" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light List Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="62" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Grid Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="63" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="64" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="65" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/></p>
<p><w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/></p>
<p><w:LsdException Locked="false" Priority="34" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/></p>
<p><w:LsdException Locked="false" Priority="29" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Quote"/></p>
<p><w:LsdException Locked="false" Priority="30" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/></p>
<p><w:LsdException Locked="false" Priority="66" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="67" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="68" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="69" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="70" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Dark List Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="71" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="72" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful List Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="73" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/></p>
<p><w:LsdException Locked="false" Priority="60" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Shading Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="61" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light List Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="62" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Grid Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="63" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="64" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="65" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="66" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="67" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="68" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="69" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="70" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Dark List Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="71" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="72" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful List Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="73" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/></p>
<p><w:LsdException Locked="false" Priority="60" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Shading Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="61" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light List Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="62" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Grid Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="63" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="64" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="65" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="66" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="67" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="68" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="69" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="70" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Dark List Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="71" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="72" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful List Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="73" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/></p>
<p><w:LsdException Locked="false" Priority="60" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Shading Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="61" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light List Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="62" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Grid Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="63" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="64" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="65" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="66" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="67" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="68" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="69" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="70" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Dark List Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="71" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="72" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful List Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="73" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/></p>
<p><w:LsdException Locked="false" Priority="60" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Shading Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="61" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light List Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="62" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Grid Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="63" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="64" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="65" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="66" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="67" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="68" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="69" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="70" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Dark List Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="71" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="72" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful List Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="73" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/></p>
<p><w:LsdException Locked="false" Priority="60" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Shading Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="61" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light List Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="62" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Light Grid Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="63" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="64" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="65" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="66" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="67" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="68" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="69" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="70" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Dark List Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="71" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="72" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful List Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="73" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/></p>
<p><w:LsdException Locked="false" Priority="19" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/></p>
<p><w:LsdException Locked="false" Priority="21" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/></p>
<p><w:LsdException Locked="false" Priority="31" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/></p>
<p><w:LsdException Locked="false" Priority="32" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/></p>
<p><w:LsdException Locked="false" Priority="33" SemiHidden="false"</p>
<p>UnhideWhenUsed="false" QFormat="true" Name="Book Title"/></p>
<p><w:LsdException Locked="false" Priority="37" Name="Bibliography"/></p>
<p><w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/></p>
<p></w:LatentStyles></p>
<p></xml><![endif]--><br />
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:1;
mso-generic-font-family:roman;
mso-font-format:other;
mso-font-pitch:variable;
mso-font-signature:0 0 0 0 0 0;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:536871559 0 0 0 415 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman","serif";
mso-fareast-font-family:"Times New Roman";}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
font-size:10.0pt;
mso-ansi-font-size:10.0pt;
mso-bidi-font-size:10.0pt;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<p><!--[if gte mso 10]></p>
<style>
<p>/* Style Definitions */</p>
<p>table.MsoNormalTable</p>
<p>{mso-style-name:"Table Normal";</p>
<p>mso-tstyle-rowband-size:0;</p>
<p>mso-tstyle-colband-size:0;</p>
<p>mso-style-noshow:yes;</p>
<p>mso-style-priority:99;</p>
<p>mso-style-qformat:yes;</p>
<p>mso-style-parent:"";</p>
<p>mso-padding-alt:0in 5.4pt 0in 5.4pt;</p>
<p>mso-para-margin:0in;</p>
<p>mso-para-margin-bottom:.0001pt;</p>
<p>mso-pagination:widow-orphan;</p>
<p>font-size:11.0pt;</p>
<p>font-family:"Calibri","sans-serif";</p>
<p>mso-ascii-font-family:Calibri;</p>
<p>mso-ascii-theme-font:minor-latin;</p>
<p>mso-fareast-font-family:"Times New Roman";</p>
<p>mso-fareast-theme-font:minor-fareast;</p>
<p>mso-hansi-font-family:Calibri;</p>
<p>mso-hansi-theme-font:minor-latin;</p>
<p>mso-bidi-font-family:"Times New Roman";</p>
<p>mso-bidi-theme-font:minor-bidi;}</p>
</style>
<p><![endif]-->w (this one is of the form returned by the Twiiter API). What we propose to do is to use jQuery&#39;s <i>GetJSON()</i> method to get the JSON Objects and use Microsoft AJAX JavaScript files to display the data on the web page. Both jQuery javascript files and Microsoft ASP.NET AJAX files are both available on the Microsoft ECN (CDN). The <i>GetJSON()</i> method as well as the Microsoft ASP.NET AJAX templates can be easily implemented in the Visual Studio 2008 IDE. Alternatively Microsoft AJAX can also be used to retrieve data from the web sites. In this article the <i>GetJSON()</i> method will be used.</p>
<pre style="margin-left: 40px;">{&quot;x&quot;:{&quot;y&quot;:[{&quot;a1&quot;:&quot;b1&quot;, &quot;c1&quot;:&quot;d1&quot;}, {&quot;a2&quot;:&quot;b2&quot;, &quot;c2&quot;:&quot;d2&quot;}]},....
 &quot;f&quot;:&quot;g&quot;,....}
</pre>
<hr color="#ff9933" noshade="noshade" size="1" />
<p>&nbsp;</p>
<div class="header">
<h1>Accessing the APIs from the intranet</h1>
<p>When you use the APIs from your browser the APIs respond in different ways. The Twitter API will respond by allowing you to download the JSON file which you can persist to a file on your local intranet. The New York Times API on the other hand will display the JSON object directly in your browser which you can persist by saving it with the JSON extension to your local intranet server. However, these APIs cannot be directly reached by the intranet due to cross-domain browser policy (The <i>same origin</i> web security model). One may use other constructs such as plug-ins that empower the browser to overstep the same domain policy, <a href="http://www2007.org/papers/paper801.pdf" target="_blank">subspacing</a>, etc. The article does not cover these aspects. In trying out these demos the user can access these APIs via browsers and persist them to their file system.</p>
<h1>Displaying data from retrieved from the APIs</h1>
<p>As previously mentioned data will be retrieved using the API URLs which are then persisted to the intranet server. The web page created using Visual Studio is then used to display data where jQuery retrieves the persisted data from the intranet which then gets displayed by the Microsoft ASP.NET Client templates. To get an initial exposure to using these tools review <a href="http://www.eggheadcafe.com/tutorials/aspnet/0c44e024-1c33-4910-b8ca-b9d5d1348f25/aspnet-ajax-on-microsoft.aspx" target="_blank">this</a> article.</p>
<h2>Data from Twitter API</h2>
<p>The next listing created using the Visual Studio 2008 shows the how the data is retrieved and displayed. One of the main things to notice is that the parsing of the JSON object to correctly display data has to be first determined. The treeview provides a hint as to how this may be accomplished. Depending on whether it is a JSON array or a JSON object the parsing will be slightly different. Also the JSON file in the Visual Studio IDE should not have line breaks. It should be preferably in an unbroken continuous line.</p>
<h3>Listing 1: Response from Twitter API displayed using Microsoft AJAX Client library</h3>
<pre style="margin-left: 40px;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
  &lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.js&quot;
  type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

  &lt;style type=&quot;text/css&quot;&gt; .sys-template { display:none; } &lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjax.debug.js&quot;&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjaxTemplates.debug.js&quot;&gt;
&lt;/script&gt;
 &lt;script&gt;
      $(document).ready(function() {
      $(&quot;#n1&quot;).css(&quot;color&quot;, &quot;red&quot;);
      $(&quot;#n2&quot;).css(&quot;color&quot;, &quot;green&quot;); 

      });
   &lt;/script&gt;
   &lt;script type=&quot;text/javascript&quot;&gt;

     var retval;
     var url_json = &quot;http://localhost/AJAXEnabledWebSite2/TwitterType2.json&quot;;

         jQuery.getJSON(url_json, function(json) {

         retval = json;
         cdn();
     });

     function cdn() {

         $create(Sys.UI.DataView, {data: retval}, null, null, $get(&#39;SList&#39;));

     }
     &lt;/script&gt;

&lt;/head&gt;

&lt;body xmlns:dataview=&quot;javascript:Sys.UI.DataView&quot;
xmlns:sys=&quot;javascript:Sys&quot;&gt;
&lt;h1&gt;Twitter Stuff&lt;/h1&gt; 

&lt;table id=&quot;SList&quot; class=&quot;sys-template&quot;
border=&quot;1&quot; style=&quot;background-color:#B0E0E6&quot; &gt;
&lt;tr&gt;      &lt;td&gt;{{as_of}}&lt;/td&gt;
          &lt;td id=&quot;n1&quot;&gt;{{trends[0].name }}&lt;/td&gt;
          &lt;td id=&quot;n2&quot;&gt;{{trends[0].url}}&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>In the above listing, the 1st three scripts are those available on the Microsoft CDN. The fourth script does the formatting for the HTML elements via jQuery. In the fifth script, the <i>GetJSON()</i> method is called to retrieve the persisted response from the Twitter API call mentioned earlier. The persisted JSON object is in file <i>TwitterType2.json</i> (it is just a text file in VS 2008 with a json extension). The function <i>cdn()</i> creates the template for display creating a dataview using the return value from the <i>getJSON</i> call. The parsed elements from the JSON object are displayed in the table. The name space attribute in the body are important and the class attribute in the table makes the initial template hidden from the user (see the style information in the &lt;head/&gt; section. Data fields retrieved from the javascript <i>$Create()</i> are pushed to the markup blocks {{}}. Please refer to an earlier article on this site. After building the project the HTML page can be displayed using the default browser as shown. The page did not display using the Opera browser (version 9.1) but displayed as shown in Mozilla Firefox, IE 8.0, Safari, Chrome and even in my one time favorite Netscape 8.1.</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msajax-article-image02.png" /></p>
<h2>Data from New York Times</h2>
<p>The New York Times API is called as previously mentioned which gives access to India related articles as of the date the call was made. The json object returned follows the general pattern as shown here. This is just the pattern to which the data adheres. The pattern is different from the one returned from Twitter.</p>
<pre style="margin-left: 40px;">{&quot;x&quot;:{&quot;y&quot;:[&quot;a1&quot;:&quot;b1&quot;,&quot;a2&quot;,&quot;b2&quot;}]},&quot;p&quot;:&quot;q&quot;,&quot;m&quot;:[&quot;n1&quot;:&quot;valn1&quot;,&quot;n2&quot;:&quot;valn2&quot;,
&quot;n3&quot;:&quot;valn3&quot;],&quot;ts&quot;:[|&quot;v&quot;,&quot;w&quot;:&quot;z&quot;],&quot;r&quot;:&quot;s&quot;}
</pre>
<p>The next listing shown here for the sake of completeness is very similar to the one used with the Twitter API except for the json file it accesses and the display of parsed content. You are also shown how to pick the data you want to display in this listing. The <i>IndiaArticles.json</i> is the name of the json data returned from the API call persisted to the intranet. The parsing of the data is very similar to the earlier Twitter example.</p>
<h3>Listing 1: Response from New York Times API displayed using Microsoft AJAX Client library</h3>
<pre style="margin-left: 40px;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
  &lt;script src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.js&quot;
  type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

  &lt;style type=&quot;text/css&quot;&gt; .sys-template { display:none; } &lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjax.debug.js&quot;&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjaxTemplates.debug.js&quot;&gt;
&lt;/script&gt;
 &lt;script&gt;
      $(document).ready(function() {
      $(&quot;#n1&quot;).css(&quot;color&quot;, &quot;red&quot;);
      $(&quot;#n2&quot;).css(&quot;color&quot;, &quot;green&quot;);
        });
   &lt;/script&gt;
   &lt;script type=&quot;text/javascript&quot;&gt;

     var retval;
     var url_json = &quot;http://localhost/AJAXEnabledWebSite2/IndiaArticles.json&quot;;

         jQuery.getJSON(url_json, function(json) {

         retval = json;
         cdn();
     });

     function cdn() {

         $create(Sys.UI.DataView, {data: retval}, null, null, $get(&#39;SList&#39;));

     }
     &lt;/script&gt;

&lt;/head&gt;

&lt;body xmlns:dataview=&quot;javascript:Sys.UI.DataView&quot;
xmlns:sys=&quot;javascript:Sys&quot;&gt;
&lt;h1&gt;New York Times Articles&lt;/h1&gt; 

&lt;table id=&quot;SList&quot; class=&quot;sys-template&quot;
border=&quot;1&quot; style=&quot;background-color:#B0E0E6&quot; &gt;
&lt;tr&gt;&lt;td&gt;{{facets}}&lt;/td&gt;
    &lt;td id=&quot;n1&quot;&gt;{{facets.publication_year[0] }}&lt;/td&gt;
    &lt;td&gt;{{facets.publication_year.count}} | {{facets.publication_year.term}}&lt;/td&gt;
    &lt;td&gt;{{offset}}&lt;/td&gt;
    &lt;td&gt;{{results[0].body}}&lt;/td&gt;
    &lt;td&gt;{{results[0].byline}}&lt;/td&gt;
    &lt;td&gt;{{results[0].date}}&lt;/td&gt;
    &lt;td&gt;{{results[0].title}}&lt;/td&gt;
    &lt;td id=&quot;l1&quot;&gt;{{results[0].url}}&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The browsed html page appears as shown in theOpera 10.0 browser.</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msajax-article-image03.png" /></p>
<h1>Summary</h1>
<p>The article described accessing data on Twitter and New York Times using jQuery and the Microsoft ASP.NET 3.5 AJAX client libraries. Both jQuery and the Microsoft AJAX are available on the Microsoft Edge Content Network.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.allfreetech.com/ajax/hacking-new-york-times-and-twitter-with-microsoft-ajax-and-jquery-139.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Web Application on JBoss AS 5</title>
		<link>http://www.allfreetech.com/java/creating-a-web-application-on-jboss-as-5-136.html</link>
		<comments>http://www.allfreetech.com/java/creating-a-web-application-on-jboss-as-5-136.html#comments</comments>
		<pubDate>Sun, 24 Jan 2010 08:14:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JBoss]]></category>

		<guid isPermaLink="false">http://www.allfreetech.com/?p=136</guid>
		<description><![CDATA[In this two-part article by Francesco Marchioni, we will be developing and configuring web applications using JBoss web container. Most developers have surely gained some experience with web applications. Therefore, we will not cover the basics of web applications; we will rather disclose how easy it can be to create a consistent web layer for [...]]]></description>
			<content:encoded><![CDATA[<p>In this two-part article by <b>Francesco Marchioni</b>, we will be developing and configuring web applications using JBoss web container. Most developers have surely gained some experience with web applications. Therefore, we will not cover the basics of web applications; we will rather disclose how easy it can be to create a consistent web layer for your applications, using just the right tools and, of course, the right technique.<span id="more-136"></span></p>
<p>We will cover the following topics in more detail:</p>
<ul>
<li>What is JSF and how to install it on JBoss AS</li>
<li>How to create a JSF facade for our pasture application</li>
<li>How to configure JBoss Web Server</li>
</ul>
<p style="margin-left: 40px; margin-right: 40px;">Wonder what was the first message sent through Internet? At 22:30 hours on October 29, 1969, a message was transmitted using ARPANET (the predecessor of the global Internet) on a host-to-host connection. It was meant to transmit &quot;login&quot;. However, it transmitted just &quot;lo&quot; and crashed.</p>
<h1>Developing web layout</h1>
<p>The basic component of any Java web application is the servlet. Born in the middle of the 90s, servlets quickly gained success against their competitors, the CGI scripts. This was because of some innovative features, especially the ability to execute requests concurrently, without the overhead of creating a new process for each request. However, a few things were missing, for example, the <b>servlet API</b> did not address any APIs specifically for creating the client GUI. This resulted in multiple ways of creating the presentation tier, generally with tag libraries that differed from job to job and from individual developers.</p>
<p>The second thing that was missing in the servlet specification was a clear distinction between the presentation tier and the backend. A plethora of web frameworks tried to fill this gap; particularly the <b>Struts</b> framework effectively realized a clean separation of the <b>model</b> (application logic that interacts with a database) from the <b>view</b> (HTML pages presented to the client) and the <b>controller</b> (instance that passes information between view and model).</p>
<p>However, the limitation of these frameworks was that even if they realized a complete modular abstraction, they still failed as they always exposed the<i>HttpServletRequest</i> and <i>HttpServletSession</i>objects to their action(s). Their actions, in turn, needed to accept the interface contracts such as <i>ActionForm</i>,<i> ActionMapping</i>, and so on.</p>
<p>The JavaServer Faces that emerged on the stage a few years later pursued a different approach. Unlike request-driven <b>Model&ndash;View&ndash;Controller (MVC)</b> web frameworks, JSF chose a component-based approach that ties the user interface component to a well-defined request processing lifecycle. This greatly simplifies the development of web applications.</p>
<p>The JSF specification allows you to have presentation components be POJOs. This creates a cleaner separation from the servlet layer and makes it easier to do testing by not requiring the POJOs to be dependent on the servlet classes.</p>
<p>In the following sections, we will describe how to create a web layout for our application store using the JSF technology. For an exhaustive explanation of the JSF framework, we suggest you to surf the JSF homepage at <a href="http://java.sun.com/javaee/javaserverfaces/" target="_blank">http://java.sun.com/javaee/javaserverfaces/</a>.</p>
<h2>Installing JSF on JBoss AS</h2>
<p>JBoss AS already ships with the JSF libraries, so the good news is that you don&#39;t need to download or install them in the application server. There are different implementations of the JSF libraries. Earlier JBoss releases adopted the <b>Apache MyFaces</b> library. JBoss AS 4.2 and 5.x ship with the <b>Common Development and Distribution License</b> (<b>CDDL</b>) implementation (now called &quot;Project Mojarra&quot;) of the JSF 1.2 specification that is available from the java.net open source community.</p>
<p style="margin-left: 40px; margin-right: 40px;"><em>Switching to another JSF implementation is anyway possible. All you have to do is package your JSF libraries with your web application and configure your <i>web.xml</i> to ignore the JBoss built-in implementation:</em></p>
<pre style="margin-left: 40px;">&lt;context-param&gt;
&lt;param-name&gt;org.jboss.jbossfaces.WAR_BUNDLES_JSF_
IMPL&lt;/param-name&gt;
&lt;param-value&gt;true&lt;/param-value&gt;
&lt;/context-param&gt;
</pre>
<p>We will start by creating a new JSF project. From the <b>File</b> menu, select <b>New</b> | <b>Other</b> | <b>JBoss Tools Web</b> | <b>JSF</b> | <b>JSF Web project</b>. The JSF applet wizard will display, requesting the <b>Project Name</b>, the <b>JSF Environment</b>, and the default starting <b>Template</b>.</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/jboss5-article1-image01.png" /></p>
<p>Choose <b>AppStoreWeb</b> as the project name, and check that the <b>JSF Environment</b> used is <b>JSF 1.2</b>. You can leave all other options to the defaults and click <b>Finish</b>. Eclipse will now suggest that you switch to the <b>Web Projects</b> view that logically assembles all JSF components. (It seems that the current release of the plugin doesn&#39;t understand your choice, so you have to manually click on the <b>Web Projects</b> tab.)</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/jboss5-article1-image02.png" /></p>
<p>The key configuration file of a JSF application is faces-config.xml contained in the Configuration folder. Here you declare all <b>navigation rules</b> of the application and the <b>JSF managed beans</b>. Managed beans are simple POJOs that provide the logic for initializing and controlling JSF components, and for managing data across page requests, user sessions, or the application as a whole.</p>
<p>Adding JSF functionalities also requires adding some information to your <i>web.xml</i> file so that all requests ending with a certain suffix are intercepted by the <i>Faces Servlet</i>. Let&#39;s have a look at the <i>web.xml</i> configuration file:</p>
<pre style="margin-left: 40px;">&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;web-app version=&quot;2.5&quot; xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot;
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;&gt;

&lt;display-name&gt;AppStoreWeb&lt;/display-name&gt;
&lt;context-param&gt;
&lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;
&lt;param-value&gt;server&lt;/param-value&gt;
&lt;/context-param&gt;
&lt;context-param&gt; [1]
&lt;param-name&gt;com.sun.faces.
enableRestoreView11Compatibility&lt;/param-name&gt;
&lt;param-value&gt;true&lt;/param-value&gt;
&lt;/context-param&gt;
&lt;listener&gt;
&lt;listener-class&gt;com.sun.faces.config.
ConfigureListener&lt;/listener-class&gt;
&lt;/listener&gt;
&lt;!-- Faces Servlet --&gt;
&lt;servlet&gt;
&lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
&lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
&lt;/servlet&gt;
&lt;!-- Faces Servlet Mapping --&gt;
&lt;servlet-mapping&gt;
&lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
&lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
&lt;login-config&gt;
&lt;auth-method&gt;BASIC&lt;/auth-method&gt;
&lt;/login-config&gt;
&lt;/web-app&gt;
</pre>
<p style="margin-left: 40px; margin-right: 40px;"><em>The context-param pointed out here <b>[1]</b> is not added by default when you create a JSF application. However, it needs to be added, else you&#39;ll stumble into an annoying ViewExpiredException when your session expires (JSF 1.2).</em></p>
<h2>Setting up navigation rules</h2>
<p>In the first step, we will define the navigation rules for our AppStore. A minimalist approach would require a homepage that displays the orders, along with two additional pages for inserting new customers and new orders respectively.</p>
<p>Let&#39;s add the following navigation rule to the <i>faces-config.xml</i>:</p>
<pre style="margin-left: 40px;">&lt;faces-config&gt;
&lt;navigation-rule&gt;
&lt;from-view-id&gt;/home.jsp&lt;/from-view-id&gt; [1]
&lt;navigation-case&gt;
&lt;from-outcome&gt;newCustomer&lt;/from-outcome&gt; [2]
&lt;to-view-id&gt;/newCustomer.jsp&lt;/to-view-id&gt;
&lt;/navigation-case&gt;
&lt;navigation-case&gt;
&lt;from-outcome&gt;newOrder&lt;/from-outcome&gt; [3]
&lt;to-view-id&gt;/newOrder.jsp&lt;/to-view-id&gt;
&lt;/navigation-case&gt;
&lt;/navigation-rule&gt;
&lt;navigation-rule&gt;
&lt;from-view-id&gt;&lt;/from-view-id&gt; [4]
&lt;navigation-case&gt;
&lt;from-outcome&gt;home&lt;/from-outcome&gt;
&lt;to-view-id&gt;/home.jsp&lt;/to-view-id&gt;
&lt;/navigation-case&gt;
&lt;/navigation-rule&gt;
&lt;/faces-config&gt;
</pre>
<p>In a navigation rule, you can have one <i>from-view-id</i> that is the (optional) starting page, and one or more landing pages that are tagged as <i>to-view-id</i>. The <i>from-outcome</i> determines the navigation flow. Think about this parameter as a Struts forward, that is, instead of embedding the landing page in the JSP/servlet, you&#39;ll simply declare a virtual path in your JSF beans.</p>
<p>Therefore, our starting page will be <i>home.jsp</i> <b>[1]</b> that has two possible links&mdash;the <i>newCustomer.jsp</i> form <b>[2]</b> and the <i>newOrder.jsp</i> form <b>[3]</b>. At the bottom, there is a navigation rule that is valid across all pages <b>[4]</b>. Every page requesting the home outcome will be redirected to the homepage of the application.</p>
<p>The above JSP will be created in a minute, so don&#39;t worry if Eclipse validator complains about the missing pages. This configuration can also be examined from the <b>Diagram</b> tab of your <i>faces-config.xml</i>:</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/jboss5-article1-image03.png" /></p>
<p>The next piece of code that we will add to the confi guration is the JSF managed bean declaration. You need to declare each bean here that will be referenced by JSF pages. Add the following code snippet at the top of your <i>faces-config.xml</i> (just before navigation rules):</p>
<pre style="margin-left: 40px;">&lt;managed-bean&gt;
&lt;managed-bean-name&gt;manager&lt;/managed-bean-name&gt; [1]
&lt;managed-bean-class&gt;
com.packpub.web.StoreManagerJSFBean
&lt;/managed-bean-class&gt; [2]
&lt;managed-bean-scope&gt;request&lt;/managed-bean-scope&gt; [3]
&lt;/managed-bean&gt;
</pre>
<p>The <i>&lt;managed-bean-name&gt;</i> <b>[1]</b> element will be used by your JSF page to reference your beans. The <i>&lt;managed-bean-class&gt;</i> <b>[2]</b> is obviously the corresponding class. The managed beans can then be stored within the request, session, or application scopes, depending on the value of the <i>&lt;managed-bean-scope&gt;</i> element <b>[3]</b>.</p>
<h2>Adding a JSF managed bean</h2>
<p>The <i>StoreManagerJSFBean</i> class follows the JavaBean patterns, providing get and <i>set</i> methods for its properties (to make the code more maintainable, we have skipped the <i>getter</i>/<i>setter</i> methods that simply wrap the fields of the class). We have declared the bean as request bound, so for each user of the application, JSF creates a <i>StoreManagerJSFBean</i> instance, which is stored within the <i>request</i> scope.</p>
<p>Add to your project a new Java class and name it <i>com.packtpub.web.StoreManagerJSFBean</i>:</p>
<pre style="margin-left: 40px;">package com.packpub.web;
// skipping imports
public class StoreManagerJSFBean {
@EJB(mappedName = &quot;AppStoreEJB/local&quot;) [1]
private StoreManager storeManager;
private int customerId;
private int orderQuantity;
private int orderPrice;
private String customerName;
private String customerCountry;
private String orderProduct;
List&lt;Order&gt; listOrders;
List &lt;SelectItem&gt; listCustomers;
public List&lt;SelectItem&gt; getListCustomers() {
if (listCustomers == null) {
listCustomers= new ArrayList();
findAllCustomers();
}
return listCustomers;
}
/*
other getter/setter methods omitted for brevity
*/
public StoreManagerJSFBean() { }
public void findOrders() { [2]
listOrders = storeManager.findAllItems(this.customerId);
}
public void findAllCustomers() {
List&lt;Customer&gt; listCustomersEJB =
storeManager.findAllCustomers();
for(Customer customer:listCustomersEJB) {
listCustomers.add(new
SelectItem(customer.getId(),customer.getName()));
}
}
}
public void saveOrder() {
storeManager.saveOrder(customerId,this.orderPrice,
this.orderQuantity,this.orderProduct);
FacesMessage fm = new FacesMessage(&quot;Saved order for
&quot;+this.orderQuantity+ &quot; of &quot;+this.orderProduct);
FacesContext.getCurrentInstance().addMessage(&quot;Message&quot;, fm);
this.orderPrice=0;
this.orderQuantity=0;
this.orderProduct=null;
}
public void insertCustomer() {
storeManager.createCustomer(this.customerCountry,
this.customerName);
FacesMessage fm = new FacesMessage(&laquo;Created Customer
&laquo;+this.customerName+ &laquo; fromf &laquo;+this.customerCountry);
FacesContext.getCurrentInstance().addMessage(&quot;Message&quot;, fm);
this.customerName=null;
this.customerCountry=null;
// Forces customer reloading
this.listCustomers=null;
}
/* Navigation rules */
public String home() { [4]
return &quot;home&quot;;
}
public String newOrder() {
return &quot;newOrder&quot;;
}
public String newCustomer() {
return &quot;newCustomer&quot;;
}
}
</pre>
<p>As you can see, the <i>StoreManagerJSFBean</i> references the session bean we have created previously (<i>StoreManager</i>). Therefore, we must tell the compiler how to solve this dependency. This can be easily solved by choosing <b>Properties</b> on the current project, and then choosing Projects from the <b>Java Build Path</b> option. Add the project <b>AppStore</b> to your build path, as shown here:</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/jboss5-article1-image04.png" /></p>
<p>Having fixed the compilation issues, we can now concentrate on the JSF bean. The first thing we want to capture your attention to is how the <i>StoreManager</i> EJB is injected <b>[1]</b> in the class, skipping completely the lookup/casting/exception handling part.</p>
<p>The <i>findOrders()</i> method <b>[2]</b> retrieves the list of orders from the <i>StoreManager</i> EJB. They will be displayed later in the <i>dataTable </i>component.</p>
<p>The <i>findAllCustomers()</i> <b>[3]</b> is slightly different. It recalls our entity bean&#39;s corresponding <i>findAllCustomers()</i> method and then populates a <i>SelectItem</i> object with the list of customers. <i>SelectItem</i> is a JSF object used to render a combobox programmatically. In our case, we will populate it with the <i>customerId</i> (as value) and <i>customerName</i> (as label).</p>
<p>The remaining EJB wrapper methods, <i>saveOrder()</i> and <i>insertCustomer()</i>, are quite intuitive; their job is to persist data for <i>Orders</i> and <i>Customers</i>.</p>
<p>The final piece of code is about navigation rules <b>[4]</b> that are coded as simple Java methods returning the outcome view as a string. For example, in order to return to the homepage from any other page, we will add the following button:</p>
<pre style="margin-left: 40px;">&lt;h:commandButton action=&quot;#{manager.home}&quot; value=&quot;Back&quot; /&gt;
</pre>
<h2>Setting up the view</h2>
<p>Setting up the view JSF pages are just behind-the-scenes JSP pages that are engineered by the JSF servlet. Therefore, in order to create your views, add the following pages to your web application: <i>home.jsp</i>, <i>newCustomer.jsp</i> and <i>newOrder.jsp</i>. A new JSP page can be added from the <b>Web Projects</b> menu by right-clicking on the <i>WebContent</i> folder, then choosing <b>New</b> | <b>File</b> | <b>JSP Page</b> and naming it <i>home.jsp</i>.</p>
<pre style="margin-left: 40px;">&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/html&quot; prefix=&quot;h&quot;%&gt; [1]
&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/core&quot; prefix=&quot;f&quot;%&gt;
&lt;html&gt;
&lt;body&gt;
&lt;f:view&gt; [2]
&lt;style type=&quot;text/css&quot;&gt; [3]
@import url(&quot;css/appstore.css&quot;);
&lt;/style&gt;
&lt;h:panelGrid columns=&quot;1&quot; border=&quot;1&quot; styleClass=&quot;spring&quot;&gt; [4]
&lt;f:facet name=&quot;header&quot;&gt;
&lt;h:outputText value=&quot;Order List&quot;/&gt;
&lt;/f:facet&gt;
&lt;h:form id=&quot;listOrdersForm&quot;&gt; [5]
&lt;h:outputText value=&quot;Select Customer:&quot; /&gt; [6]
&lt;h:selectOneMenu id=&quot;selectCustomer&quot;
value=&quot;#{manager.customerId}&quot; styleClass=&quot;buttons&quot;&gt; [7]
&lt;f:selectItems
value=&quot;#{manager.listCustomers}&quot; /&gt;
&lt;/h:selectOneMenu&gt;
&lt;h:commandButton action=&quot;#{manager.findOrders}&quot;
value=&quot;ListOrders&quot; styleClass=&quot;buttons&quot;/&gt; [8]
&lt;h:dataTable value=&quot;#{manager.listOrders}&quot; var=&quot;orders&quot;
border=&quot;1&quot; rowClasses=&quot;row1, row2&quot; headerClass=&quot;header&quot;&gt; [9]
&lt;h:column&gt;
&lt;f:facet name=&quot;header&quot;&gt;
&lt;h:outputText value=&quot;Product&quot; /&gt;
&lt;/f:facet&gt;
&lt;h:outputText value=&quot;#{orders.product}&quot; /&gt;
&lt;/h:column&gt;
&lt;h:column&gt;
&lt;f:facet name=&quot;header&quot;&gt;
&lt;h:outputText value=&quot;Price&quot; /&gt;
&lt;/f:facet&gt;
&lt;h:outputText value=&quot;#{orders.price}&quot; /&gt;
&lt;/h:column&gt;
&lt;h:column&gt;
&lt;f:facet name=&quot;header&quot;&gt;
&lt;h:outputText value=&quot;Quantity&quot; /&gt;
&lt;/f:facet&gt;
&lt;h:outputText value=&quot;#{orders.quantity}&quot; /&gt;
&lt;/h:column&gt;
&lt;/h:dataTable&gt;
&lt;h:commandButton action=&quot;#{manager.newCustomer}&quot;
value=&quot;Insert Customer&quot; styleClass=&quot;buttons&quot; /&gt; [10]
&lt;h:commandButton action=&quot;#{manager.newOrder}&quot;
value=&quot;Insert Order&quot; styleClass=&quot;buttons&quot; /&gt; [11]
&lt;/h:form&gt;
&lt;/h:panelGrid&gt;
&lt;/f:view&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>JSF contains two tag libraries <b>[1]</b> called JSF core and HTML Basic. The former provides a few general tags and some other tags that let you register validators and event listeners to UI components. The latter contains JSP tags that render HTML UI components such as buttons, text fields, checkboxes, lists, and so on. The standard prefixes of these two tag libraries are <i>h</i> and <i>f</i>, and they are declared at the beginning of <i>home.jsp</i>.</p>
<p>The <i>view</i> tag <b>[2]</b> is the container for all JavaServer Faces component tags used on a page. <b>Stylesheets [3]</b> are used here to decorate the UI components. The <i>panelGrid</i> <b>[4]</b> component simplifies the task of constructing a layout table, to hold form fields, labels, and buttons. In this case, it will contain the main input form.</p>
<p>The <i>form</i> element <b>[5]</b> manages an HTML form just the same way as standard form HTML. Rendering simple text on the page can be achieved with an <i>outputText </i>tag <b>[6]</b>. Here, you can use value-binding expressions from your JSF beans.</p>
<p>The <i>selectOneMenu</i> element <b>[7]</b> is used to display an HTML combobox that is bound to a bean collection. Review the <i>findAllCustomers()</i> method of your <i>StoreManagerJSFBean</i>, where the combobox is built dynamically.</p>
<p>The <i>commandButton</i> <b>[8]</b> is applied to render an HTML button. In our case, we have bound the button to the <i>findOrders()</i> method of our JSF bean.</p>
<p>A core JSF tag is the <i>dataTable</i> tag <b>[9]</b> that can be used to render an HTML table using a collection from the backing bean. This component is generally used to display tabular data and it offers a vast choice of built-in options for customizing its header and footer, and for paginating the table.</p>
<p>The last two buttons, <b>[10]</b> and <b>[11]</b>, plot the route to the <i>newCustomer</i> and <i>newOrder</i> forms.</p>
<p>The form for inserting a new customer is as follows:</p>
<pre style="margin-left: 40px;">&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/html&quot; prefix=&quot;h&quot;%&gt;
&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/core&quot; prefix=&quot;f&quot;%&gt;
&lt;html&gt;
&lt;body&gt;
&lt;f:view&gt;
&lt;style type=&quot;text/css&quot;&gt;
@import url(&quot;css/appstore.css&quot;);
&lt;/style&gt;
&lt;h:form id=&quot;newCustomer&quot;&gt;
&lt;h:panelGrid columns=&quot;2&quot; border=&quot;1&quot; styleClass=&quot;spring&quot;&gt;
&lt;f:facet name=&quot;header&quot;&gt;
&lt;h:outputText value=&quot;Insert new Customer&quot; /&gt;
&lt;/f:facet&gt;
&lt;h:outputText value=&quot;Name&quot; /&gt;
&lt;h:inputText value=&quot;#{manager.customerName}&quot; /&gt; [1]
&lt;h:outputText value=&quot;Country&quot; /&gt;
&lt;h:inputText value=&quot;#{manager.customerCountry}&quot; /&gt;
&lt;h:commandButton action=&quot;#{manager.insertCustomer}&quot; [2]
value=&quot;Insert Customer&quot; /&gt;
&lt;h:commandButton action=&quot;#{manager.home}&quot; value=&quot;Back&quot; /&gt;
&lt;/h:panelGrid&gt;
&lt;h:messages /&gt;
&lt;/h:form&gt;
&lt;/f:view&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>The <i>inputText</i> fields <b>[1]</b> are used to populate the individual managed bean properties. With the <i>commandButton</i> <b>[2]</b>, the <i>insertCustomer()</i> action is recalled, thus inserting a new customer. This is the last JSP needed for our example <i>newOrder.jsp</i>:</p>
<pre style="margin-left: 40px;">&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/html&quot; prefix=&quot;h&quot;%&gt;
&lt;%@ taglib uri=&quot;http://java.sun.com/jsf/core&quot; prefix=&quot;f&quot;%&gt;
&lt;html&gt;
&lt;body&gt;
&lt;f:view&gt;
&lt;style type=&quot;text/css&quot;&gt;
@import url(&quot;css/appstore.css&quot;);
&lt;/style&gt;
&lt;h:form id=&quot;newOrder&quot;&gt;
&lt;h:panelGrid columns=&quot;2&quot; border=&quot;1&quot; styleClass=&quot;spring&quot;&gt;
&lt;f:facet name=&quot;header&quot;&gt;
&lt;h:outputText value=&quot;Insert new Order&quot; /&gt;
&lt;/f:facet&gt;
&lt;h:outputText value=&quot;Product&quot; /&gt;
&lt;h:inputText value=&quot;#{manager.orderProduct}&quot; /&gt;
&lt;h:outputText value=&quot;Quantity&quot; /&gt;
&lt;h:inputText value=&quot;#{manager.orderQuantity}&quot; /&gt;
&lt;h:outputText value=&quot;Price&quot; /&gt;
&lt;h:inputText value=&quot;#{manager.orderPrice}&quot; /&gt;
&lt;h:outputText value=&quot;Customer&quot; /&gt;
&lt;h:selectOneMenu id=&quot;selectCustomerforOrder&quot;
value=&quot;#{manager.customer}&quot;&gt;
&lt;f:selectItems value=&quot;#{manager.listCustomers}&quot; /&gt;
&lt;/h:selectOneMenu&gt;
&lt;h:commandButton action=&quot;#{manager.saveOrder}&quot;
value=&quot;Save Order&quot; /&gt;
&lt;h:commandButton action=&quot;#{manager.home}&quot; value=&quot;Back&quot; /&gt;
&lt;/h:panelGrid&gt;
&lt;h:messages /&gt;
&lt;/h:form&gt;
&lt;/f:view&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>Assembling and deploying the application</h2>
<p>So far, you have got two standalone projects, one EJB project and one web project. While you could technically deploy them separately, it is worth combining them in an <b>Enterprise ARchive</b> (<b>EAR</b>). The most obvious reason for deploying the application as an Enterprise ARchive is that the web application will be loaded by a <i>ClassLoader</i> in the same hierarchy as the EJB classloader. In short, you don&#39;t need to provide the EJB interfaces to the web application, as you would for a standalone application.</p>
<p>Packaging the application can be done entirely by Eclipse, without messing with archive files. From the menu, select <b>New</b> | <b>Other</b> | <b>Java EE</b> | <b>Enterprise Application project</b>. The next facet will request the <b>Project name</b> and a few details about the configuration. Your archive name will be, by default, the project name plus the extension <i>.ear</i>. Verify that both <b>Target Runtime</b> and the <b>Configuration</b> point correctly to the JBoss 5.0 environment.</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/jboss5-article1-image05.png" /></p>
<p>Click <b>Next</b>. On the window that follows, you can select the components of your archive application, that is, the <b>AppStore</b> application and the <b>AppStoreWeb</b> component. Check the option <b>Generate Deployment Descriptor</b>.</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/jboss5-article1-image06.png" /></p>
<p>Verify that <i>META-INF/application.xml</i> deployment descriptors contain both the modules enlisted below:</p>
<pre style="margin-left: 40px;">&lt;application&gt;
&lt;display-name&gt;EnterpriseStore&lt;/display-name&gt;
&lt;module&gt;
&lt;web&gt;
&lt;web-uri&gt;AppStoreWeb.war&lt;/web-uri&gt;
&lt;context-root&gt;AppStoreWeb&lt;/context-root&gt;
&lt;/web&gt;
&lt;/module&gt;
&lt;module&gt;
&lt;ejb&gt;AppStore.jar&lt;/ejb&gt;
&lt;/module&gt;
&lt;/application&gt;
</pre>
<p>Okay, now you need only a few more laps to complete the race. Let&#39;s deploy the process to JBoss by switching on the <b>JBoss Server View</b>. Right-click on the JBoss server and select <b>Add and remove projects</b>. Add the <b>EnterpriseStore</b> to the configured projects.</p>
<p>Now deploy the application in the usual way. Right-click on the <b>EnterpriseStore</b> and select <b>Full Publish</b> (at the time of writing, JBoss 5 doesn&#39;t support partial deployment of this component).</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/jboss5-article1-image07.png" /></p>
<p>Verify from the console that the application has been deployed correctly.</p>
<h3>Running the store</h3>
<p>The application gateway will be <i>home.jsf</i> page. Point the browser to the location <i>http://localhost:8080/AppStoreWeb/home.jsf</i>.</p>
<p>Testing the application is quite simple. First add some customers and then link some orders to the customers. In the <i>home.jsf</i> page, check that the orders are correctly listed from the datagrid.</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/jboss5-article1-image08.png" /></p>
<p style="margin-left: 40px; margin-right: 40px;"><em><b>A last trick</b><br />
	Usually web applications ship with a <b>welcome file list</b> so that you don&#39;t have to remember anything else besides the web context. If you have already tried to add home.jsf to the welcome file list (in web.xml), you would have noticed that it doesn&#39;t work. Actually, Tomcat is a bit stubborn and requires a trick to set a JSF page as a welcome file. First, add the following to your web.xml:</em></p>
<pre style="margin-left: 40px;">&lt;welcome-file-list&gt;
&lt;welcome-file&gt;home.jsf&lt;/welcome-file&gt;
&lt;/welcome-file-list&gt;
</pre>
<p style="margin-left: 40px; margin-right: 40px;"><em>Then create an empty <i>home.jsf</i> page in your web context root. This will trick Tomcat to detect <i>home.jsf</i> as the welcome file and will load <i>home.jsp</i> instead.</em></p>
<h1>Summary</h1>
<p>This two-part article on creating a web application is about developing and configuring web applications on JBoss AS 5.0 using the JSF cutting-edge technology. In this part of the article we have enhanced the Appstore Enterpirse application by adding a web layer to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.allfreetech.com/java/creating-a-web-application-on-jboss-as-5-136.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with Microsoft Dynamics AX and .NET: Part 2</title>
		<link>http://www.allfreetech.com/microsoft-net/working-with-microsoft-dynamics-ax-and-net-part-2-134.html</link>
		<comments>http://www.allfreetech.com/microsoft-net/working-with-microsoft-dynamics-ax-and-net-part-2-134.html#comments</comments>
		<pubDate>Sun, 24 Jan 2010 08:09:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Microsoft .Net]]></category>
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.allfreetech.com/?p=134</guid>
		<description><![CDATA[Add a reference to .NET Business Connector
In the next example, we create a new project in Visual Studio and add the reference to the project. You can skip this step if you already have a project where you would like to use the .NET Business Connector.
Open Visual Studio and create a new project as shown [...]]]></description>
			<content:encoded><![CDATA[<h1>Add a reference to .NET Business Connector</h1>
<p>In the next example, we create a new project in Visual Studio and add the reference to the project. You can skip this step if you already have a project where you would like to use the .NET Business Connector.</p>
<p>Open Visual Studio and create a new project as shown in the next screenshot:</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msax-article1-image05.png" /></p>
<p>When you click on <b>OK</b>, you will have a new C# file called <i>Program.cs</i>. Before we start writing any code in the file, we have to add the .NET Business Connector as a reference.</p>
<p>In the Solution Explorer right-click on the <b>References</b> node and select <b>Add Reference</b>.</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msax-article1-image06.png" /></p>
<p>In the form that opens select <b>Microsoft.Dynamics.BusinessConnectorNet.dll</b> under the Browse tab.</p>
<p>The file is found in the <i>ClientBin</i> catalog of your AX installation. The default path is:</p>
<p><i>C:Program FilesMicrosoft Dynamics Ax50ClientBin</i></p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msax-article1-image07.png" /></p>
<p>Click on <b>OK</b> and note that the reference has now been added under the <b>References</b> node in the <b>Solution Explorer</b>.</p>
<h1>Using the .NET Business Connector in .NET classes</h1>
<p>In the next sections of this article we will look at some examples that show how we can use methods in the .NET Business Connector to call AX methods, insert data into AX tables, and read data from AX tables.</p>
<h2>Calling a static class method in AX</h2>
<p>You now have to go back to AX, open the AOT and find the <b>Global</b> class. Add the following method to the <b>Global</b> class:</p>
<pre style="margin-left: 40px;">static str AxHelloWorld()
{
    return &quot;HelloWorld!&quot;;
}
</pre>
<p>In the Visual Studio project we open the <i>Program.cs</i> file again and enter the following code that will create a connection to AX through the .NET Business Connector. We then call the method we created in the Global class before it prints the result to the console:</p>
<p>
	&nbsp;</p>
<pre style="margin-left: 40px;">using System;
using Microsoft.Dynamics.BusinessConnectorNet;
namespace GetAxInfo1
{
    class Program
    {
        /// &lt;summary&gt;
        /// This class connects to AX throught the
        /// .NET Business Connector and call the static method
        /// AxHelloWorld in the Global class in AX.
        /// The result is sent to the console (command prompt).
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;args&quot;&gt;&lt;/param&gt;
        static void Main(string[] args)
        {
            Axapta ax;
            Object axObject;
            try
            {
                // Create a new Axapta object.
                ax = new Axapta();
                // Logon using the default settings
                // in the AX configuration for the .NET
                // Business Connector
                ax.Logon(null, null, null, null);
                // Call the static method and return the
                // result to the axObject variable
                axObject =
                  ax.CallStaticClassMethod(&quot;Global&quot;, &quot;AxHelloWorld&quot;);
                // Print the result to the console
                Console.WriteLine(&quot;The message from AX is {0}&quot;,
                  axObject.ToString());
                ax.Logoff();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
    }
}
</pre>
<p>Execute the program by pressing <i>Ctrl + F5</i>. You should now see the following result in the console (command prompt) that opens up:</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msax-article1-image08.png" /></p>
<p>If you get a different result it might be because you haven&#39;t set up the .NET Business Connector correctly. If so, please refer to the installation guide to set it up properly. Also, check the Windows Event Viewer to see if there are any error messages that can lead you in the right direction.</p>
<h2>Insert data into an AX table</h2>
<p>As mentioned earlier in this article, you can use the methods in some of the marshaled classes in the .NET Business Connector to manipulate data. However, it is better to avoid this and instead have AX handle all data selection and manipulation. It would be even better to have your .NET application call a method in AX that does the job and returns the results back to the .NET application again. However, this is not always feasible, for instance, when you would like to insert records from your .NET application to an AX table. The next section will guide you through the steps needed to achieve this.</p>
<p>First, you should create a new project in Visual Studio as we did earlier in this article. In this example, we will call the new project &quot;InsertAxRecord&quot;.</p>
<p>Then you have to add a reference to the .NET Business Connector.</p>
<p>In the <i>Program.cs</i> file (or whatever you call your file), you write something like this:</p>
<pre style="margin-left: 40px;">using System;
using Microsoft.Dynamics.BusinessConnectorNet;
namespace InsertAxRecord
{
    class Program
    {
        static void Main(string[] args)
        {
            Axapta ax;
            AxaptaRecord record;
            try
            {
                // Create AX object and logon to AX
                ax = new Axapta();
                ax.Logon(null, null, null, null);
                // Create a new AxaptaRecord object with
                // the name of the table as input parameter
                using (record = ax.CreateAxaptaRecord(&quot;CarTable&quot;))
                {
                    // Remember to clear the tablebuffer if
                    // you are inserting inside a loop
                    record.Clear();
                    record.InitValue();
                    // Set the fields in the table
                    record.set_Field(&quot;CARID&quot;, &quot;XXX1&quot;);
                    record.set_Field(&quot;MODELYEAR&quot;, 1998);
                    record.set_Field(&quot;CARBRAND&quot;, &quot;FORD&quot;);
                    record.set_Field(&quot;MODEL&quot;, &quot;F1&quot;);
                    record.set_Field(&quot;MILEAGE&quot;, 89378);
                    // Insert the record
                    record.Insert();
                }
                // End the AX session
                ax.Logoff();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}
</pre>
<p>
	&nbsp;</p>
<p>If you open the table browser and look at the contents of <b>CarTable</b> in AX now (find the table in the AOT and pressing <i>Ctrl + O</i> to open the table browser) you should see that the record has been added.</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msax-article1-image09.png" /></p>
<h2>Read data from an AX table</h2>
<p>For our next example we will repeat the procedure from the previous example, except that now we will read data from the table instead of writing to the table.</p>
<p>Start off by creating a new project and add the .NET Business Connector as&nbsp; a reference to the solution.</p>
<p>Enter the following code into the <i>Program.cs</i> file (or whatever you call your program):</p>
<pre style="margin-left: 40px;">using System;
using Microsoft.Dynamics.BusinessConnectorNet;
namespace ReadAxRecord
{
    class Program
    {
        static void Main(string[] args)
        {
            Axapta ax;
            AxaptaRecord record;
            Object carId, carBrand, model, modelYear, mileage;
            try
            {
                // Create AX object and logon to AX
                ax = new Axapta();
                ax.Logon(null, null, null, null);
                // Create an AxaptaRecord object from the
                // table that will be used
                using (record = ax.CreateAxaptaRecord(&quot;CarTable&quot;))
                {
                    // Execute the statement entered as parameter
                    record.ExecuteStmt(&quot;select * from %1
                      where %1.CarBrand like &#39;BMW&#39;&quot;);
                    // Loop through the result of the statement.
                    while (record.Found)
                    {
                        // Set our local variables to be
                        // equal to the fields in the table
                        // for the current record.
                        carId = record.get_Field(&quot;CARID&quot;);
                        carBrand = record.get_Field(&quot;CARBRAND&quot;);
                        model = record.get_Field(&quot;MODEL&quot;);
                        modelYear = record.get_Field(&quot;MODELYEAR&quot;);
                        mileage = record.get_Field(&quot;MILEAGE&quot;);
                        // Write the result to the console
                        Console.WriteLine(carId + &quot;t&quot; +
                                          carBrand + &quot;t&quot; +
                                          model + &quot;t&quot; +
                                          modelYear + &quot;t&quot; +
                                          mileage);
                        // Go to the next record in the result set
                        record.Next();
                    }
                    // End the AX session
                    ax.Logoff();
                    // Make sure the console stays up
                    // until a key is pressed
                    Console.ReadKey();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}
</pre>
<p>Execute the program by pressing <i>Ctrl + F5</i> and take a look at the result. It should look something like this:</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msax-article1-image10.png" /></p>
<h2>Exception classes</h2>
<p>The .NET Business Connector also consists of a number of exceptions that AX can raise. These exceptions are controlled by exception classes that will help you determine further actions if an exception occurs. In the previous example I have only used the standard .NET exception class, but if you would like to write solid code you should consider using the exceptions from the .NET Business Connector instead.</p>
<p>
	&nbsp;</p>
<p>
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
</p>
<table align="center" border="1" bordercolor="#000000" cellpadding="7" cellspacing="0" style="page-break-before: always;" width="639">
<col width="304" />
<col width="305" />
<tbody>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2"><b>Exception </b></font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2"><b>Description</b></font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">AlreadyLoggedOnException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when logon to AX fails because the </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">user is already logged on.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">AxBufferNotValidException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the AX buffer being referenced is </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">not valid.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">AxContainerNotValidException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the AX container being </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">referenced is not valid.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">AxObjectNotValidException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the AX object being referenced is </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">not valid.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">AxRecordNotValidException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the AX record being referenced </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">is not valid.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">BusinessConnectorException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when an unexpected error has </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">occurred with the Business Connector.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">ConnectionLostException</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">Thrown when the connection to the AOS is lost.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">DebuggerStopException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the AX debugger has been </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">stopped.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">ExecutionErrorException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when an unexpected system exception </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">has occurred.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">FatalErrorLoggedOffException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the AX session is closed due to </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">an error.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">InitializationFailedException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the .NET Business Connector </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">fails to initialize.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">InvalidReturnValueException</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">Thrown when a return value is invalid.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">LogonAsGuestNotSupportedException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when trying to logon as Guest from a </font></font></p>
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">non-web (IIS) scenario, for example, directly </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">through .NET Business Connector.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">LogonFailedException</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">Thrown during an AX logon failure.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">LogonSystemChangedException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when logon to AX fails due to logon </font></font></p>
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">parameters not matching those currently in use </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">for the Business Connector.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">LogonUserLockedOutException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the user attempting a logon is </font></font></p>
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">locked out due to exceeding the maximum </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">number of logon attempts.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">MethodUnknownException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the method being referenced is </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">not known by the system.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">NoIISRightsException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when logon to AX fails because the </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">user has not been granted the proper IIS rights.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">NoSecurityKeyException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when a requested operation fails </font></font></p>
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">because the required security key does not </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">exist.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">NotLoggedOnException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when a requested operation cannot be </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">performed because the user is not logged on.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">PermissionDeniedException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when permission to execute an </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">operation is denied.</font></font></p>
</td>
</tr>
</tbody>
</table>
<p>
	&nbsp;</p>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td valign="top">
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
<table align="center" border="1" bordercolor="#000000" cellpadding="7" cellspacing="0" style="page-break-before: always;" width="639">
<col width="304" />
<col width="305" />
<tbody>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">ServerCommunicationErrorException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when communication between the </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">client computer and the server fails.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">ServerOutOfReachException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when communication with the server </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">cannot be established.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">ServerOutOfResourcesException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the server terminates the session </font></font></p>
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">due to the server not having enough free </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">resources.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">ServerUnavailableException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the server is unavailable. AX will </font></font></p>
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">attempt to connect to other servers listed in the </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">client confguration.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">SessionTerminatedException</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">Thrown when the server terminates the session.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">UnknownClassHandleException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the class being referenced does </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">not exist.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">UnknownRecordException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when the record being referenced does </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">not exist.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">UnknownTextException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when an unknown text exception has </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">occurred.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">UnknownXPPClassException</font></font></p>
</td>
<td width="305">
<p style="margin-bottom: 0in;"><font face="Verdana, sans-serif"><font size="2">Thrown when an unknown X++ exception has </font></font></p>
<p><font face="Verdana, sans-serif"><font size="2">occurred.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">XppException</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">Thrown when an X++ exception has occurred.</font></font></p>
</td>
</tr>
</tbody>
</table>
<h1>Summary</h1>
<p>You should now be able to use .NET classes in AX and also use AX code in&nbsp; .NET classes.</p>
<p>When using .NET classes in AX you had to add the reference to the .NET class first and then use the code in the .NET class from X++ code. AX makes this possible by using a bridge to the Common Language Runtime.</p>
<p>When you want to use AX functionality in your .NET classes you first had to add a reference to the .NET Business Connector. Then you had to use the marshalled classes that the .NET Business Connector consists of in your .NET code in order to call class methods, manipulate data or read data from AX.</p>
<p>For more examples on how to use the .NET Business Connector to create cool features in other programs, take a look at the Microsoft Dynamics Snap for AX:<a href="http://www.codeplex.com/axsnap" target="_blank">http://www.codeplex.com/axsnap</a></p>
<p>The Microsoft Dynamics Snap for AX are free applications that exemplifies how Microsoft Office applications like Excel, Word, and Outlook can be used to integrate with AX.</p>
<p>One of the applications is Business Data Lookup. It enables users that work in Word, Excel, and Outlook to lookup information in AX and paste data back to the Microsoft Offce application.</p>
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.allfreetech.com/microsoft-net/working-with-microsoft-dynamics-ax-and-net-part-2-134.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with Microsoft Dynamics AX and .NET: Part 1</title>
		<link>http://www.allfreetech.com/microsoft-net/working-with-microsoft-dynamics-ax-and-net-part-1-131.html</link>
		<comments>http://www.allfreetech.com/microsoft-net/working-with-microsoft-dynamics-ax-and-net-part-1-131.html#comments</comments>
		<pubDate>Sun, 24 Jan 2010 08:07:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Microsoft .Net]]></category>
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.allfreetech.com/?p=131</guid>
		<description><![CDATA[This article by Erlend Dalen, explains how you can use .NET classes in AX with the Common Language Runtime and how you can write .NET code that uses AX classes by using the .NET Business Connector for AX.
The topics covered in this article are:

A brief description of Common Language Runtime (CLR)
Adding .NET references to classes [...]]]></description>
			<content:encoded><![CDATA[<p>This article by <b>Erlend Dalen</b>, explains how you can use .NET classes in AX with the Common Language Runtime and how you can write .NET code that uses AX classes by using the .NET Business Connector for AX.<span id="more-131"></span></p>
<p>The topics covered in this article are:</p>
<ul>
<li>A brief description of Common Language Runtime (CLR)</li>
<li>Adding .NET references to classes in AX</li>
<li>Using a .NET class in X++</li>
<li>Adding references to the .NET Business Connector</li>
<li>Using the .NET Business Connector in .NET classes</li>
</ul>
<p>When you are done with this article, you should be able to use .NET classes as reference classes in AX through the <b>Common Language Runtime</b> (<b>CLR</b>). The article will also guide you through the process of creating a .NET class in Visual Studio, and how to use it in AX. You will also learn how to use AX logic from external applications by using the .NET Business Connector.</p>
<p style="margin-left: 40px; margin-right: 40px;"><em>All the Visual Studio examples in this article are written in C#.</em></p>
<h1>Common Language Runtime</h1>
<p>You might have done some .NET development before looking into X++ right? Maybe you&#39;re even a .NET expert? If so, you must have heard of CLR before. The CLR is a component of .NET that enables objects written in different languages to communicate with each other. CLR can be used in AX to combine functionality from .NET classes and libraries, including the ones you have yourself created in .NET. However, you cannot consume AX objects in .NET by using the CLR. Instead, you will then have to use the .NET Business Connector.</p>
<p>To learn more about the CLR, check out the following link: <a href="http://msdn.microsoft.com/en-us/library/ddk909ch%28VS.71%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ddk909ch(VS.71).aspx</a></p>
<p>One very useful feature in AX when dealing with integration between AX and .NET is the way AX implicitly converts the most common data types. For the data types listed in the next table you do not need to convert the data manually. For all other data types, you will have to convert them manually.</p>
<p>
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
</p>
<table align="center" border="1" bordercolor="#000000" cellpadding="7" cellspacing="0" style="page-break-before: always;" width="639">
<col width="304" />
<col width="305" />
<tbody>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2"><b>.NET Common Language Runtime</b></font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2"><b>X++</b></font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">System.String</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">str</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">System.Int32</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">int</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">System.Int64</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">int64</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">System.Single</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">real</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">System.Double</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">real</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">System.Boolean</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">Boolean</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">System.DateTime</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">date</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">System.Guid</font></font></p>
</td>
<td width="305">
<p><font face="Verdana, sans-serif"><font size="2">guid</font></font></p>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p style="margin-left: 40px; margin-right: 40px;"><em>Enums are stored as integers in AX and are treated as integers when they are implicitly converted between .NET and AX.</em>&nbsp;&nbsp; &nbsp;</p>
<p>We prove this by executing the next example that shows the conversion between <i>System.String</i> and <i>str</i>. The same can be done for any of the other data types in the above table.</p>
<pre style="margin-left: 40px;"><b> </b>static void ImplicitDataConversion(Args _args)
{
    System.String netString;
    str xppString;
    ;

    // Converting from System.String to str
    netString = &quot;Hello AX!&quot;;
    xppString = netString;
    info(xppString);
    // Converting from str to System.String
    xppString = &quot;Hello .NET!&quot;;
    netString = xppString;
    info(netString);
}
</pre>
<p style="margin-left: 40px; margin-right: 40px;"><em>X++ is case insensitive, except when dealing with CLR. This means that writing <i>System.string</i> in the previous example will result in &nbsp;&nbsp; &nbsp;a compile error, whereas writing <i>Str</i> instead of <i>str</i> will not.</em></p>
<p>The result will look like this:</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msax-article1-image01.png" /></p>
<h1>Adding a reference to a .NET class in AX</h1>
<p>To be able to use .NET classes in AX you have to make sure that the .NET assembly that you would like to use in AX exists under the <b>References</b> node in the AOT. If you can&#39;t find it there, you have to add it by adding a reference to the DLL file that contains the assembly in the AOT under <b>References</b>.</p>
<p style="margin-left: 40px; margin-right: 40px;"><em>When adding a reference node in the AOT you have to make sure that the DLL exists on all client computers. If there is a client computer in which the DLL does not exist, it will result in compile errors when compiling code on that client computer.</em></p>
<h2>Assembly exist in the Global Assembly Cache</h2>
<p>Follow these steps to add a reference that exists in the Global Assembly Cache:</p>
<ol>
<li>If the DLL has been added to the Global Assembly Cache, you can right-click on the <b>Reference</b> node in the AOT and select <b>Add Reference</b>.</li>
<li>In the form that opens (see next screenshot), you should be able to find the desired <i>DLL</i>. Add it by clicking on the <b>Select</b> button.</li>
<li>When you have selected the desired reference, click on the <b>OK</b> button. The assembly has now been added to the AOT, and can be used when writing X++ code.</li>
<p>	&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;</ol>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msax-article1-image02.png" /></p>
<h2>Assembly not in Global Assembly Cache</h2>
<p>If the file does not exist in the Global Assembly Cache follow these steps:</p>
<ol>
<li>Click on the <b>Browse</b> button in the <b>Add Reference</b> form shown above and find the <i>DLL</i> file.</li>
<li>Click on <b>Open</b>. If the <i>DLL</i> is a valid assembly it will be added to the AOT under <b>References</b>.</li>
</ol>
<p>Another option is to add the DLL to the Global Assembly Cache first and select it as described in the previous section, <i>Assembly exist in the Global Assembly Cache</i>.</p>
<h1>Using a .NET class in X++</h1>
<p>After having added a reference to the .NET assembly you want to use in AX, you can start writing the X++ code that will use the assembly.</p>
<p>When referencing the classes in the assembly you will need to write the whole namespace and class name. In my example I&#39;m using an assembly that has been added to the AOT in the SYS layer. The example shows a nice feature that enables AX to send info messages to the Windows Event Log.</p>
<p>This can be particularly useful when you would like to use the Windows Event Log to monitor AX batch Jobs.</p>
<p>First, we add a new static method called <i>writeLogEntry</i> to the Global class:</p>
<div style="margin-left: 40px;">
<pre>static void writeLogEntry(Exception e, str caller, int line, str text)
{
    // Use the standard .NET class EventLog from
    // the System.Diagnostics assembly
    System.Diagnostics.EventLog     eventLog;
    // Also use a .NET enumeration from the
    // System.Diagnostics assembly
    System.Diagnostics.EventLogEntryType    entryType;
    System.Exception    clrException;
    str stack;
    Batch batch;
    str batchInfo;
    ;
    try
    {
        // Create a new object of the EventLog class
        eventLog = new System.Diagnostics.EventLog();
        eventLog.set_Source(&quot;Dynamics AX&quot;);
        // Set the enumeration value based on the Exception
        // type in AX
        switch (e)
        {
            case Exception::Info :
                entryType =
                  System.Diagnostics.EventLogEntryType::Information;
                break;
            case Exception::Warning :
                entryType =
                  System.Diagnostics.EventLogEntryType::Warning;
                break;
            case Exception::Error :
                entryType =
                  System.Diagnostics.EventLogEntryType::Error;
                break;
        }
        // If the current user is running a batch job
        // we can assume that the info message came
        // from the batch job and add additional information
        // to the event log

        while select batch
            where batch.Status == BatchStatus::Executing &amp;&amp;
                  batch.ExecutedBy == curuserid()
        {
            batchInfo += batch.GroupId + &#39;: &#39;+
              classid2name(batch.ClassNumber) + &#39;n&#39;;
        }
        if (batchInfo)
            eventLog.WriteEntry(strfmt(&quot;Batch info from AX: %1 nn
              The message originated from :%2 nat line %3 nn
              Message: %4&quot;, batchInfo, caller, line, text),
              entryType);
        else
            eventLog.WriteEntry(strfmt(&quot;Info from AX: nn
              The message originated from :%1 nat line %2 nn
              Message: %3&quot;, caller, line, text), entryType);
    }
    catch(Exception::CLRError)
    {
        // If not able to write the info to the eventlog
        // print an error in the print window instead.
        print &quot;EventWriter:
          Unable to write entry to the windows eventlog&quot;;
    }
}</pre>
</div>
<p>
	&nbsp;</p>
<p>Then we add a line of code at the end of the <i>add</i> method in the <i>Info</i> class so that the end of the method will look like this:</p>
<pre style="margin-left: 40px;">       writeLogEntry(_exception, conpeek(packedAction,2) ,
          conpeek(packedAction,3), _txt);
        this.addSysInfoAction(_helpUrl, actionClassId, packedAction);
    }
    return super(_exception, (buildprefix?getprefix():&#39;&#39;)+_txt);
}
</pre>
<p>To test the feature, simply create a new Job that prints something to the infolog:</p>
<pre style="margin-left: 40px;">static void TestEventLog(Args _args)
{
    ;
    info(&quot;This is a test&quot;);
}
</pre>
<p>You will now see an infolog message in AX, and if you open the Windows <b>Event Viewer</b> you should see the following message in the list:</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msax-article1-image03.png" /></p>
<p>Double-clicking on the event will bring up information about the origin of the info and the message that was printed to the infolog in AX.</p>
<p style="text-align: center;"><img src="http://www.packtpub.com/files/images/msax-article1-image04.png" /></p>
<p>This example could easily be extended so you can enable or disable the feature for different users and select the level of messages to be sent to the EventLog.</p>
<h1>.NET Business Connector</h1>
<p>If you have external applications that need to integrate directly to AX logic you can easily achieve this by using the .NET Business Connector. A typical scenario can be that you would like your .NET application to execute some code in AX and have the result sent back to the .NET application.</p>
<p style="margin-left: 40px; margin-right: 40px;"><em>The .NET Business Connector requires additional licenses. Make sure that the AX installation in which you want to make use&nbsp; of the .NET Business Connector has the necessary licenses before you start developing the solution.</em></p>
<p>In standard AX, the .NET Business Connector is also used by the Enterprise Portal through the Web Parts in SharePoint so that they can expose AX data and logic directly to the Web. It is also used by the standard <b>Application Integration Framework</b> (<b>AIF</b>).</p>
<p>The way that the .NET Business Connector works is that it offers a set of .NET managed classes that .NET applications use in order to log on to AX and execute methods in AX classes.</p>
<p>Here is a list of the different managed classes that can be used in .NET when you want to integrate to AX through the .NET Business Connector. The list is taken from the Dynamics AX SDK.</p>
<p>
	&nbsp;</p>
<table cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td valign="top">
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
<table align="center" border="1" bordercolor="#000000" cellpadding="7" cellspacing="0" style="page-break-before: always;" width="640">
<col width="304" />
<col width="306" />
<tbody>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2"><b>Class name </b></font></font></p>
</td>
<td width="306">
<p><font face="Verdana, sans-serif"><font size="2"><b>Description</b></font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">Axapta</font></font></p>
</td>
<td width="306">
<p><font face="Verdana, sans-serif"><font size="2">The Axapta class contains methods that enable you to connect to AX, create AX objects, and execute transactions.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">AxaptaBuffer</font></font></p>
</td>
<td width="306">
<p><font face="Verdana, sans-serif"><font size="2">The AxaptaBuffer class contains methods that enable you to add data to, and retrieve data from an AX buffer.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">AxaptaContainer</font></font></p>
</td>
<td width="306">
<p><font face="Verdana, sans-serif"><font size="2">The AxaptaContainer class contains methods that enable you to read data from, and write data to, AX containers.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">AxaptaRecord</font></font></p>
</td>
<td width="306">
<p><font face="Verdana, sans-serif"><font size="2">The AxaptaRecord class contains methods that enable you to read, update, insert, and delete AX records. It also enables you to call table methods in AX.</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="304">
<p><font face="Verdana, sans-serif"><font size="2">AxaptaObject</font></font></p>
</td>
<td width="306">
<p><font face="Verdana, sans-serif"><font size="2">The AxaptaObject class contains methods that enable you to call class methods in AX.</font></font></p>
</td>
</tr>
</tbody>
</table>
<p>				<a href="http://www.packtpub.com/article/working-with-microsoft-dynamics-ax-and-net-2?utm_source=sb_msax_abr1_1209&amp;utm_medium=content&amp;utm_campaign=santi" target="_blank"><br />
				</a></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.allfreetech.com/microsoft-net/working-with-microsoft-dynamics-ax-and-net-part-1-131.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Managing Discounts, Vouchers, and Referrals with PHP 5 Ecommerce</title>
		<link>http://www.allfreetech.com/php/managing-discounts-vouchers-and-referrals-with-php-5-ecommerce-126.html</link>
		<comments>http://www.allfreetech.com/php/managing-discounts-vouchers-and-referrals-with-php-5-ecommerce-126.html#comments</comments>
		<pubDate>Sun, 24 Jan 2010 07:58:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ecommerce]]></category>

		<guid isPermaLink="false">http://www.allfreetech.com/?p=126</guid>
		<description><![CDATA[Once your shipping and tax issues taken into account, the next logical step for your e-commerce store is discount codes, as these need to be entered at the shopping basket stage. Going hand in hand with discount codes are voucher codes and referral discounts. In this article by Michael Peacock, you will learn:

How to create [...]]]></description>
			<content:encoded><![CDATA[<p>Once your shipping and tax issues taken into account, the next logical step for your e-commerce store is discount codes, as these need to be entered at the shopping basket stage. Going hand in hand with discount codes are voucher codes and referral discounts. In this article by <b>Michael Peacock</b>, you will learn:</p>
<ul>
<li>How to create a discount code system
<ol>
<li>How to offer different types of discounts</li>
<li>How to take the discount into account at the shopping basket stage</li>
</ol>
</li>
<li>How to sell voucher codes on your store</li>
<li>How to offer discounts to customers who bring us referral business</li>
</ul>
<h1>Discount codes</h1>
<p>Discount codes are a great way to both entice new customers into a store, and also to help retain customers with special discounts. The discount code should work by allowing the customer to enter a code, which will then be verified by the store, and then a discount will be applied to the order.</p>
<p>The following are discount options we may wish to have available in our store:</p>
<ul>
<li>A fixed amount deducted from the cost of the order</li>
<li>A fixed percentage deducted from the cost of the order</li>
<li>The shipping cost altered, either to free or to a lower amount</li>
<li>Product-based discounts (although we won&#39;t cover this one in the article)</li>
</ul>
<p>It may also be useful to take into account the cost of the customer&#39;s basket; after all if we have a $5 discount code, we probably wouldn&#39;t want that to apply for orders of $5 or lower, and may wish to apply a minimum order amount.</p>
<h2>Discount codes data</h2>
<p>When storing discount codes in the framework, we need to store and account for:</p>
<ul>
<li>The voucher code itself, so that we can check that the customer is entering a valid code</li>
<li>Whether the voucher code is active, as we may wish to prepare some voucher codes, but not have them usable until a certain time, or we may wish to discontinue a code</li>
<li>A minimum value for the customer&#39;s basket, either as an incentive for the customer to purchase more or to prevent loss-making situations (for example a $10 discount on a $5 purchase!)</li>
<li>The type of discount:
<ol>
<li><b>Percentage</b>: To indicate that the discount amount is a percentage to be removed from the cost</li>
<li><b>Fixed amount deducted</b>: To indicate that the discount amount is a fixed amount to be removed from the order total</li>
<li><b>Fixed amount set to shipping</b>: To indicate that the discount amount is to be the new value for the shipping cost</li>
</ol>
</li>
<li>Discount amount; that is, the amount of discount to be applied</li>
<li>The number of vouchers issued, if we wish to limit the number of uses of a particular voucher code</li>
<li>An expiry date, so that if we wish to have the voucher code expire, codes with a date after the stored expiry date would no longer work</li>
</ul>
<h3>Discount codes database</h3>
<p>The following table illustrates this information as database fields within a table:</p>
<p>The default value for <i>num_vouchers</i> is <i>-1</i>, which we will use for vouchers that are not limited to a set number of issues.</p>
<p><center></p>
<p>
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
</p>
<table border="1" bordercolor="#00000a" cellpadding="7" cellspacing="0" width="542">
<col width="130" />
<col width="122" />
<col width="246" />
<tbody>
<tr valign="TOP">
<td width="130">
<p><font face="Verdana, sans-serif"><font size="2"><b>Field</b></font></font></p>
</td>
<td width="122">
<p><font face="Verdana, sans-serif"><font size="2"><b>Type</b></font></font></p>
</td>
<td width="246">
<p><font face="Verdana, sans-serif"><font size="2"><b>Description</b></font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="130">
<p><font face="Verdana, sans-serif"><font size="2">ID</font></font></p>
</td>
<td width="122">
<p><font face="Verdana, sans-serif"><font size="2">Integer (Primary Key, Auto increment)</font></font></p>
</td>
<td width="246">
<p><font face="Verdana, sans-serif"><font size="2">For the framework to reference the code</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="130">
<p><font face="Verdana, sans-serif"><font size="2">Vouchercode</font></font></p>
</td>
<td width="122">
<p><font face="Verdana, sans-serif"><font size="2">Varchar</font></font></p>
</td>
<td width="246">
<p><font face="Verdana, sans-serif"><font size="2">The code the customer enters into the order</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="130">
<p><font face="Verdana, sans-serif"><font size="2">Active</font></font></p>
</td>
<td width="122">
<p><font face="Verdana, sans-serif"><font size="2">Boolean</font></font></p>
</td>
<td width="246">
<p><font face="Verdana, sans-serif"><font size="2">If the code can be used</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="130">
<p><font face="Verdana, sans-serif"><font size="2">Min_basket_cost</font></font></p>
</td>
<td width="122">
<p><font face="Verdana, sans-serif"><font size="2">Float</font></font></p>
</td>
<td width="246">
<p><font face="Verdana, sans-serif"><font size="2">The minimum cost of the customer&#39;s basket for the code to work for them</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="130">
<p><font face="Verdana, sans-serif"><font size="2">Discount_operation</font></font></p>
</td>
<td width="122">
<p><font face="Verdana, sans-serif"><font size="2">ENUM(&#39;-&#39;,%&#39;,&#39;s&#39;)</font></font></p>
</td>
<td width="246">
<p><font face="Verdana, sans-serif"><font size="2">The type of discount</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="130">
<p><font face="Verdana, sans-serif"><font size="2">Num_vouchers</font></font></p>
</td>
<td width="122">
<p><font face="Verdana, sans-serif"><font size="2">Integer</font></font></p>
</td>
<td width="246">
<p><font face="Verdana, sans-serif"><font size="2">Number of times the voucher can be used</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="130">
<p><font face="Verdana, sans-serif"><font size="2">Expiry</font></font></p>
</td>
<td width="122">
<p><font face="Verdana, sans-serif"><font size="2">timestamp</font></font></p>
</td>
<td width="246">
<p><font face="Verdana, sans-serif"><font size="2">The date the voucher code expires, and is no longer usable</font></font></p>
</td>
</tr>
</tbody>
</table>
<p></center></p>
<p>The following code represents this data in our database:</p>
<pre style="margin-left: 40px;">CREATE TABLE `discount_codes` (
`ID` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`vouchercode` VARCHAR( 25 ) NOT NULL ,
`active` TINYINT( 1 ) NOT NULL ,
`min_basket_cost` FLOAT NOT NULL ,
`discount_operation` ENUM( &#39;-&#39;, &#39;%&#39;, &#39;s&#39; ) NOT NULL ,
`discount_amount` FLOAT NOT NULL ,
`num_vouchers` INT( 11 ) NOT NULL DEFAULT &#39;-1&#39;,
`expiry` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( `ID` )
) ENGINE = INNODB DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;
</pre>
<hr color="#ff9933" noshade="noshade" size="1" />
<h2>Discount codes functionality</h2>
<p>The functionality for discount codes can be encapsulated into a single function; this function should be called when the basket is loaded and updated. (That is, if the customer changes the quantity of products in the basket, we must run this; also, if the customer adds a voucher code to their order, we must obviously call this function.)</p>
<p>&nbsp;</p>
<p>The function needs to:</p>
<ol>
<li>Check to see if the customer has entered a voucher code with their order.</li>
<li>If they have, it must look up the voucher code to see if it exists, or doesn&#39;t exist.</li>
<li>If the voucher code exists, it must check to see if the code has expired and is still able to be used (that is, that <i>num_vouchers</i> is greater than <i>0</i> or equal to <i>-1</i>).</li>
<li>Assuming this is the case, it must then check to see that the customer&#39;s basket cost is at least that of the minimum order amount in the discount codes record in the database.</li>
<li>If the voucher is able to be used, it must then determine the type of voucher, and make the relevant discount to either the basket cost, or the shipping costs.</li>
</ol>
<p>The following code does all of this; some of the relevant sections described are highlighted within the code:</p>
<pre style="margin-left: 40px;">/**
  * Consider and apply voucher codes
  * Types of voucher code
  * - = FIXED AMOUNT OFF
  * % = PERCENTAGE OFF
  * s = SET NEW SHIPPING COST
  * @param voucherCode String
  * @return void
  */
  private function considerVouchers( $voucherCode )
  {
    <span style="font-weight: bold;">//The voucher code value is checked to ensure it is not empty </span>
<span style="font-weight: bold;">    // (as per point 1)</span>
<span style="font-weight: bold;">    if( $voucherCode != &#39;&#39; )</span>
<span style="font-weight: bold;">    {</span>
<span style="font-weight: bold;">      // we need the date, to see if the voucher has expired</span>
<span style="font-weight: bold;">      $cts = date(&#39;Y-m-d H:i:s&#39;);</span>
<span style="font-weight: bold;">      $voucher_sql = &quot;SELECT *, if(&#39;{$cts}&#39; &gt; expiry, 1, 0)</span>
<span style="font-weight: bold;">                        AS expired FROM discount_codes</span>
<span style="font-weight: bold;">                      WHERE vouchercode=&#39;{$voucherCode}&#39; LIMIT 1&quot;;</span>
      $this-&gt;registry-&gt;getObject(&#39;db&#39;)-&gt;executeQuery( $voucher_sql );
      if( $this-&gt;registry-&gt;getObject(&#39;db&#39;)-&gt;numRows() == 0 )
      {
        $this-&gt;voucher_notice = &#39;Sorry, the voucher code you entered
            is invalid&#39;;
      }
      else
      {
        $voucher = $this-&gt;registry-&gt;getObject(&#39;db&#39;)-&gt;getRows();
        if( $voucher[&#39;active&#39;] == 1 )
        {
          if( $voucher[&#39;expired&#39;] == 1 )
          {
            $this-&gt;voucher_notice = &#39;Sorry, this voucher has
                expired&#39;;
            return false;
          }
          else
          {
            <span style="font-weight: bold;">// check to see there are some vouchers, and customer</span>
<span style="font-weight: bold;">            // has enough in their basket (points 3 and 4)</span>
            if( $voucher[&#39;num_vouchers&#39;] != 0 )
            {
              <span style="font-weight: bold;">if( $this-&gt;cost &gt;= $voucher[&#39;min_basket_cost&#39;] )</span>
              {
                $this-&gt;discountCode = $voucherCode;
                $this-&gt;discountCodeId = $voucher[&#39;ID&#39;];
                // If the discount operation is a percentage, then
                // the discount value is applied to the basket cost
                // to calculate that percentage. This amount is then
                // deducted from the order cost, giving a &quot;discount
                // value&quot;% discount from the order.
                if( $voucher[&#39;discount_operation&#39;] == &#39;%&#39; )
                {
                  $this-&gt;cost = $this-&gt;
              cost - (($this-&gt;cost)/100)*$voucher[&#39;discount_amount&#39;];
                  $this-&gt;voucher_notice = &#39;A &#39;
                      . $voucher[&#39;discount_amount&#39;]
                      . &#39;% discount has been applied to your order&#39;;
                  return true;
                  // If the discount operation is a subtraction, then
                  // the discount amount from the discount code is
                  // deducted from the order cost, and the order cost
                  // is updated to reflect this.
                }
                elseif( $voucher[&#39;discount_operation&#39;] == &#39;-&#39; )
                {
                  $this-&gt;cost =
                      $this-&gt;cost - $voucher[&#39;discount_amount&#39;];
                  $this-&gt;voucher_notice = &#39;A discount of &amp;pound;&#39;
                      . $voucher[&#39;discount_amount&#39;]
                      . &#39; has been applied to your order&#39;;
                  return true;
                  // Finally, if the discount operation is set to s
                  // then, we set the shipping cost to the discount
                  // value. This could allow us to set free shipping,
                  // or just reduce shipping costs.
                }
                elseif( $voucher[&#39;discount_operation&#39;] == &#39;s&#39; )
                {
                  $this-&gt;shipping_cost = $voucher[&#39;discount_amount&#39;];
                  $this-&gt;voucher_notice = &#39;Your orders shipping cost
                      has been reduced to &amp;pound;&#39;
                      . $voucher[&#39;discount_amount&#39;];
                  return true;
                }
              }
              else
              {
                $this-&gt;voucher_notice = &#39;Sorry, your order total is
                    not enough for your order to qualify for this
                    discount code&#39;;
                return false;
              }
            }
            else
            {
              $this-&gt;voucher_notice = &#39;Sorry, this was a limited
                  edition voucher code, there are no more instances
                  of that code left&#39;;
              return false;
            }
          }
        }
        else
        {
          $this-&gt;voucher_notice = &#39;Sorry, the vocuher code you
              entered is no longer active&#39;;
          return false;
        }
      }
    }
  }
</pre>
<p>Now, we have the basis for our discount code feature. We can issue discount codes as an incentive to get new customers, or to encourage existing customers to make more purchases.</p>
<p>&nbsp;</p>
<h3>Reducing the number of codes available</h3>
<p>One feature we added to the database structure for our discount codes was the ability to limit the number of times a voucher could be used, effectively allowing a code to be &quot;issued&quot; a set number of times. We need to take this into account, and reduce the number of vouchers in circulation, once one has been used.</p>
<p>This won&#39;t be done at this stage, but will need to be implemented at the final checkout stage when an order is updated to &quot;paid&quot;, or the customer pays online. The following function will do this for us; it checks to see if a code is used, or if it&#39;s unlimited or has expired, and if it&#39;s not unlimited and hasn&#39;t already expired, it updates the code to decrement the number of uses remaining:</p>
<pre style="margin-left: 40px;">private function adjustDiscountCodeQuantities( $codeId )
{
$sql = &quot;SELECT num_vouchers FROM discount_codes WHERE ID=&quot; . $codeId;
$this-&gt;registry-&gt;getObject(&#39;db&#39;)-&gt;executeQuery( $sql );
if( $this-&gt;registry-&gt;getObject(&#39;db&#39;)-&gt;numRows() &gt; 0 )
{
$codeData = $this-&gt;registry-&gt;getObject(&#39;db&#39;)-&gt;getRows();
if( $codeData[&#39;num_vouchers&#39;] &gt; 0 )
{
$sql = &quot;UPDATE discount_codes SET num_vouchers=num_vouchers-1
WHERE ID=&quot; . $codeId;
$this-&gt;registry-&gt;getObject(&#39;db&#39;)-&gt;executeQuery( $sql );
}
}
}
</pre>
<h1>Purchasable voucher codes</h1>
<p>Voucher codes work in the same way as discount codes, except that they are purchased for use by a customer, as opposed to given away for promotional reasons.</p>
<h2>Existing functionality</h2>
<p>The discount codes and product variation features already give us most of the functionality required for purchasable voucher codes.</p>
<h3>Discount codes</h3>
<p>As a voucher code has the same functionality as our discount codes, which we built earlier, we have a large portion of the functionality in place. When a voucher is purchased, a new record in the discount codes table will be made, with a <i>num_vouchers</i> value of <i>1</i>.</p>
<h3>Product variations</h3>
<p>Let&#39;s say we have product variations feature built, which allows us to create a purchasable voucher code product, with variations that increase the price in increments, perhaps of $5.</p>
<h2>Required additional functionality</h2>
<p>We only need to add additional functionality to this if we wish to automate the process of generating a voucher code when a customer purchases a voucher code. Without additional functionality, we would simply notice a new order, manually create a new discount code, and then e-mail the customer with the code. However, automating this would save us quite a lot of time, so let&#39;s look at what would be involved in doing this:</p>
<ol>
<li>First, we must wait until an order has its status updated to &quot;paid&quot;. This would either be when a payment is made online by the customer, or when an offl ine payment is received and we, as the administrator, mark the order as &quot;paid&quot;.</li>
<li>The order contents must be searched for anything that is a purchasable voucher code.</li>
<li>For each of these vouchers purchased, a new record must be automatically inserted into the <i>voucher_codes</i> table with the following values:
<ul>
<li><i>vouchercode</i>: A randomly generated string</li>
<li><i>active</i>: <i>1</i></li>
<li><i>min_basket_cost</i>: The amount of the voucher purchased</li>
<li><i>discount_operation</i>: (because we are subtracting an amount from the cost)</li>
<li><i>discount_amount</i>: The amount of the voucher purchased</li>
<li><i>num_vouchers</i>: <i>1</i></li>
<li><i>expiry</i>: A year in the future would be a suitable validity period</li>
</ul>
</li>
<li>These vouchers would then be sent through e-mail to the customer.</li>
</ol>
<h1>Referrals</h1>
<p>To reward loyal customers, we may wish to offer referral discounts to them. This would work by encouraging our customers to introduce new customers, and giving them a credit based off a percentage of orders placed by customers they refer to our store. Customers referring other customers would be given a referral code, which could either be part of a link used to promote the site, or given to customers to enter somewhere on the order process.</p>
<p>The referral process should work like this:</p>
<ol>
<li>Check for a referral code in the URL.</li>
<li>If a code is found in the URL, it should be stored in a cookie, unless a previous referral code is already being stored; in that case, the older code should be used.</li>
<li>At the checkout stage, this code should be looked up, to check if it is valid and to see the commission to be applied to the customer who passed the referral. The order number, commission value, and referring customer should be stored in a database table.</li>
<li>When the order is updated to &quot;paid&quot; or &quot;paid online&quot;, the commission should be applied to the relevant customer&#39;s account.</li>
</ol>
<h2>Database changes</h2>
<p>This requires a new database table, as well as some database alterations to work.</p>
<h3>New table: Referrers</h3>
<p>A referrers table is required to link customers to a unique referral code, and a commission percentage. It would require the following fields:</p>
<p><center></p>
<p>
<style type="text/css">
<!--
@page { margin: 0.79in }
P { margin-bottom: 0.08in }
-->
</style>
</p>
<table border="1" bordercolor="#00000a" cellpadding="7" cellspacing="0" width="542">
<col width="89" />
<col width="99" />
<col width="310" />
<tbody>
<tr valign="TOP">
<td width="89">
<p><font face="Verdana, sans-serif"><font size="2"><b>Field</b></font></font></p>
</td>
<td width="99">
<p><font face="Verdana, sans-serif"><font size="2"><b>Type</b></font></font></p>
</td>
<td width="310">
<p><font face="Verdana, sans-serif"><font size="2"><b>Description</b></font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="89">
<p><font face="Verdana, sans-serif"><font size="2">Customer ID</font></font></p>
</td>
<td width="99">
<p><font face="Verdana, sans-serif"><font size="2">Integer </font></font></p>
</td>
<td width="310">
<p><font face="Verdana, sans-serif"><font size="2">A reference to the customer&#39;s ID number</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="89">
<p><font face="Verdana, sans-serif"><font size="2">Referral Code</font></font></p>
</td>
<td width="99">
<p><font face="Verdana, sans-serif"><font size="2">Varchar (Unique)</font></font></p>
</td>
<td width="310">
<p><font face="Verdana, sans-serif"><font size="2">The customer&#39;s referral code, which he/she would give to friends</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="89">
<p><font face="Verdana, sans-serif"><font size="2">Commission percentage</font></font></p>
</td>
<td width="99">
<p><font face="Verdana, sans-serif"><font size="2">Float</font></font></p>
</td>
<td width="310">
<p><font face="Verdana, sans-serif"><font size="2">The percentage of commission that would be credited back to the customer&#39;s account</font></font></p>
</td>
</tr>
<tr valign="TOP">
<td width="89">
<p><font face="Verdana, sans-serif"><font size="2">Active</font></font></p>
</td>
<td width="99">
<p><font face="Verdana, sans-serif"><font size="2">Boolean</font></font></p>
</td>
<td width="310">
<p><font face="Verdana, sans-serif"><font size="2">If the customer is a referrer, or not, as we may wish to disable a customer&#39;s referral code, if he/she is abusing it</font></font></p>
</td>
</tr>
</tbody>
</table>
<p></center></p>
<h3>Changes</h3>
<p>Customers should have a credit field, showing how much credit they have with the store based on referred customers. The orders table should also be altered to store a record of any referral code used.</p>
<h2>Functionality</h2>
<p>The workflow of this feature would work like this:</p>
<ol>
<li>An order is placed, and a referral code is associated with it.</li>
<li>The order is marked as &quot;paid&quot;.</li>
<li>A lookup is performed on the referrers table to find the customer and the percentage.</li>
<li>The commission value is calculated.</li>
<li>The referring customer&#39;s credit value is updated to include new commission earned.</li>
</ol>
<p>We could extend this to record a list of transactions to a customer&#39;s credit, such as dates and amounts their account was credited by, and allow reports to be generated and sent to them. However, that could occupy several chapters itself!</p>
<h3>Checkout process consideration</h3>
<p>This requires an important consideration when we get to the checkout stage: we must take into account any credit stored on a customer&#39;s account. If they have credit, it should be deducted from any of their own orders, to ensure they can spend the commission they earned.</p>
<h1>Summary</h1>
<p>We now have a number of useful features to encourage new orders and customers to our store, as well as encouraging existing customers to promote our store through affiliate codes.</p>
<p>This included creating a voucher code system which supported vouchers that deducted a percentage from the order total, vouchers that deducted a fixed amount from the order total, and vouchers that altered the cost of shipping to the customer. These vouchers were able to take into account expiry dates, limited-use options, and the current cost of the customer&#39;s basket.</p>
<p>Taking this forward, we looked at how to extend our framework to allow customers to purchase vouchers as gifts for other customers, as well as how to extend our store to support referral bonuses and incentives for our customers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.allfreetech.com/php/managing-discounts-vouchers-and-referrals-with-php-5-ecommerce-126.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
