<?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>Tech Insight ! &#187; .net developement</title>
	<atom:link href="http://techinsight.dhanashree.com/tag/net-developement/feed/" rel="self" type="application/rss+xml" />
	<link>http://techinsight.dhanashree.com</link>
	<description>Technical blog on ASP.Net, PHP, Web Development, Web hosting , Database Programming</description>
	<lastBuildDate>Fri, 12 Aug 2011 07:26:49 +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>Combine/Compress/Minify JavaScript, CSS in Asp.net</title>
		<link>http://techinsight.dhanashree.com/combinecompressminify-javascript-css-in-asp-net/</link>
		<comments>http://techinsight.dhanashree.com/combinecompressminify-javascript-css-in-asp-net/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 11:00:28 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[.net framework]]></category>
		<category><![CDATA[CSS 3]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/combinecompressminify-javascript-css-in-asp-net/</guid>
		<description><![CDATA[Introduction:

When we design and develop the website, the performance is in the core of development. The system you are developing must produce the result with high speed. For the web development perspective, website load performance is very essential thing to take care of. You need good working layout, easy layout and easy navigation.
Here with this [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction:<br />
</strong></p>
<p>When we design and develop the website, the performance is in the core of development. The system you are developing must produce the result with high speed. For the web development perspective, website load performance is very essential thing to take care of. You need good working layout, easy layout and easy navigation.</p>
<p>Here with this article I m not going to talk about of all the aspects of web application performance improvements. But I am specifically targeting the topic when it comes to the CSS and JavaScript faster loading in the client browser.  In fact Google is also counting the speed of your website site when indexing to your website.</p>
<p>The goal was to improve overall performance on the client side. At the same time, it will show how we can force a client side script to be coached at the browser, so that in subsequent visit, it will take those scripts from the cache. This becomes increasingly important when using AJAX techniques within an application that introduce new features and functionality.</p>
<p>First of all I will outline the requirements and essential steps that this project is made of. So that if you want to implement the same in your development, it become easy for you to set up project.</p>
<p>To download complete project, <a href="http://www.esnips.com/doc/bb247398-9971-4fac-bb8e-02a8e8ebad7d/JS-CSS-Combiner-Minifier">click here</a></p>
<p><strong>Setup:<br />
</strong></p>
<p>To begin with, we will have following list of files to be created in the development studio.</p>
<ol>
<li>2 XML files, first one to hold source of JS files for each page and second to  hold CSS files for each page.</li>
<li>A generic class that implement <em>IHttpHandler, </em>that will be used to delivery combined and compressed JavaScript/CSS at the client.</li>
<li>And at last your .ASPX file that will be used to serve combined and compressed Javascript/CSS at client side.</li>
</ol>
<p><strong>Step by Step Implementation:<br />
</strong></p>
<p>Now let&#8217;s get dig into the actual development. To summarize, let&#8217;s say we have a page default.aspx that has following no. of JavaScript files and CSS files. Think of these file that we wanted to combine them and deliver at one go at the client browser.</p>
<ol>
<li>jquery.js</li>
<li>script-file-1.js</li>
<li>style-1.css</li>
<li>style-2.css</li>
</ol>
<p>As you can see, we have 2 different JavaScript file &amp; 2 CSS files. So what basically we will do in the next is to create a utility which can combine given JavaScript and compress it, then send it to client browser. Next the same process will be done for the CSS. Both the CSS files will be combined and compressed and send to client browser.</p>
<p>Now it&#8217;s time to take a look at into actual stuff that does this underlying work.</p>
<p>First of all we will create a CS class file that will hold the programming stuffs.</p>
<p>So perform the following steps to create &amp; configure that CS class file.</p>
<ol>
<li>
<div>Create CS class file with the name <em>ScriptCombiner.cs</em> and put the following code in that.</div>
</li>
</ol>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">class</span><br />
<span style="color: #2b91af;">ScriptCombiner</span> : <span style="color: #2b91af;">IHttpHandler<span style="color: #000000;">{</span></span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: blue;">readonly</span><span style="color: blue;"> </span><span style="color: blue;">static</span><span style="color: blue;"> </span><span style="color: #2b91af;">TimeSpan</span> CACHE_DURATION = <span style="color: #2b91af;">TimeSpan</span>.FromDays(1);</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: #2b91af;">HttpContext</span> context;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">void</span> ProcessRequest(<span style="color: #2b91af;">HttpContext</span> context){</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">bool</span> IsReusable{</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">get</span> { <span style="color: blue;">return</span><span style="color: blue;"> </span><span style="color: blue;">true</span>; }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;">}</span></p>
<p>As you can see, we are implementing the <span style="color: #2b91af; font-family: Courier New; font-size: 10pt;">IHttpHandler </span>interface.</p>
<p>You can write custom HTTP handlers to process specific, predefined types of HTTP requests in any Common Language Specification (CLS) compliant language. Executable code defined in the HttpHandler classes, rather than conventional ASP or ASP.NET Web pages, responds to these specific requests. HTTP handlers give you a means of interacting with the low-level request and response services of the IIS Web server and provide functionality much like ISAPI extensions but with a simpler programming model.</p>
<p>We are also implementing <span style="font-family: Courier New; font-size: 10pt;">IsReusable </span>properly as it is compulsory to implement as a part of inheritance of <span style="color: #2b91af; font-family: Courier New; font-size: 10pt;">IHttpHandler </span>interface.</p>
<p>Now, let&#8217;s put the nuts &amp; bolts inside the <span style="font-family: Courier New; font-size: 10pt;">ProcessRequest </span>function. I will also explain you the step by step each execution that is inside this function.</p>
<ol>
<li>We will also create another CS class file that is used to compress JavaScript. That file is named as &#8220;JavaScriptMinifier.cs&#8221;. Please take a look at the attached project solution file. As it is contain long lines of code, I can&#8217;t put it here.</li>
<li>Complete your class file with following functions.</li>
</ol>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">void</span> ProcessRequest(<span style="color: #2b91af;">HttpContext</span> context)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">string</span> xStrType, xStrSet, xStrVer, xStrpagecode;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: #2b91af;">Boolean</span> xBlnCanCompress;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">this</span>.context = context;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: #2b91af;">HttpRequest</span> request = context.Request;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;">xStrType = (!<span style="color: #2b91af;">String</span>.IsNullOrEmpty(request[<span style="color: #a31515;">"type"</span>])) ? request[<span style="color: #a31515;">"type"</span>] : <span style="color: blue;">null</span>;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> xStrSet = (!<span style="color: #2b91af;">String</span>.IsNullOrEmpty(request[<span style="color: #a31515;">"s"</span>])) ? request[<span style="color: #a31515;">"s"</span>] : <span style="color: blue;">null</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> xStrVer = (!<span style="color: #2b91af;">String</span>.IsNullOrEmpty(request[<span style="color: #a31515;">"v"</span>])) ? request[<span style="color: #a31515;">"v"</span>] : <span style="color: blue;">null</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> xStrpagecode = (!<span style="color: #2b91af;">String</span>.IsNullOrEmpty(request[<span style="color: #a31515;">"pcode"</span>])) ? request[<span style="color: #a31515;">"pcode"</span>] : <span style="color: blue;">null</span>;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//first check if client browser can support compressions<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> xBlnCanCompress = CanClientGZip(request);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">using</span> (<span style="color: #2b91af;">MemoryStream</span> memStream = <span style="color: blue;">new</span><span style="color: blue;"> </span><span style="color: #2b91af;">MemoryStream</span>(8092))<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: #2b91af;">Stream</span> writer;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//if browser is supporing GZip compression then create a new object using ICSharpCode.SharpZipLib.GZip</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//library which allow the compressed respose to send to client<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (xBlnCanCompress) </span></p>
<p><span style="font-family: Courier New; font-size: 10pt;">writer = (<span style="color: blue;">new</span> ICSharpCode.SharpZipLib.GZip.GZipOutputStream(memStream));</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> writer = memStream;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">using</span> (writer){</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">//now its time to read all the script/css files into a StringBuilder object.<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: #2b91af;">StringBuilder</span> combinedSource = <span style="color: blue;">new</span><span style="color: blue;"> </span><span style="color: #2b91af;">StringBuilder</span>();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> file <span style="color: blue;">in</span> GetFileNames(xStrSet, xStrpagecode, xStrType))<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> combinedSource.Append(System.IO.<span style="color: #2b91af;">File</span>.ReadAllText(context.Server.MapPath(file), <span style="color: #2b91af;">Encoding</span>.UTF8));<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">//Upto now we have combined all css/javascript based on request.<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">//its now time to remove extra white spaces and other unwanted characters from respose.</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//compression will take place now.<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">string</span> minified;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//use the YUI Javascript/CSS minifier to compress all js files<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (xStrType == <span style="color: #a31515;">&#8220;js&#8221;</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> minified = combinedSource.ToString();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> minified = CompressCSS(combinedSource.ToString());<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">// Send minfied string to output stream<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">byte</span>[] bt = <span style="color: #2b91af;">Encoding</span>.UTF8.GetBytes(minified);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> writer.Write(bt, 0, bt.Length);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">//cache the respose so that in next request it can be reused<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">byte</span>[] responseBytes = memStream.ToArray();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">//context.Cache.Insert(GetCacheKey(xStrSet, xStrType, xStrVer, xBlnCanCompress), responseBytes, null, System.Web.Caching.Cache.NoAbsoluteExpiration, CACHE_DURATION);<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: green;">// Generate the response<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">this</span>.WriteBytes(responseBytes, xBlnCanCompress, xStrType);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: blue;">bool</span> CanClientGZip(<span style="color: #2b91af;">HttpRequest</span> request){</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">string</span> acceptEncoding = request.Headers[<span style="color: #a31515;">"Accept-Encoding"</span>];<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (!<span style="color: blue;">string</span>.IsNullOrEmpty(acceptEncoding) &amp;&amp;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> (acceptEncoding.Contains(<span style="color: #a31515;">&#8220;gzip&#8221;</span>) || acceptEncoding.Contains(<span style="color: #a31515;">&#8220;deflate&#8221;</span>)))<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">return </span><span style="color: blue;">true</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">return</span><span style="color: blue;"> </span><span style="color: blue;">false</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: green;">// helper method that return an array of file names inside the text file stored in App_Data folder<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: blue;">static</span><span style="color: blue;"> </span><span style="color: blue;">string</span>[] GetFileNames(<span style="color: blue;">string</span> setName, <span style="color: blue;">string</span> pagecode, <span style="color: blue;">string</span> type)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {System.Xml.XPath.<span style="color: #2b91af;">XPathDocument</span> doc2;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> System.Xml.XPath.<span style="color: #2b91af;">XPathNavigator</span> navigator;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> System.Xml.XPath.<span style="color: #2b91af;">XPathNodeIterator</span> iterator;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> System.Collections.Generic.<span style="color: #2b91af;">List</span>&lt;<span style="color: blue;">string</span>&gt; scripts = <span style="color: blue;">new</span> System.Collections.Generic.<span style="color: #2b91af;">List</span>&lt;<span style="color: blue;">string</span>&gt;();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">string</span> key;</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">if</span> (type == <span style="color: #a31515;">&#8220;js&#8221;</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> key = <span style="color: #a31515;">&#8220;scriptfile&#8221;</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> key = <span style="color: #a31515;">&#8220;cssfile&#8221;</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (System.Web.<span style="color: #2b91af;">HttpContext</span>.Current.Cache[key] != <span style="color: blue;">null</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {doc2 = (System.Xml.XPath.<span style="color: #2b91af;">XPathDocument</span>)System.Web.<span style="color: #2b91af;">HttpContext</span>.Current.Cache[key];</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">string</span> filename;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> filename = System.Web.<span style="color: #2b91af;">HttpContext</span>.Current.Server.MapPath(<span style="color: #2b91af;">String</span>.Format(<span style="color: #a31515;">&#8220;~/App_Data/{0}.xml&#8221;</span>, setName));<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> doc2 = <span style="color: blue;">new</span> System.Xml.XPath.<span style="color: #2b91af;">XPathDocument</span>(filename);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> System.Web.<span style="color: #2b91af;">HttpContext</span>.Current.Cache.Insert(key, doc2, <span style="color: blue;">new</span> System.Web.Caching.<span style="color: #2b91af;">CacheDependency</span>(filename), <span style="color: #2b91af;">DateTime</span>.Now.AddMinutes(60), <span style="color: #2b91af;">TimeSpan</span>.Zero);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;">navigator = doc2.CreateNavigator();</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">if</span> (type == <span style="color: #a31515;">&#8220;js&#8221;</span>)</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;">iterator = navigator.Select(<span style="color: #a31515;">&#8220;/scripts/page[@pagecode='"</span> + pagecode + <span style="color: #a31515;">"']/script&#8221;</span>);</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> iterator = navigator.Select(<span style="color: #a31515;">&#8220;/styles/page[@pagecode='"</span> + pagecode + <span style="color: #a31515;">"']/style&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">while</span> (iterator.MoveNext())<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> scripts.Add(iterator.Current.InnerXml);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">return</span> scripts.ToArray();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: blue;">string</span> GetCacheKey(<span style="color: blue;">string</span> type, <span style="color: blue;">string</span> setName, <span style="color: blue;">string</span> version, <span style="color: blue;">bool</span> cancompress)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">return</span><span style="color: blue;"> </span><span style="color: #a31515;">&#8220;HttpCombiner.&#8221;</span> + setName + <span style="color: #a31515;">&#8220;.&#8221;</span> + type + <span style="color: #a31515;">&#8220;.&#8221;</span> + version + <span style="color: #a31515;">&#8220;.&#8221;</span> + cancompress;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">private</span><span style="color: blue;"> </span><span style="color: blue;">void</span> WriteBytes(<span style="color: blue;">byte</span>[] bytes, <span style="color: blue;">bool</span> isCompressed, <span style="color: blue;">string</span> type)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: #2b91af;">HttpResponse</span> response = context.Response;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.AppendHeader(<span style="color: #a31515;">&#8220;Content-Length&#8221;</span>, bytes.Length.ToString());<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (type == <span style="color: #a31515;">&#8220;js&#8221;</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.ContentType = <span style="color: #a31515;">&#8220;application/x-javascript&#8221;</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.ContentType = <span style="color: #a31515;">&#8220;text/css&#8221;</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (isCompressed)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.AppendHeader(<span style="color: #a31515;">&#8220;Content-Encoding&#8221;</span>, <span style="color: #a31515;">&#8220;gzip&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.AppendHeader(<span style="color: #a31515;">&#8220;Content-Encoding&#8221;</span>, <span style="color: #a31515;">&#8220;utf-8&#8243;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> context.Response.Cache.SetCacheability(<span style="color: #2b91af;">HttpCacheability</span>.Public);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> context.Response.Cache.SetExpires(<span style="color: #2b91af;">DateTime</span>.Now.Add(CACHE_DURATION));<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> context.Response.Cache.SetMaxAge(CACHE_DURATION);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.ContentEncoding = <span style="color: #2b91af;">Encoding</span>.Unicode;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.OutputStream.Write(bytes, 0, bytes.Length);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> response.Flush();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">static</span><br />
<span style="color: blue;">string</span> GetScriptTag(<span style="color: blue;">string</span> setname, <span style="color: blue;">string</span> pageid, <span style="color: blue;">string</span> type, <span style="color: blue;">string</span> ver)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">string</span> result = <span style="color: #a31515;">&#8220;&#8221;</span>;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">if</span> (type == <span style="color: #a31515;">&#8220;js&#8221;</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> result += <span style="color: #2b91af;">String</span>.Format(<span style="color: #a31515;">&#8220;&lt;script type=\&#8221;text/javascript\&#8221; src=\&#8221;/&#8221;</span> + Web.Utility.Functions.GetURLPrefix() + <span style="color: #a31515;">&#8220;ScriptCombiner.axd?s={0}&amp;v={1}&amp;type=js&amp;pcode={2}\&#8221;&gt;&lt;/script&gt;&#8221;</span>, setname, ver, pageid);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> result += <span style="color: #2b91af;">String</span>.Format(<span style="color: #a31515;">&#8220;&lt;link link href=\&#8221;ScriptCombiner.axd?s={0}&amp;v={1}&amp;type=css&amp;pcode={2}\&#8221; rel=\&#8221;stylesheet\&#8221; type=\&#8221;text/css\&#8221;/&gt;&#8221;</span>, setname, ver, pageid);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">return</span> result;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">public</span><span style="color: blue;"> </span><span style="color: blue;">static</span><span style="color: blue;"> </span><span style="color: blue;">string</span> CompressCSS(<span style="color: blue;">string</span> body)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = <span style="color: #2b91af;">Regex</span>.Replace(body, <span style="color: #a31515;">&#8220;/\\*.+?\\*/&#8221;</span>, <span style="color: #a31515;">&#8220;&#8221;</span>, <span style="color: #2b91af;">RegexOptions</span>.Singleline);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8221;  &#8220;</span>, <span style="color: blue;">string</span>.Empty);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #2b91af;">Environment</span>.NewLine + <span style="color: #2b91af;">Environment</span>.NewLine + <span style="color: #2b91af;">Environment</span>.NewLine, <span style="color: blue;">string</span>.Empty);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #2b91af;">Environment</span>.NewLine + <span style="color: #2b91af;">Environment</span>.NewLine, <span style="color: #2b91af;">Environment</span>.NewLine);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #2b91af;">Environment</span>.NewLine, <span style="color: blue;">string</span>.Empty);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8220;\\t&#8221;</span>, <span style="color: blue;">string</span>.Empty);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8221; {&#8220;</span>, <span style="color: #a31515;">&#8220;{&#8220;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8221; :&#8221;</span>, <span style="color: #a31515;">&#8220;:&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8220;: &#8220;</span>, <span style="color: #a31515;">&#8220;:&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8220;, &#8220;</span>, <span style="color: #a31515;">&#8220;,&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8220;; &#8220;</span>, <span style="color: #a31515;">&#8220;;&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = body.Replace(<span style="color: #a31515;">&#8220;;}&#8221;</span>, <span style="color: #a31515;">&#8220;}&#8221;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = <span style="color: #2b91af;">Regex</span>.Replace(body, <span style="color: #a31515;">&#8220;/\\*[^\\*]*\\*+([^/\\*]*\\*+)*/&#8221;</span>, <span style="color: #a31515;">&#8220;$1&#8243;</span>);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> body = <span style="color: #2b91af;">Regex</span>.Replace(body, <span style="color: #a31515;">&#8220;(?&lt;=[&gt;])\\s{2,}(?=[&lt;])|(?&lt;=[&gt;])\\s{2,}(?=&amp;nbsp;)|(?&lt;=&amp;ndsp;)\\s{2,}(?=[&lt;])&#8221;</span>, <span style="color: blue;">string</span>.Empty);<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">return</span> body;<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p>You are now almost done with 50% of work for your project.</p>
<p>Now let&#8217;s take a look at the few of important execution steps that are in this function.</p>
<p>First of all we are declaring four different string variables:</p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">string</span> xStrType, xStrSet, xStrVer, xStrpagecode;<br />
</span></p>
<p>They will be used to get the Querystring passed in to this handler. This is utilized later on the code.</p>
<p>Moving next, you will find these function call:</p>
<p><span style="color: green; font-family: Courier New; font-size: 10pt;">//first check if client browser can support compressions<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> xBlnCanCompress = CanClientGZip(request);<br />
</span></p>
<p>This is basically to check does client browser support GZip compression.</p>
<p>Gzip compression, otherwise known as content encoding, is a publicly defined way to compress textual content transferred from web servers to browsers. HTTP compression uses public domain compression algorithms, like gzip and compress, to compress XHTML, JavaScript, CSS, and other text files at the server. This standards-based method of delivering compressed content is built into HTTP 1.1, and most modern browsers that support HTTP 1.1 support ZLIB inflation of deflated documents. In other words, they can decompress compressed files automatically, which saves time and bandwidth.</p>
<p>In the next step it is preparing the <em>stream</em> object used to hold the response output. We will not take dipper look into that code. As I expect that the a beginning developer even must be able know about next few line of code. <span style="font-family: Wingdings;">J</span></p>
<p>Let&#8217;s move to the line of code:</p>
<p><span style="color: green; font-family: Courier New; font-size: 10pt;">//now its time to read all the script/css files into a StringBuilder object.<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><br />
<span style="color: #2b91af;">StringBuilder</span> combinedSource = <span style="color: blue;">new</span><br />
<span style="color: #2b91af;">StringBuilder</span>();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> file <span style="color: blue;">in</span> GetFileNames(xStrSet, xStrpagecode, xStrType))<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> combinedSource.Append(System.IO.<span style="color: #2b91af;">File</span>.ReadAllText(context.Server.MapPath(file), <span style="color: #2b91af;">Encoding</span>.UTF8));<br />
</span></p>
<p>As you can see in the foreach loop, it is calling to method <span style="font-family: Courier New; font-size: 10pt;">GetFileNames, </span>by passing 3 different parameters. Here this is also core and important part of this project. Let me outline you first what this function basically do. This function will read to the &#8220;script.xml&#8221; file that hold content of script file that we want to load. Please look inside the attached project solution to understand it better. The function will read xml file and return array of string object containing JavaScript files to read.</p>
<p>In the subsequent line of code, it iterate through each file name and read it. Each content of read file is placed inside a <span style="color: #2b91af; font-family: Courier New; font-size: 10pt;">StringBuilder </span>object.</p>
<p>Please take look at the code inside the <span style="font-family: Courier New; font-size: 10pt;">GetFileNames </span>function to understand what is actually happening inside it. It fetches the JavaScript/CSS based on the parameter passed. And return either the JavaScript file name array or CSS file name array.</p>
<p>So now we have a combined script/CSS with us. It&#8217;s a time to minify JavaScript/CSS now.</p>
<p>Following line of code will minify respective JavaScript/CSS based on type of client script requested.</p>
<p><span style="color: green; font-family: Courier New; font-size: 10pt;">//use the YUI Javascript/CSS minifier to compress all js files<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"><br />
<span style="color: blue;">if</span> (xStrType == <span style="color: #a31515;">&#8220;js&#8221;</span>)<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: #2b91af;">JavaScriptMinifier</span> minifier = <span style="color: blue;">new</span><br />
<span style="color: #2b91af;">JavaScriptMinifier</span>();<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> minified = minifier.Minify(combinedSource.ToString());<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> <span style="color: blue;">else<br />
</span></span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> {<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> minified = CompressCSS(combinedSource.ToString());<br />
</span></p>
<p><span style="font-family: Courier New; font-size: 10pt;"> }<br />
</span></p>
<p>The <span style="color: #2b91af; font-family: Courier New; font-size: 10pt;">JavaScriptMinifier </span>has been created in the 2<sup>nd</sup> step. Please refer to the attached solution project for more detail regarding this class file. I have adopted this class file from one of the article</p>
<p>You will also see function <span style="font-family: Courier New; font-size: 10pt;">CompressCSS </span>that is used to compress CSS file. The compressor of CSS file is done through just few regular expression. JavaScript compression has different algorithm.</p>
<p>After that it is calling to <span style="font-family: Courier New; font-size: 10pt;">WriteBytes </span>function that will prepare the combined &amp; compressed JavaScript &amp; CSS response and send it to the client.</p>
<p>Hurray… as part of implementation we are done.</p>
<p>Now it&#8217;s time to check that in action. You can run the project attached here with and check it In live action.</p>
<p>To download complete project, <a href="http://www.esnips.com/doc/bb247398-9971-4fac-bb8e-02a8e8ebad7d/JS-CSS-Combiner-Minifier">click here</a></p>
<p>Let&#8217;s compare the result of two different pages. The first one is with the compressed JavaScript &amp; CSS. The second one is with the normal JavaScript &amp; CSS. We will also see the difference in load time and size of content received.</p>
<p>Response time with compressed JavaScript &amp; CSS.</p>
<p><img src="http://techinsight.dhanashree.com/article-images/040510_1059_CombineComp1.jpg" alt="" /></p>
<p>Response time without compressed JavaScript &amp; CSS.</p>
<p><img src="http://techinsight.dhanashree.com/article-images/040510_1059_CombineComp2.jpg" alt="" /></p>
<p>As you can see from given statistics</p>
<p>With Combined &amp; Compressed JavaScript and CSS ..</p>
<p>Total request: 3</p>
<p>Response size: 16.3 KB</p>
<p>Without Combined &amp; Compressed JavaScript and CSS ..</p>
<p>Total request: 5</p>
<p>Response size: 96 KB</p>
<p>You can clearly see the difference between these two request.</p>
<p>To get more idea open and run the project yourself. That will give you better idea.</p>
<p>Hope you will find it very useful.</p>
<p>Happy coding…. <span style="font-family: Wingdings;">J</span></p>
<p><span style="font-family: Calibri; font-size: 15px; color: #ff0000;">NOTE<span style="mso-spacerun: yes;"> </span>:</span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><br />
<span style="font-family: Calibri;">NOTE<span style="mso-spacerun: yes;"> </span>: Also visit <a href="http://www.dhanashree.com">www.dhanashree.com</a></span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><br />
<a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;"><br />
Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/combinecompressminify-javascript-css-in-asp-net/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>Understanding asp.net MVC (Model View Controller) architecture</title>
		<link>http://techinsight.dhanashree.com/understanding-asp-net-mvc-model-view-controller-architecture/</link>
		<comments>http://techinsight.dhanashree.com/understanding-asp-net-mvc-model-view-controller-architecture/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 06:21:38 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[.net framework]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[.net developement]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/understanding-asp-net-mvc-model-view-controller-architecture/</guid>
		<description><![CDATA[This article is intended to provide basic concept and fundamentals of asp.net MVC (Model View Controller) architecture workflow for beginners.
Introduction:

&#8220;M&#8221;  &#8220;V&#8221;   &#8220;C&#8221;  stands for &#8220;MODEL&#8221;  &#8220;VIEW&#8221; &#8220;CONTROLLER&#8221; , asp.net MVC is an architecture to develop asp.net web applications in a different manner than the traditional asp.net web development , web [...]]]></description>
			<content:encoded><![CDATA[<p>This article is intended to provide basic concept and fundamentals of asp.net MVC (Model View Controller) architecture workflow for beginners.</p>
<p><span style="text-decoration: underline;">Introduction:<br />
</span></p>
<p>&#8220;M&#8221;  &#8220;V&#8221;   &#8220;C&#8221;  stands for &#8220;MODEL&#8221;  &#8220;VIEW&#8221; &#8220;CONTROLLER&#8221; , asp.net MVC is an architecture to develop asp.net web applications in a different manner than the traditional asp.net web development , web applications developed with asp.net MVC is even more SEO (Search Engine Friendly ) friendly.</p>
<p>Developing asp.net MVC application requires Microsoft .net framework 3.5 or higher.</p>
<p><span style="text-decoration: underline;">MVC interaction with browser:<br />
</span></p>
<p>Like a normal web server interaction, MVC application also accept request and respond web browser same way.</p>
<p><img src="http://techinsight.dhanashree.com/article-images/020510_0621_Understandi1.png" alt="" /></p>
<p><span style="text-decoration: underline;">Inside MVC architecture:<br />
</span></p>
<p>Whole asp.net MVC architecture is based on Microsoft .net framework 3.5 and in addition uses LINQ to SQL Server.</p>
<p><strong>What is a Model? </strong></p>
<ol>
<li>MVC <strong>model</strong> is basically a C# or VB.net class</li>
<li>A <strong>model</strong> is accessible by both <strong>controller</strong> and <strong>view</strong></li>
<li>A <strong>model</strong> can be used to pass data from <strong>Controller</strong> to <strong>view</strong>.</li>
<li>A <strong>view</strong> can use model to display data in page.</li>
</ol>
<p><strong>What is a View?<br />
</strong></p>
<ol>
<li>View is an ASPX page without having a code behind file</li>
<li>All page specific HTML generation and formatting can be done inside view</li>
<li>One can use Inline code (server tags ) to develop dynamic pages</li>
<li>A request to <strong>view</strong> (ASPX page) can be made only from a controller&#8217;s action method</li>
</ol>
<p><strong>What is a Controller?<br />
</strong></p>
<ol>
<li><strong>Controller</strong> is basically a C# or VB.net class which inherits <strong>system.mvc.controller</strong></li>
<li><strong>Controller</strong> is a heart of whole MVC architecture</li>
<li>Inside<strong> Controller&#8217;s class </strong>action methods can be implemented which is responsible for responding to browser OR calling view&#8217;s.<strong><br />
</strong></li>
<li><strong>Controller</strong> can access and use <strong>model</strong> class to pass data to <strong>view&#8217;s<br />
</strong></li>
<li><strong>Controller </strong>uses <strong>ViewData </strong>to pass any data to <strong>view</strong></li>
</ol>
<p><img src="http://techinsight.dhanashree.com/article-images/020510_0621_Understandi2.png" alt="" /></p>
<h3><span style="text-decoration: underline;"><span style="font-weight: normal;">MVC file structure &amp; file naming standards</span><br />
</span></h3>
<p>MVC uses a standard directory structure and file naming standards which is very important part of MVC application development.</p>
<p>Inside the ROOT directory of the application there must be 3 directories each for model, view and Controller.</p>
<p>Apart from 3 directories there must have a <strong>Global.asax </strong>file in root folder. And a web.config like a traditional asp.net application.</p>
<ul>
<li>
<div><strong>Root </strong>[directory]<strong><br />
</strong></div>
<ul>
<li>
<div><strong>Controller</strong> [directory]</div>
<ul>
<li>Controller CS files</li>
</ul>
</li>
<li>
<div><strong>Models</strong> [directory]</div>
<ul>
<li>Model CS files</li>
</ul>
</li>
<li>
<div><strong>Views </strong>[directory]<strong><br />
</strong></div>
<ul>
<li>View CS files<strong><br />
</strong></li>
</ul>
</li>
<li>Global.asax</li>
<li>Web.config</li>
</ul>
</li>
</ul>
<p><span style="text-decoration: underline;">Asp.net MVC Execution life cycle<br />
</span></p>
<p>Here is how MVC architecture executes the requests to browser and objects interactions with each other.</p>
<p>A step by step process is explained below:  <strong>[Refer figure as given below]</strong></p>
<p><img src="http://techinsight.dhanashree.com/article-images/020510_0621_Understandi3.png" alt="" /></p>
<p><span style="color: #0070c0;"><strong>Step 1: </strong><br />
<strong>Browser request</strong><br />
</span></p>
<p>Browser request happens with a specific URL. Let&#8217;s assume that user entering URL like: [xyz.com]/home/index/</p>
<p><span style="color: #0070c0;"><strong>Step 2:  Job of Global.asax &#8211; MVC routing<br />
</strong></span></p>
<p>The specified URL will first get parsed via application_start() method inside Global.asax file. From the requested URL it will parse the <strong>Controller, Action and ID.<br />
</strong></p>
<p>So for [xyz.com]/home/index/:</p>
<p>Controller = home</p>
<p>Action = index()</p>
<p>ID = empty  &#8212; we have not specified ID in [xyz.com]/home/index/, so it will consider as empty string</p>
<p><span style="color: #0070c0;"><strong>Step 3:  Controller and Action methods<br />
</strong></span></p>
<p>MVC now find the <strong>home controller</strong> class in controller directory.  A controller class contains different action methods,</p>
<p>There can be more than one action method, but MVC will only invokes the action method which is been parsed from the URL, its index() in our case.</p>
<p>So something like: <strong>homeController.index() </strong>will happen inside MVC controller class.</p>
<p>Invoking action method can return plain text string OR rendered HTML by using view.</p>
<p><span style="color: #0070c0;"><strong>Step 4:  Call to View (ASPX page)<br />
</strong></span></p>
<p>Invoking view will return <strong>view()</strong> . a call to view will access the particular ASPX page inside the view directory and generate the rendered HTML from the ASPX and will respond back to the browser.</p>
<p>In our case controller was <strong>home </strong>and action was <strong>index().</strong> So calling view() will return a rendered HTML from the ASPX page located at <strong>/views/home/index.aspx.<br />
</strong></p>
<p><strong>This is it, the whole process ends here. So this is how MVC architecture works.</strong></p>
<p><span style="font-family: Calibri; font-size: 15px; color: #ff0000;">NOTE<span style="mso-spacerun: yes;"> </span>:</span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/understanding-asp-net-mvc-model-view-controller-architecture/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Dot Net framework 3.5, C#, VB.Net Language Improvements: Automatic Properties, Object initializers, Collection Initializers, Lambda expression, Anonymous type</title>
		<link>http://techinsight.dhanashree.com/dot-net-framework-3-5-c-vb-net-language-improvements-automatic-properties-object-initializers-collection-initializers-lambda-expression-anonymous-type/</link>
		<comments>http://techinsight.dhanashree.com/dot-net-framework-3-5-c-vb-net-language-improvements-automatic-properties-object-initializers-collection-initializers-lambda-expression-anonymous-type/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 11:15:52 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.net 3.5]]></category>
		<category><![CDATA[.net framework]]></category>
		<category><![CDATA[Tools & Technology]]></category>
		<category><![CDATA[.net developement]]></category>

		<guid isPermaLink="false">http://techinsight.dhanashree.com/?p=167</guid>
		<description><![CDATA[The new .net 3.5 has significant improved features. This feature makes the .net programming concept more sophisticated. You will now be able to write less code and build more dynamic application using those.
From all of them what the most I like is the LINQ, which allow you to query over variety of objects.
LINQ is all [...]]]></description>
			<content:encoded><![CDATA[<p>The new .net 3.5 has significant improved features. This feature makes the .net programming concept more sophisticated. You will now be able to write less code and build more dynamic application using those.</p>
<p>From all of them what the most I like is the LINQ, which allow you to query over variety of objects.</p>
<p>LINQ is all about queries, they returns a set of matching objects, a single object, or a subset of fields from an object or set of objects. In LINQ, this returned set of objects is called a <em>sequence</em>.</p>
<p>Basically LINQ comes in variety of flavors’ like following:</p>
<ul>
<li>LINQ to Objects</li>
<li>LINQ to XML</li>
<li>LINQ to Dataset</li>
<li>LINQ to SQL</li>
<li>LINQ to Entities</li>
</ul>
<p>Well there is a detailed discussion on LINQ further in this article. Let me first make you guys introduce to the language improvements in .net 3.5. In fact I believe that these new improvements are essential to learn before we actually get dig into the LINQ J.</p>
<p>To summarize quickly, here are the list of new language feature that are shipped with .Net 3.5.</p>
<ul>
<li>Automatic properties</li>
<li>Object initializers, Collection initializers</li>
<li>Anonymous types</li>
<li>Extension methods</li>
<li>Query Expression</li>
</ul>
<p>Well if you are the C# developer, I believe you will really love to have such significant improvement. Because these features puts extra wing on your programming skill.</p>
<p>The important is not that you learn the latest technology of .Net 3.5 like WCF, WPF, Silverlight etc. These are the core part of basic programming. Its like you should be knowing the if syntax of C programming language before you actually write your first “Hello word” program J</p>
<p>So let’s go through each of them step by step and try to understand what they are and how it can help the developer to create rich internet/desktop application.</p>
<ul>
<li><strong>Automatic Property</strong></li>
</ul>
<p>Before I explain you the concept of “automatic property in .net 3.5, can you guys first please try to go through the following code?</p>
<p>public class MShoppingCart</p>
<p>{</p>
<p>private int _cartId;</p>
<p>public int CartId</p>
<p>{</p>
<p>get { return _cartId; }</p>
<p>set { _cartId = value; }</p>
<p>}</p>
<p>private int _customerid;</p>
<p>public int Customerid</p>
<p>{</p>
<p>get { return _customerid; }</p>
<p>set { _customerid = value; }</p>
<p>}</p>
<p>private int _billingaddressid;</p>
<p>public int Billingaddressid</p>
<p>{</p>
<p>get { return _billingaddressid; }</p>
<p>set { _billingaddressid = value; }</p>
<p>}</p>
<p>private int _shippingaddressid;</p>
<p>public int Shippingaddressid</p>
<p>{</p>
<p>get { return _shippingaddressid; }</p>
<p>set { _shippingaddressid = value; }</p>
<p>}</p>
<p>private MShippingCartItem _cartitem;</p>
<p>public MShippingCartItem Cartitem</p>
<p>{</p>
<p>get { return _cartitem; }</p>
<p>set { _cartitem = value; }</p>
<p>}</p>
<p>}</p>
<p>Most of the time we are used to write such model classes. This are the most basic and popular mechanism in returning a wrapper classes. The basic purpose of writing such getter/setter property is to hide the actual private member of our classes. It has been the standard pattern to access the private method of any classes. Well you may arise with a question that why do we actually need to write such getter/setter properties. Can’t we simply expose the private member? Well the answer is YES, but I would request you to remember the fundamental of object oriented programming. J</p>
<p>Anyway there are basically two reason of not doing so. Following are this:</p>
<ol>
<li>You won’t be easily able to bind those private variable to controls</li>
<li>You will not be able to modify them into property later on.</li>
</ol>
<p>The first point is quite understandable, what do you mean by the second one? Well, say for e.g. if you need to add any business logic or validation logic when assigning value to any private variable then? You will not be able to do that.</p>
<p>So what if we need not to write even the private variables? Exited, yes the new version of .Net 3.5 allows you have such facility. The concept is called automatic property. All you have to do is to write the getter/setter property. You need not to worry about the private member of that property. The compiler will decide and prepare base private member for you on the fly.</p>
<p>See the example in the following.</p>
<p>public class MShoppingCart</p>
<p>{</p>
<p>public int CartId</p>
<p>{</p>
<p>get;</p>
<p>set;</p>
<p>}</p>
<p>public int Customerid</p>
<p>{</p>
<p>get;</p>
<p>set;</p>
<p>}</p>
<p>public int Billingaddressid</p>
<p>{</p>
<p>get;</p>
<p>set;</p>
<p>}</p>
<p>public int Shippingaddressid</p>
<p>{</p>
<p>get;</p>
<p>set;</p>
<p>}</p>
<p>private MShippingCartItem _cartitem;</p>
<p>public MShippingCartItem Cartitem</p>
<p>{</p>
<p>get;</p>
<p>set;</p>
<p>}</p>
<p>}</p>
<p>Now it this case when the compiler will encounter this properties while compiling your code, it will automatically expose the private variable for each of property with its associated type. For e.g. compiler automatically assume and expose the <em>_cartid</em> private variable of integer type. Using advantage of this is we need not to worry about the underlying private variable. In future we can add any sort of validation logic in this property.</p>
<ul>
<li><strong>Object initialization, collection initialization</strong></li>
</ul>
<p>I would like to explain this concept by taking the example of automatic property so that I maintain the continuity for you to understand. Say for e.g. when we want to use the “shopping cart” class that we created earlier. What we do is write following code.</p>
<p>MShoppingCart cart = new MShoppingCart();</p>
<p>cart.CartId = 1;</p>
<p>cart.Customerid = 1001111;</p>
<p>cart.Shippingaddressid = 2333;</p>
<p>cart.Billingaddressid = 2232;</p>
<p>With the feature supported by the .net framework 3.5, you can take advantage of what is called “syntactic sugar”, and that is object initializers.</p>
<p>Using object initializers, you can write the same code given above, in following way.</p>
<p>MShoppingCart cart = new MShoppingCart {CartId =1, Customerid=1001111, Billingaddressid=2232, Shippingaddressid =23333  };</p>
<p>So it allows you to pass the value of all property at the time of initializing the object.</p>
<p>In fact it not only allow to initialize object’s property in this way, you can also have nested initialization of object within any object.</p>
<p>To demonstrate you, see the following example.</p>
<p>MShoppingCart cart = new MShoppingCart { CartId = 1, Customerid = 1001111, Billingaddressid = 2232, Shippingaddressid = 23333, <strong><span style="text-decoration: underline;">Cartitem = new MShippingCartItem { }</span></strong> };</p>
<p>If you see in the highlighted (underlined) part of above code, you can clearly see that the child object can also be initialized in the same way.</p>
<p>As if the new object initialization enhancements were not enough, someone at Microsoft must have said, “What about collections?” Collection initialization allows you to specify the initialization values for a collection, just like you would do for an object, as long as the collection implements the</p>
<p>System.Collections.Generic.ICollection&lt;T&gt; interface.</p>
<p>List&lt;string&gt; presidents = new List&lt;string&gt; { &#8220;Name 1&#8243;, &#8220;Name 2&#8243;, &#8220;Name 3&#8243; };</p>
<p>foreach (string president in presidents)</p>
<p>{</p>
<p>Console.WriteLine(president);</p>
<p>}</p>
<ul>
<li><strong>Anonymous types</strong></li>
</ul>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p>What is anonymous type?</p>
<p>Well, we have been familiar till date with different types. They are either custom classes or any of .net’s build in type. So what is actually the anonymous type is. The answer is that the “Anonymous type” has no type defined to it. It has no type name. Though there should be at least one type name associated in .Net. In anonymous type, the type name is specified by the developer doing the programming. It is the compiler which will identify the type to associate with the declaration of any anonymous type.</p>
<p>There is also another significant different in anonymous type is that it is called <em>immutable</em>. The definition of immutable type is that the one that is declared and initialized once. It can’t be altered later on. So anonymous type has the same characteristic. Once you declared and initialized, you can’t alter the anonymous type afterward.</p>
<p>This is also why anonymous types have been introduced. They allow us to create a type on the fly and therefore return only certain values of a given named type. This is very handy when only a subset of properties is needed, properties are joined together or even objects are joined together.</p>
<p>class Program</p>
<p>{</p>
<p>static void Main(string[] args)</p>
<p>{</p>
<p>// create a list of carts with dummy data.</p>
<p>List&lt;MShoppingCart&gt; carts = new List&lt;MShoppingCart&gt;();</p>
<p>carts.Add(new MShoppingCart { CartId=101, Customerid=1001, Billingaddressid=20, Shippingaddressid =30});</p>
<p>carts.Add(new MShoppingCart { CartId = 102, Customerid = 1002, Billingaddressid = 22, Shippingaddressid = 33 });</p>
<p>carts.Add(new MShoppingCart { CartId=103, Customerid=1003, Billingaddressid=23, Shippingaddressid =34});</p>
<p>// query the cart collection to collect cart with id of 101</p>
<p>var result = from c in carts</p>
<p>where c.CartId &gt;= 101</p>
<p>// put the result in a anonymous type</p>
<p>select new { c.Billingaddressid  };</p>
<p>// loop over the result.</p>
<p>foreach (var item in result)</p>
<p>{</p>
<p>// print out the name of the item.</p>
<p>Console.WriteLine(item.Billingaddressid );</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>Anonymous type are mostly used when working with the LINQ. It is utilized highly while querying to your data in LINQ. It is irrespective which flavor of LINQ you are using.</p>
<p>Although the anonymous type can be used in your own code also. It is especially useful when we want to combine different variables into one.</p>
<p>Se for e.g. following example:</p>
<p>// create an anonymous type instance with a name.</p>
<p>var anonymousType = new</p>
<p>{</p>
<p>Name = name,</p>
<p>Age = age,</p>
<p>Nationality = nationality</p>
<p>};</p>
<p>// print the name to the console.</p>
<p>Console.WriteLine(anonymousType.Name);</p>
<p>Though the real time use of anonymous type Is when you use it with the LINQ. I need to write a separate article to demonstrate you actual usage LINQ. J</p>
<ul>
<li><strong>Extension methods</strong></li>
</ul>
<p><strong> </strong></p>
<p>An extension method is a static method of a static class that you can call as though it were an instance method of a different class.</p>
<p>To make you understand the extension method, let me first re cape the class level methods (static methods) and instance methods. The primary different between these two is that the instance method can also be access by initializing object of any class. It can’t be invoked by using class name only. The exact opposite of that is class method. You can only call static class method using the name of class only. You can’t access them using the instance of same class.</p>
<p>I am not gonna give you any example for the above explanation as I expect from you guys that you are familiar with the different I explained.</p>
<p>Extension method is a way of extending existing classes for whatever additional functionality. Let me demonstrate you that by example.</p>
<p>namespace ExtensionMethods</p>
<p>{</p>
<p>public static class StringExtensionMethods</p>
<p>{</p>
<p>public static bool IsNumeric(this string str)</p>
<p>{</p>
<p>try</p>
<p>{</p>
<p>int i = int.Parse(str);</p>
<p>return true;</p>
<p>}</p>
<p>catch</p>
<p>{</p>
<p>}</p>
<p>return false;</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>In the above given example, almost everything seems to be similar what we are used to in normal programming. But, the difference is clearly seen. You should be able to notice that in the “IsNumeric” static method parameter are passed using <em>this </em>keyword. This keyword tells the compiler what you are going to extend for particular given type. So in this example it tells you that it extends the existing string class.</p>
<p>See for e.g. how to use the extension method.</p>
<p>string s = &#8220;someValue&#8221;;</p>
<p>bool bs = s.IsNumeric();</p>
<p>// bs is false;</p>
<p>string i = &#8220;7&#8243;;</p>
<p>bool bi = i.IsNumeric();</p>
<p>// bi is true;</p>
<ul>
<li><strong>Query Expression</strong></li>
</ul>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p>One of the conveniences that the C# language provides is the foreach statement. When you use foreach, the compiler translates it into a loop with calls to and MoveNext. The simplicity the foreach statement provides for enumerating through arrays and collections has made it very popular and often used.</p>
<p>One of the features of LINQ that seems to attract developers is the SQL-like syntax available for LINQ queries. The first few LINQ examples in the first chapter of this book use this syntax. This syntax is provided via the new C# 3.0 language enhancement known as query expressions. Query expressions allow LINQ queries to be expressed in nearly SQL form. To perform a LINQ query, it is not required to use query expressions. The alternative is to use standard C# dot notation, calling methods on objects and classes.</p>
<p>Although it is occupy a dedicated book for detail understanding of query expression with LINQ. Just to summarize you, here is the example that shows you what actually query expression does.</p>
<p>For e.g.</p>
<p>string[] names = {</p>
<p>&#8220;Adams&#8221;, &#8220;Arthur&#8221;, &#8220;Buchanan&#8221;, &#8220;Bush&#8221;, &#8220;Carter&#8221;, &#8220;Cleveland&#8221;,</p>
<p>&#8220;Clinton&#8221;, &#8220;Coolidge&#8221;, &#8220;Eisenhower&#8221;, &#8220;Fillmore&#8221;, &#8220;Ford&#8221;, &#8220;Garfield&#8221;,</p>
<p>&#8220;Grant&#8221;, &#8220;Harding&#8221;, &#8220;Harrison&#8221;, &#8220;Hayes&#8221;, &#8220;Hoover&#8221;, &#8220;Jackson&#8221;,</p>
<p>&#8220;Jefferson&#8221;, &#8220;Johnson&#8221;, &#8220;Kennedy&#8221;, &#8220;Lincoln&#8221;, &#8220;Madison&#8221;, &#8220;McKinley&#8221;,</p>
<p>&#8220;Monroe&#8221;, &#8220;Nixon&#8221;, &#8220;Pierce&#8221;, &#8220;Polk&#8221;, &#8220;Reagan&#8221;, &#8220;Roosevelt&#8221;, &#8220;Taft&#8221;,</p>
<p>&#8220;Taylor&#8221;, &#8220;Truman&#8221;, &#8220;Tyler&#8221;, &#8220;Van Buren&#8221;, &#8220;Washington&#8221;, &#8220;Wilson&#8221;};</p>
<p>IEnumerable&lt;string&gt; sequence = from n in names</p>
<p>where n.Length &lt; 6</p>
<p>select n;</p>
<p>foreach (string name in sequence)</p>
<p>{</p>
<p>Console.WriteLine(&#8220;{0}&#8221;, name);</p>
<p>}</p>
<p>Though query expression can be used by two different way. 1) is using dot notation and 2) is using expression syntax.</p>
<p>Hope I could make you understand what are the new improvements in the newer version of .net 3.5.</p>
<p>Once you are aware and familiar with this feature, you are ready to get dig into dip into the word of .net 3.5 for all new existing experience in developing rich internet/enterprise application.</p>
<p>Best luck</p>
<p><span style="font-family: Calibri; font-size: 15px; color: #ff0000;">NOTE<span style="mso-spacerun: yes;"> </span>:</span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/dot-net-framework-3-5-c-vb-net-language-improvements-automatic-properties-object-initializers-collection-initializers-lambda-expression-anonymous-type/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Recommendation for developers</title>
		<link>http://techinsight.dhanashree.com/recommendation-for-developers/</link>
		<comments>http://techinsight.dhanashree.com/recommendation-for-developers/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 10:07:27 +0000</pubDate>
		<dc:creator>jatin</dc:creator>
				<category><![CDATA[Tools & Technology]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=83</guid>
		<description><![CDATA[
Generally, and most often many developer ask following normal questions:

“What do I do so I can become a full time web developer?”
Experienced developers often ask what I would recommend to help advance their careers or become an independent

These answers are not easy…it depends on your experience, your available time, and most importantly, your drive. The [...]]]></description>
			<content:encoded><![CDATA[<div style="font-family: Arial; font-size: 12px;">
<h1><span style="font-weight: normal; font-size: 12px;">Generally, and most often many <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer/dedicated-asp-net-developer" target="_blank">developer</a> ask following normal questions:</span></h1>
<ol>
<li>“What do I do so I can become a full time <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">web developer</a>?”</li>
<li><a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer/dedicated-asp-net-developer" target="_blank">Experienced developers</a> often ask what I would recommend to help advance their <a href="http://www.dhanashree.com/career-as-web-developer" target="_blank">careers</a> or become an independent</li>
</ol>
<p>These answers are not easy…it depends on your experience, your available time, and most importantly, your drive. The first 5 are for those of you just getting started and the last 5 are for the life of your career.</p>
<ul>
<li><strong>Find Good Resources</strong> – Whether it’s a friend, colleague, website forum or some online community, try to find at least one good resource. When I graduated college, most of my skills were <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">web development</a> related technologies. Specially <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">.net 2.0 technology</a>, <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">ASP</a>, VB, Sql Server and all that. My initial interest was on the networking side. Later on I switched to <a href="http://www.dhanashree.com/web-development-services" target="_blank">programming</a> and keep continue in that field. The most important advice would tell is to be in contact with your seniors. Your senior have vast amount of experienced behind them, which can really drive you a good path. I was always used to be in contact with my one of senior. And in fact I got inspiration from him only to go for the .net development. I developed a couple <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/ecommerce-development" target="_blank">ecommerce sites</a> and keep on learning on different <a href="http://techinsight.dhanashree.com/" target="_blank">web development technologies</a>. Specially I also love the dealing with <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">SQL</a>. So did few of certification also in that.</li>
<li><strong>Learn the Basics</strong> – All most in your every line of code you write, your most common tasks will include declaring variables, assigning values, performing calculations, looping through data, if…then…else, functions, etc. Every language supports these features and they must be mastered. Any “Introduction” book will cover these features in very good detail. If a book has at least a dozen reviews, see what the consensus says. Better yet, a good resource should be able to recommend a good starter book. I also highly recommend buying an introduction book for the language you plan on <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">developing</a> in. You might not know what that is, but you should have a good idea. You want to always be reading in the language you are learning…this may seem obvious, If you want to learn <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">C#</a>, make the investment of buying a good <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">C#</a> book. And don’t worry too much about choosing a language to start with…as I said above, the basics translate to any language…it’s just differences in the syntax.</li>
<li><strong>Follow the KISS Rule (Keep It Simple Stupid)</strong> – May time I come across such issue where <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer/dedicated-php-developer" target="_blank">developer</a> are involved in doing the changes in others work. When it come to modify some else <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">programming</a>, it become very tedious task to do. First any one need time to understand the logic implemented by others. If you put 1,000 programmers in a room and gave them even a simple coding task, not one person would code it the same. The question is, would everyone be able to read your <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">code</a>…and if you looked at it a few months later, would you be able to quickly read and understand it? There are a million ways to solve any problem; the best approach is to keep it simple. It makes it much easier to maintain and also decreases the chance of someone else breaking it.</li>
<li><strong>Test Your Learning By Implementing it</strong> – Reading and comprehending a subject isn’t that difficult….but can you really apply what you just learned? I have seen many peoples who can read for the hours and hours. But when you ask them what did he learned, he would be unanswered. I have a wonderful thought, that says: “What you see has no meaning when you don’t read it. It has no meaning of what you read until you understand it, and there is no important what you understand until you implement it”</li>
<li><strong>Plan your Code</strong> – Oh.. that’s real main important that I should more focus on, during my job I see many <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">developers</a>, in fact almost everyone are used to start coding straightway when they are given with specific module. <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer/dedicated-development-team" target="_blank">Developer </a>do not plan their coding before they begin it. They are generally very excited about <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">development</a> when they get something new to do. But that’s the not proper approach. It always lead to big mistakes. It either make you to long development time or I may lead to wrong development at the end. The very fundamental development life cycle approach MUST be followed. And that is called System Development Life Cycle (SDLC).
<ul>
<li>Project planning and feasibility study: Establish a high-level view of the project and determines its goals.</li>
<li>Systems analysis and requirements definition: Refine goals into defined functions. Analyze end-user needs.</li>
<li>Systems design: Describe desired features in detail, including screen layouts, business rules, process diagrams and other documentation.</li>
<li>Implementation: Write the code. Personally, I design the database first,</li>
<li>Testing: Check for errors, bugs.</li>
<li>Deployment: The final stage of the initial development where the software is put into production and runs the actual business.</li>
<li>Maintenance: The rest of the <a href="http://www.dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">software&#8217;s</a> life: changes, correction, additions, moves to a different platforms, etc. This, the least glamorous and perhaps most important step of all, goes on seemingly forever.</li>
</ul>
</li>
<li><strong>Laziness Will Kill You!</strong> – Often, you might seem under a lot of pressure to get something done very quickly…it is very important to never compromise the quality of the <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">software</a> to get something done fast. At least a half dozen cases where a fellow developer did not code for some scenario because “there’s no way anyone would ever do that”. And more times than not, some user somewhere did it…and I’ve seen entire <a href="http://www.dhanashree.com/dhanashree-web-development-portfolio" target="_blank">websites</a> crash because of it (and people do get fired). The developer always blames the user for being stupid and doing what should not have been done, when in fact the developer is the real idiot. Don’t be lazy…don’t be a hack…do it right.</li>
<li><strong>Put First Things First</strong> &#8211; Stephen Covey’s “7 Habit’s of Highly Effective People”. He says in Habit 3: Put First Things First, “The key is not to prioritize your schedule, but to schedule your priorities. Do the most important things first – because where you are headed is more important than how fast you are going”. He also says of all of the 7 habits, this is the hardest one to master. I completely agree…it is so easy to work on the fun tasks or prioritize what may seem urgent over working on the not-so-fun things than require time and serious thought. But what’s important should always take precedence over what’s considered urgent. In Covey’s book, he also referenced a lifelong study on what the common trait among successful people is. The answer: successful people know to “Put First Things First”. This may be the most important recommendation you’re your continued <a href="http://www.dhanashree.com/career-as-web-developer" target="_blank">career</a>.</li>
<li><strong>Prepare Component for Reusability</strong> – You should never need to rewrite the same logic of code ever. Does your <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a> send emails out? If so, you better have one “SendEmail” method that everyone uses. Do you query the <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">database</a> for the current specials to be displayed on every page? You better have that method encapsulated in a database tier and every page better be getting the data through that method (Better yet, you better be caching that data to eliminate the extra database queries!). Whenever I m supposed to start <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/portal-development" target="_blank">development</a> in any of new project, I first try to find out the common functionality or functions that need to be developed across different <a href="http://www.dhanashree.com/web-development-services/website-designing" target="_blank">web pages</a>. Generally I devide them into different set of segments. Say for e.g. for the task related to validation at the client side, I always has a <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">dedicated</a> .js file which contain all most common validation functions. Same concept I applied to the <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">database programming</a>. We had developed a specialized library that do the all the basic CRUD operation. We have followed the MS Petshop application pattern. In this, we generally have to prepare the object of models and pass it to the data layer. The data layer will do the rest of database related operation.</li>
<li><strong>Certifications</strong> –Does certification puts wings on your resume..?? No, that is not always true. Most people says getting certified is a good idea. But few completely disagree. The main disagreement is that anyone can get certified. They’re just tests and there are “brain dump” <a href="http://www.dhanashree.com" target="_blank">websites</a> out there where people post questions and answers right after taking the tests. But generally companies may or may not consider your certifications that you highlighted on your resume. Yes that is true, that it sometime attract to the recruiter or the HR. They may prioritize your changes first in getting hire a <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">developer</a>. But even after they are going to follow the same selection process that they are used to do. They are gonna take your personal technical interview, may take technical exams. So by that way, if you are not upto the mark in your certification, then you are gone. They do not give discount in selection process to certificate holders. But at the end it is certification is eye attraction <img src='http://techinsight.dhanashree.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li><strong>Continued Education</strong> &#8211; Each <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">developer</a> know enough to get the job done, work their 8 hours every day and go home to do nothing. Those with drive and ambition to be great continue their education everyday…even at home. Whether it’s reading technical magazines, <a href="http://techinsight.dhanashree.com/" target="_blank">online articles</a>, <a href="http://techinsight.dhanashree.com/" target="_blank">blogs</a>, or picking up a good book, anything you do to stay on top of the latest technology will give you a huge advantage. Not only will you continue to work with the latest <a href="http://www.dhanashree.com/web-development-services" target="_blank">software</a>, but you will also be much more sought after, have much better job security and be able to bill a much higher rate. My favorite <a href="http://www.dhanashree.com" target="_blank">site</a> is The Code Project, <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">C#</a> corner and may different blogs. When searching for a way to do something specific, I often go here first and almost always find it. Whatever approach you take, make a conscious effort to keep learning. By being smarter and better than the rest, And yes keep on <a href="http://www.dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">developing</a> your knowledge bank database by bookmarking important resources that you come across while surfing over the net. This will really help you out to get the quick solution in what you do.</li>
</ul>
</div>
<p><span style="text-decoration: underline;"><strong><em><br />
</em></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><span style="font-family: Calibri;"><br />
NOTE<span style="mso-spacerun: yes;"> </span>:</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/recommendation-for-developers/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Custom error tracking library in asp.net using XML &amp; C#</title>
		<link>http://techinsight.dhanashree.com/custom-error-tracking-library-in-asp-net-using-xml-c/</link>
		<comments>http://techinsight.dhanashree.com/custom-error-tracking-library-in-asp-net-using-xml-c/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 09:14:01 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[C#.net]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=80</guid>
		<description><![CDATA[
Being an asp.net developers we develop a web project and get it completed in a months of time as there are many organizations which works on very tight bound timeline for developing web sites Or web application projects. And delivers the project to client in months of time
While after project delivery if client come up [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Being an <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">asp.net developers</a> we develop a web project and get it completed in a months of time as there are many organizations which works on very tight bound timeline for <a href="http://www.dhanashree.com/web-development-services/website-designing" target="_blank">developing web sites</a> Or <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">web application</a> projects. And delivers the project to client in months of time</p>
<p>While after project delivery if client come up saying that they are facing problems or <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a> is giving errors, that time it always becomes a headache for a <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">developer</a> to test each things even whole project sometimes to find a smaller errors (by means of error here we are not talking about logical errors, we talking about exceptions which mostly responsible for errors in the application), there are many exceptions .net framework fires which we never come to find out while debugging or developing the application. Those exceptions never affect directly to the <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a> but each small exception puts the unnecessary load on the server.</p>
<p>Here is the solution to track each and every smallest things happening inside your <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">asp.net web application</a>. Which I named as “<strong>Custom error tracking library</strong>”</p>
<p><strong><em>Custom error tracking library</em></strong></p>
<p>Very first question will come is that, what is the core concept for this.</p>
<p>Concept is like we will be maintaining an XML file with a predefined structure which I have built which will contain all the required fields as nodes and subs. Which we call as <strong>errorlog.xml</strong></p>
<p>There will be a CS library file which will track each and every minor errors/exceptions happens inside the <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a> or .net framework and will put the error details inside the XML file.</p>
<p>Once we got CS library ready with us we just have to a simple function with 2 overload methods as per requirement in each <strong>try/catch</strong> blocks of the code and also in <strong>Application_Error </strong>event of <strong>Global.asax</strong> file.</p>
<h3><em>XML File (errorlog.xml)</em></h3>
<p>&lt;?xml version=”1.0″ encoding=”utf-8″?&gt;</p>
<p>&lt;errorlog&gt;</p>
<p>&lt;error&gt;</p>
<p>&lt;datetime&gt;datetime&lt;/datetime&gt;</p>
<p>&lt;filename&gt;filename&lt;/filename&gt;</p>
<p>&lt;classname&gt;classname&lt;/classname&gt;</p>
<p>&lt;methodname&gt;methodname&lt;/methodname&gt;</p>
<p>&lt;errormethod&gt;errormethod&lt;/errormethod&gt;</p>
<p>&lt;messsage&gt;ErrorMessage&lt;/messsage&gt;</p>
<p>&lt;errordetails&gt;Details goes here&lt;/errordetails&gt;</p>
<p>&lt;IP&gt;IP adress&lt;/IP&gt;</p>
<p>&lt;url&gt;URL&lt;/url&gt;</p>
<p>&lt;/error&gt;</p>
<p>&lt;error&gt;</p>
<p><strong>&lt;/</strong><strong>errorlog</strong><strong>&gt;</strong></p>
<p>Root node of XLM file will be <strong>&lt;errorlog&gt;&lt;/errorlog&gt;</strong> inside root node there will be a sub node  <strong>&lt;error&gt;&lt;/error&gt;</strong> which will get duplicated for each error. For each error, library will generate a node will all the below listed details in XML file. Next to last error node. So for each error there will be a seaprate ERROR node.</p>
<p>Each fields of the above XML file is descibed beloe :</p>
<ol>
<li><strong>1. </strong><strong>Datetime : </strong>date and time of the error/exception<strong> </strong></li>
<li><strong>2. </strong><strong>File name : </strong>file name where exception or error happens<strong> </strong></li>
<li><strong>3. </strong><strong>Class name : </strong>classname in which error occurred<strong> </strong></li>
<li><strong>4. </strong><strong>Methodname : </strong>function name where errored<strong> </strong></li>
<li><strong>5. </strong><strong>Errormethod :</strong> name of the function which contains error code.<strong> </strong></li>
<li><strong>6. </strong><strong>Message : </strong>error message/exception message<strong> </strong></li>
<li><strong>7. </strong><strong>Error details: </strong>detailed error description which will show whole<strong>stack trace</strong> of the functional execution.<strong> </strong></li>
<li><strong>8. </strong><strong>IP : </strong>client IP address<strong> </strong></li>
<li><strong>9. </strong><strong>URL : </strong>absolute error ULR<strong> </strong></li>
</ol>
<p><strong> </strong></p>
<p><strong> </strong></p>
<h3><em>CS library</em></h3>
<p>There will be a CS library file where we will write all functionality for error handling and writing errors into XML file.</p>
<p><strong>errorHamdler.cs </strong>file will<strong> </strong>have 2 statis methods named <strong>WriteError(), </strong>there will be 2 overloaded methods for same functions with diff. parameters.</p>
<p><strong>CS file will look as given below. We name it as errorHamdler.cs</strong></p>
<h3>errorHandler.cs</h3>
<p>using System;</p>
<p>using System.Collections.Generic;</p>
<p>using System.Text;</p>
<p>using System.Xml;</p>
<p>using System.Reflection;</p>
<p>using System.Diagnostics;</p>
<p>namespace code_center</p>
<p>{</p>
<p>public class errorHandler</p>
<p>{</p>
<p>string _strErrorMessage, _strDetails, _strClassName, _strMethodName;</p>
<p>DateTime _dtOccuranceTime = new DateTime();</p>
<p>public errorHandler()</p>
<p>{</p>
<p>}</p>
<p>public errorHandler(DateTime time, string className, string methodName, string errorMessage, string details)</p>
<p>{</p>
<p>_dtOccuranceTime = time;</p>
<p>_strClassName = className;</p>
<p>_strDetails = details;</p>
<p>_strErrorMessage = errorMessage;</p>
<p>_strMethodName = methodName;</p>
<p>}</p>
<p>public static void WriteError(Exception ex)</p>
<p>{</p>
<p>WriteError(ex, “”);</p>
<p>}</p>
<p><strong>public static void WriteError(Exception ex, string fileName)</strong></p>
<p>{</p>
<p>XmlDocument doc = new XmlDocument();</p>
<p>string strRootPath = System.Configuration.ConfigurationManager.AppSettings["logfilepath"].ToString();</p>
<p>string xmlPath = System.Web.HttpContext.Current.Server.MapPath(strRootPath);</p>
<p>doc.Load(@xmlPath);</p>
<p>XmlNode newXMLNode, oldXMLNode;</p>
<p>oldXMLNode = doc.ChildNodes[1].ChildNodes[0];</p>
<p>newXMLNode = oldXMLNode.CloneNode(true);</p>
<p>StackTrace stackTrace = new StackTrace();</p>
<p>StackFrame stackFrame = stackTrace.GetFrame(1);</p>
<p>MethodBase methodBase = stackFrame.GetMethod();</p>
<p>newXMLNode.ChildNodes[0].InnerText = DateTime.Now.ToString();</p>
<p>newXMLNode.ChildNodes[1].InnerText = fileName;</p>
<p>newXMLNode.ChildNodes[2].InnerText = methodBase.DeclaringType.FullName;</p>
<p>newXMLNode.ChildNodes[3].InnerText = methodBase.Name;</p>
<p>newXMLNode.ChildNodes[4].InnerText = ex.TargetSite.Name;</p>
<p>newXMLNode.ChildNodes[5].InnerText = ex.Message;</p>
<p>newXMLNode.ChildNodes[6].InnerText = ex.StackTrace;</p>
<p>newXMLNode.ChildNodes[7].InnerText = System.Web.HttpContext.Current.Request.UserHostAddress;</p>
<p>newXMLNode.ChildNodes[8].InnerText = System.Web.HttpContext.Current.Request.Url.OriginalString;</p>
<p>doc.ChildNodes[1].AppendChild(newXMLNode);</p>
<p>doc.Save(@xmlPath);</p>
<p>doc.RemoveAll();</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>In above code there is a line “string strRootPath = System.Configuration.ConfigurationManager.AppSettings["logfilepath"].ToString();”</p>
<p>We need to give XML file path also where we have placed XML file in the project, so just have to add 1 line in web.config file as given below to store actual XML file path, which will be used in abiove functon.</p>
<h3><em>Code inside web.config</em></h3>
<p>&lt;appSettings&gt;</p>
<p>&lt;add key=”logfilepath” value=”~/errorHandling/errorlog.xml”/&gt;</p>
<p>&lt;/appSettings&gt;</p>
<h1><em>How to use error handler in application</em></h1>
<p>Now everything is ready to be used in real time<a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank"> application</a>. In each <strong>try/catch</strong>block we have to call</p>
<p><strong>Writeerror()</strong> function as described below .</p>
<h3><em>Code inside Default.aspx.vb</em></h3>
<p>protected void Page_Load(object sender, EventArgs e)</p>
<p>{</p>
<p>try</p>
<p>{</p>
<p>throw new Exception(“Custom error”);</p>
<p>}</p>
<p>catch (Exception ex)</p>
<p>{</p>
<p>Response.Write(ex.Message);</p>
<p><strong>code_center.errorHandler.WriteError(ex, “Default.aspx.vb”);</strong></p>
<p>}</p>
<p>}</p>
<p>Apart from each <strong>try/catch</strong> blocks we will put some code in <strong>Global.asax </strong>file also, as given below.</p>
<p>void Application_Error(object sender, EventArgs e)</p>
<p>{</p>
<p>code_center.errorHandler.WriteError(Server.GetLastError().GetBaseException(), “Global.asax”);</p>
<p>}</p>
<p>The reason behind putting code in Global.asax file is very important and necessory as there might be many exceptions which occurs at application level and canot be tracable in any <strong>try/catch</strong> blocks in any function or events. So anyerror except try/catch blocks will come in this event (Application_Error) and will get inserted intoXML file.</p>
<p>That’s it, we have done with the error handling, and all errors will be tractable from the XML file which is being generated via the error handler.</p>
</div>
<p><span style="text-decoration: underline;"><strong><em><br />
</em></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><span style="font-family: Calibri;"><br />
NOTE<span style="mso-spacerun: yes;"> </span>:</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/custom-error-tracking-library-in-asp-net-using-xml-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>List of technology which can be adopted into development</title>
		<link>http://techinsight.dhanashree.com/list-of-technology-which-can-be-adopted-into-development/</link>
		<comments>http://techinsight.dhanashree.com/list-of-technology-which-can-be-adopted-into-development/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 07:51:15 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tools & Technology]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>
		<category><![CDATA[C#.net]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=77</guid>
		<description><![CDATA[Business Intelligence Application Development
 
Companies are investing millions of dollars in ERP solutions or have invested till date to improve the way they conduct their business. While ERP provides significant benefits organizations are finding that, in order to achieve critical decision making business goals, they often need to supplement it with additional external reporting capabilities [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Business Intelligence <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">Application Development</a></strong></p>
<p><strong> </strong></p>
<p>Companies are investing millions of dollars in ERP solutions or have invested till date to improve the way they conduct their business. While ERP provides significant benefits organizations are finding that, in order to achieve critical decision making business goals, they often need to supplement it with additional external reporting capabilities for it end users. With the wealth of data entered and stored in ERP databases the ability to analyze and interpret the data is significant for management reporting. With Business Intelligence tool, it has greatly alleviated the backlog of report requests and has provided users with decision making information in a timely manner.</p>
<p>Business Intelligence is a method of storing and presenting key enterprise data so that anyone in your company can quickly and easily ask questions of accurate and timely data. Effective BI allows end users to use data to understand why your business got the particular results that it did, to decide on courses of action based on past data, and to accurately forecast future  results.</p>
<p>BI data is displayed in a fashion that is appropriate to each type of user, i.e. analysts will be able to drill into detailed data, executives will see timely summaries, and middle managers will see data presented at the level of detail that they need to make good business decisions. Microsoft’s BI uses cubes, rather than tables, to store information and presents information via reports. The reports can be presented to end users in a variety of formats:Windows applications,<a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">Web Applications</a>, and Microsoft BI client tools, such</p>
<p>as Excel or SQL Reporting Services.</p>
<p>Need for the BI application:</p>
<p>Check out following article where it is explain what is the important of BI application</p>
<p><a href="http://www.cio.com/article/153500/Need_for_Business_Intelligence_Grows_Too_Much_Information_Not_Enough_Insight">http://www.cio.com/article/153500/Need_for_Business_Intelligence_Grows_Too_Much_Information_Not_Enough_Insight</a></p>
<p>Microsoft products involved in BI <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application development</a>:</p>
<p><strong>SQL Server 2005</strong>: This is the preferred staging and, possibly, source location for BI solutions. Data can actually be retrieved from a variety of data stores (Oracle, DB2, and so on), so a SQL Server installation is not strictly required to build a Microsoft BI solution. However, due to the integration of some key toolsets that are part of nearly all BI solutions—for example, SSIS or SQL Server Integration Services, which is usually used to perform the ETL of source data into the data warehouse—most BI solutions will include at least one SQL Server 2005 installation. Another key component in many BI solutions is SQL Server Reporting Services (SSRS). When working with SQL Server to perform OLAP administrative tasks, you will use the management interface, which is called SQL Server Management Studio (SSMS).</p>
<p><strong>SQL Server Analysis Service</strong>: This is the core server in Microsoft’s BI solution. SSAS provides storage for the data used in cubes for your data warehouse.</p>
<p><strong>SQL Server 2005 Integration Service</strong>: This toolset is a key component in most BI solutions that is used to import, cleanse, and validate data prior to making the data available to the  analysis Services for reporting purposes. It is typical to use data from many disparate sources (relational, flat file, XML, and so on) as source data to a data warehouse. For this reason, a sophisticated toolset, such as SSIS is used to facilitate the complex data loads that are often common to BI solutions. As stated earlier, this functionality is often called ETL (Extract, Transform, and Load) in a BI solution.</p>
<p><strong>SQL Server 2005 Reporting Service</strong>: This is an optional component for your BI solution.</p>
<p><strong>Excel 2003 and 2007: </strong>This is another optional component for your BI solution. Many  companies already own Office 2003, so use of Excel as a BI client is often attractive for its low cost and (relatively) low training curve.</p>
<p><strong> </strong></p>
<p>Apart from Microsoft BI solution, there are number of other solution provider are there in market.</p>
<p>Following are the list of BI solution &amp; tools provider</p>
<p>Cognos: <a href="http://www.cognos.com/products/cognos8businessintelligence/index.html">http://www.cognos.com/products/cognos8businessintelligence/index.html</a></p>
<p>SAP: <a href="http://www.sap.com/solutions/netweaver/components/bi/index.epx">http://www.sap.com/solutions/netweaver/components/bi/index.epx</a></p>
<p>Business Object: <a href="http://www.uk.businessobjects.com/products/platform/enterprise.asp">http://www.uk.businessobjects.com/products/platform/enterprise.asp</a></p>
<p>Oracle: <a href="http://www.oracle.com/solutions/business_intelligence/index.html">http://www.oracle.com/solutions/business_intelligence/index.html</a></p>
<p><strong><span style="text-decoration: underline;"><br />
</span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p><strong><span style="text-decoration: underline;">SharePoint Portal Service/Server</span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p>Microsoft Windows SharePoint Services 3.0 is a versatile technology that organizations and business units of all sizes can use to increase the efficiency of business processes and improve team productivity. With tools for collaboration that help people stay connected across organizational and geographic boundaries, Windows SharePoint Services gives people access to information they need.</p>
<p>Built on Microsoft Windows Server 2003, Windows SharePoint Services also provides a  foundation platform for building <a href="http://www.dhanashree.com/web-development-services/web-software-application-development/business-communication-sytems" target="_blank">Web-based business applications</a> that can flex and scale easily to meet the changing and growing needs of your business. Robust administrative controls for managing storage and Web infrastructure give IT departments a cost-effective way to implement and manage a high-performance collaboration environment. With a familiar, <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">Web-based interface</a> and close integration with everyday tools including the Microsoft Office system, Windows SharePoint Services is easy to use and can be deployed rapidly</p>
<p>Need of SharePoint?</p>
<p>• As companies grow so does the amount of their files. It soon becomes difficult to keep track of the multiplying documents and their locations.  SharePoint overcomes this by allowing you to store and share your files in a central site.</p>
<p>• Sharing work files through email is a cumbersome process.  SharePoint eliminates this by allowing files to be stored in one location, allowing easy access to all team members.</p>
<p>• Business Intelligence has traditionally remained in the hands of a few key decision makers within organizations.  For years, it has been the goal of BI providers to “democratize business intelligence” by making it available to all levels of workers throughout companies.  With the addition of PerformancePoint to the SharePoint Enterprise version of SharePoint, this vision is realized, finally taking business intelligence out of the hands of the few and into the hands of many.</p>
<p>• Today’s work occurs over multiple locations, whether it is in different countries, office locations, separate departments or at your home office. SharePoint enables teams and individuals to connect and collaborate together regardless of where they are located.</p>
<p>• Surveys have shown that employees can spend up to 20 – 30 % of their day searching for data and information.  SharePoint eliminates this drag on productivity by providing the robust search functionality needed to find the information and expertise buried in the thousands, or hundreds of thousands of files a company generates in the course of business.</p>
<p>• It’s difficult and time consuming to create and maintain sites.  SharePoint allows anyone to <a href="http://www.dhanashree.com/web-development-services" target="_blank">create sites</a> for use within their company’s Intranet, as they are needed, whether they are departmental sites, document libraries, meetings sites, survey sites, or discussion boards.</p>
<p>Ref: <a href="http://office.microsoft.com/en-us/sharepointserver/FX100492001033.aspx">http://office.microsoft.com/en-us/sharepointserver/FX100492001033.aspx</a></p>
<p><strong><span style="text-decoration: underline;"><br />
</span></strong></p>
<p><strong><span style="text-decoration: underline;">iPhone Application Development</span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p>iPhone is Revolutionary device which is designed and marketed by Apple Inc. iPhone provides downgraded version of OS framework to Mac OS X framework. iPhone has Cocoa Touch Framework.</p>
<p>Development tools involved in <a href="http://www.dhanashree.com/web-development-services/mobile-application-iphone-application-anoroid-development" target="_blank">IPhone application development</a>:</p>
<p><strong>XCode</strong>: Complete <a href="http://www.dhanashree.com/web-development-services" target="_blank">development</a> environment provides project management, a powerful source editor, and a graphical debugger</p>
<p><strong>iPhone Simulator</strong>: Run, test, and debug your <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a> locally on your Mac using a simulated iPhone</p>
<p><strong>Instruments</strong>: Collect, display, and compare performance data graphically in real-time to optimize your application.</p>
<p><strong>Interface Builder: </strong>Interface Builder makes <a href="http://www.dhanashree.com/web-development-services/website-designing" target="_blank">designing</a> a user interface as easy as drag and drop.</p>
<p>The more detail on the <a href="http://www.dhanashree.com/web-development-services/mobile-application-iphone-application-anoroid-development" target="_blank">iPhone application development</a>, check out the official “iPhone Developer Program” website.</p>
<p><a href="http://developer.apple.com/iphone/program/">http://developer.apple.com/iphone/program/</a></p>
<p><strong><em><span style="text-decoration: underline;">Development Related</span></em></strong></p>
<p><strong> </strong></p>
<p><strong><span style="text-decoration: underline;">ORM</span></strong></p>
<p>Object-relational mapping is used to map object-oriented programming objects to relational databases managed by Oracle, DB2, Sybase, and other relational database managers (RDBMSs). This site provides facts about object-relational mapping products, architecture problem-solving, and direction in product comparison and selection.</p>
<p>Object-relational mapping products are designed to work well with object programming languages such as C#, C++, and Java. Database objects appear as programming language objects. Often, the interface for object-relational mapping products is the same as the interface for object-oriented databases.</p>
<p><strong>ORM tools for .Net</strong></p>
<p>ADO.NET Entity Framework is an <a title="Object-relational mapping" href="http://en.wikipedia.org/wiki/Object-relational_mapping">object-relational mapping</a> (ORM) framework for the <a title=".NET Framework" href="http://en.wikipedia.org/wiki/.NET_Framework">.NET Framework</a>. This framework is an ORM offering from Microsoft for the <a title=".NET Framework" href="http://en.wikipedia.org/wiki/.NET_Framework">.NET Framework</a></p>
<p><a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">ADO.NET</a> Entity Framework is included with <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">.NET</a> Framework 3.5 Service Pack 1 and <a title="Microsoft Visual Studio" href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio">Visual Studio 2008</a> Service Pack 1, released on 11 Aug 2008. It also includes the capability of executing <a title="Language Integrated Query" href="http://en.wikipedia.org/wiki/Language_Integrated_Query">LINQ</a> against ADO.NET Entity Framework entities.</p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong>ORM for PHP</strong></p>
<p><strong> </strong></p>
<p>There are several tools available right now for implementing ORM technique in PHP.</p>
<p>Following are the list of few ORM tools which can be used with PHP.</p>
<ul>
<li><a href="http://cakephp.org/">CakePHP</a>’s ORM layer</li>
<li><a href="http://www.symfony-project.org/">Symfony</a></li>
<li><a href="http://www.phpdoctrine.org/">Doctrine</a></li>
<li><a href="http://propel.phpdb.org/trac/">Propel</a></li>
</ul>
<p>Check out following articles which demonstrate you in detail ORM implementation in PHP.</p>
<p><a href="http://www.developertutorials.com/blog/php/getting-started-with-orm-in-php-331/">http://www.developertutorials.com/blog/php/getting-started-with-orm-in-php-331/</a><br />
<strong><span style="text-decoration: underline;">Microsoft .Net 3.5</span></strong></p>
<p>There are several .NET language enhancements to be introduced with Visual Studio 2008 including implicitly typed variables, extension methods, anonymous types, object initializers, collection initializers and automatic properties. These language enhancements, along with features like generics, are critical to the use of some of the new features, such as LINQ with the ADO.NET Entity Framework.</p>
<p>These are the such enhancements in .net framework which really can bust development as well as productivity of <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">developers</a>.</p>
<p>Following are the few of articles which demonstrate the practical usage of new .net framework 3.5 enhancement.</p>
<p><a href="http://www.simple-talk.com/dotnet/.net-framework/.net-3.5-language-enhancements/">http://www.simple-talk.com/dotnet/.net-framework/.net-3.5-language-enhancements/</a></p>
<p><strong><span style="text-decoration: underline;">MVC framework</span></strong></p>
<p>MVC is a framework methodology that divides an application&#8217;s implementation into three component roles: models, views, and controllers.</p>
<ul>
<li>&#8220;Models&#8221;      in a MVC based application are the components of the application that      are responsible for maintaining state.  Often this state is      persisted inside a database (for example: we might have a Product class      that is used to represent order data from the Products table inside SQL).</li>
</ul>
<ul>
<li>&#8220;Views&#8221;      in a MVC based application are the components responsible for      displaying the application&#8217;s user interface.  Typically      this UI is created off of the model data (for example: we might      create an Product &#8220;Edit&#8221; view that surfaces textboxes, dropdowns      and checkboxes based on the current state of a Product object).</li>
</ul>
<ul>
<li>&#8220;Controllers&#8221;      in a MVC based application are the components responsible for      handling end user interaction, manipulating the model, and ultimately      choosing a view to render to display UI.  In a MVC application the      view is only about displaying information &#8211; it is the controller that      handles and responds to user input and interaction.</li>
</ul>
<p>One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views and controllers within an <a href="http://www.dhanashree.com/web-development-services/web-software-application-development" target="_blank">application</a>.  Maintaining a clean separation of concerns makes the testing of applications much easier, since the contract between different application components are more clearly defined and articulated.</p>
<p>The MVC pattern can also help enable red/green <a href="http://en.wikipedia.org/wiki/Test-driven_development" target="_blank">test driven development</a> (TDD) &#8211; where you implement automated unit tests, which define and verify the requirements of new code, first before you actually write the code itself.</p>
<p><strong>MVC Framework for .NET</strong></p>
<p>The <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">ASP.NET</a> MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating MVC-based <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">Web applications</a></p>
<p>Check out following articles for the overview of ASP.NET MVC framework</p>
<p><em><a href="http://www.asp.net/learn/mvc/tutorial-01-cs.aspx">http://www.asp.net/learn/mvc/tutorial-01-cs.aspx</a></em></p>
<p><em> </em></p>
<p><strong>MVC Framework for PHP</strong></p>
<p>php.MVC implements the Model-View-Controller (MVC) design pattern, and encourages application design based on the Model 2 paradigm. This design model allows the Web page or other contents (View) to be mostly separated from the internal application code (Controller/Model), making it easier for <a href="http://www.dhanashree.com/web-development-services/website-designing/website-designing-services" target="_blank">designers</a> and <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">programmers</a> to focus on their respective areas of expertise.</p>
<p>Reference: <a href="http://www.phpmvc.net/">http://www.phpmvc.net/</a><br />
<strong><span style="text-decoration: underline;">IIS Search Engine Optimization Toolkit</span></strong></p>
<p>The IIS <a href="http://www.dhanashree.com/web-development-services/search-engine-promotion-submission" target="_blank">Search Engine Optimization</a> (SEO) Toolkit helps <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">Web developers</a>, hosting providers, and Web server administrators to improve their Web site’s relevance in search results by recommending how to make the site content more search engine-friendly. The IIS <a href="http://www.dhanashree.com/web-development-services/search-engine-promotion-submission" target="_blank">SEO</a> Toolkit includes the Site Analysis module, the Robots Exclusion module, and the Sitemaps and Site Indexes module, which let you perform detailed analysis and offer recommendations and editing tools for managing your Robots and Sitemaps files.</p>
<p>The components of IIS Search Engine Optimization Toolkit include the following features:</p>
<ol>
<li>Site Analysis:</li>
</ol>
<p>1.1. Fully featured site crawling engine &#8211; in order to perform detailed analysis of site&#8217;s structure and content, Site Analysis tool uses a built-in web crawler, called &#8220;iisbot&#8221;, to download and cache all the publicly available web site content. The web crawler is fully compliant with robots exclusion protocol.</p>
<p>1.2. Report summary dashboard &#8211; the results of site analysis are presented in an easy to use dashboard page that serves as a start page for various types of analysis. In addition this page includes a large set of pre-built queries for most common reports.</p>
<p>1.3. Query builder &#8211; Site Analysis tool includes a powerful and flexible query builder user interface that lets you create any custom queries that are run against the cached web site content.</p>
<p>1.4.  Detailed URL information &#8211; you can obtain various detailed information about every URL in your web site, such as response headers and content, the pages that link to that URL as well as all the referenced URLs.</p>
<p>1.5. Detailed Violations descriptions &#8211; each content or SEO violation found on a web site has a detailed description as well as a recommended corrective action.</p>
<p>1.6. Word Analysis &#8211; any web page can be analyzed with regards to the most commonly used words and phrases within the content of that page. The results of that analysis can be used to select the keywords that most accurately describe the content of the page.</p>
<p>1.7. Route Analysis &#8211; unique routes to any page can be displayed in a separate report. This kind of information helps better understand how search engine and site visitors reach a particular page on your web site.</p>
<ol>
<li>Robots Exclusion</li>
</ol>
<p>2.1.   User interface for editing robots.txt file &#8211; the content of the robots exclusion file &#8211; robots.txt &#8211; can be edited by using IIS Manager GUI</p>
<p>2.2. Selecting URL paths from physical view of web site &#8211; the paths that are specified for &#8220;Allow&#8221; and &#8220;Disallow&#8221; directives in robots.txt file can be selected from the physical file system layout of your web site.</p>
<p>2.3. Selecting URL paths from virtual view of web site &#8211; the paths that are specified for &#8220;Allow&#8221; and &#8220;Disallow&#8221; directives in robots.txt file can be selected from the logical view of your web site obtained from the results of site analysis.</p>
<ol>
<li>Sitemaps and Sitemap Indexes</li>
</ol>
<p>3.1. User interface for managing sitemap and sitemap indexes files &#8211; the content of the sitemap and indexes files can be edited by using IIS Manager GUI</p>
<p>3.2. Selecting URLs from physical view of web site &#8211; the URLs that are specified within a sitemap can be selected from the physical file system layout of your web site.</p>
<p>3.3. Selecting URLs from virtual view of web site &#8211; the URLs that are specified within a sitemap can be selected from the logical view of your web site obtained from the results of site analysis.</p>
<p><strong><span style="text-decoration: underline;">Rich Internet Application Tools</span></strong></p>
<p><strong><span style="text-decoration: underline;"> </span></strong></p>
<p><strong>Adobe AIR</strong></p>
<p>The Adobe® AIR™ runtime lets <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">developers</a> use proven <a href="http://www.dhanashree.com/web-development-services" target="_blank">web technologies</a> to build rich <a href="http://www.dhanashree.com/web-development-services/web-software-application-development/supply-chain-management" target="_blank">Internet applications</a> that run outside the browser on multiple operating systems.</p>
<p>Adobe AIR is divided into 3 different categories as per the expertise of particular <a href="http://www.dhanashree.com/web-development-services/dedicated-php-dotnet-developer/dedicated-development-team" target="_blank">developer</a>.</p>
<p>AJAX: <a href="http://www.adobe.com/products/air/develop/ajax/">http://www.adobe.com/products/air/develop/ajax/</a></p>
<p>AIR with Flex : <a href="http://www.adobe.com/products/air/develop/flex/">http://www.adobe.com/products/air/develop/flex/</a></p>
<p>AIR with flash: <a href="http://www.adobe.com/products/air/develop/flash/">http://www.adobe.com/products/air/develop/flash/</a></p>
<p><strong>Google Web toolkit</strong></p>
<p>Google Web Toolkit 1.6 is a unique and remarkable platform-independent Java to JavaScript cross-compiler. The whole application may be written using most of the Java 1.5 features for which there is much tooling and test support. Not only that, but it is also possible to follow the Model View Controller (MVC) approach separating user interface from business logic, reducing cost of maintenance and increasing development flexibility. DOJO, on the other hand, requires you to develop the client using only the JavaScript language. This can be much more time consuming and more difficult to work with<strong> </strong></p>
<p><a href="http://code.google.com/webtoolkit/">http://code.google.com/webtoolkit/</a></p>
<p><strong>jQuery</strong></p>
<p>jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid <a href="http://www.dhanashree.com/dhanashree-web-development-profile" target="_blank">web development</a>. jQuery is designed to change the way that you write JavaScript.</p>
<p><a href="http://jquery.com/">http://jquery.com/</a></p>
<p><strong>Yahoo User Interface</strong></p>
<p>The YUI Library is a set of utilities and controls, written in JavaScript, for building richly <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">interactive web applications</a> using techniques such as DOM scripting, DHTML and AJAX</p>
<p><a href="http://developer.yahoo.com/yui/">http://developer.yahoo.com/yui/</a></p>
<p>Apart from these library/toolkits, there are several other toolkits which can also be utilized.</p>
<p>Mootools: <a href="http://mootools.net/">http://mootools.net/</a></p>
<p>Dojo: <cite><a href="http://www.dojotoolkit.org/">www.<strong>dojo</strong>toolkit.org/</a></cite></p>
<p>List of other toolkits: <a href="http://www.javascriptlibraries.com/">http://www.javascriptlibraries.com/</a></p>
<p><strong>Tools for Web Development &amp; Testing</strong></p>
<p>Following are few exiting tools for the <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">web development</a> testing.</p>
<ol>
<li>XenoCode Browser SandboxBrowser testing is one of the most tedious and frustrating parts of <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">web development</a>. What <a href="http://www.dhanashree.com/web-development-services/website-designing/website-designing-services" target="_blank">designer</a> or programmer hasn’t screamed bloody murder at broken alignments in Internet Explorer 6? One of the difficult parts of browser testing is that no developer can have every browser type on a single computer for proper testing.Enter XenoCode Browser Sandbox, a series of virtual applications that can run all popular browsers simultaneously. It does not even require the installation of software. However, XenoCode (Xenocode)’s Browser Sandbox can be heavy in some browsers and is still lacking in a Mac version.Use the following URL for further instruction on how to make use of such toolsRef: <a href="http://www.xenocode.com/browsers/">http://www.xenocode.com/browsers/</a></li>
<li>W3C Validation ServicesW3C is THE standard in all of web validation. The W3C Validator looks into the markup of any website and display errors based on industry standards. It comes in over a dozen languages and a dozen varieties. Here are some of the most important validators:Following are the popular validation services provided by W3C<a href="http://validator.w3.org/" target="_blank">W3C Markup Validation</a><br />
<a href="http://jigsaw.w3.org/css-validator/" target="_blank">W3C CSS Validation</a><br />
<a href="http://validator.w3.org/checklink" target="_blank">W3C Link Checker</a><br />
<a href="http://validator.w3.org/mobile/" target="_blank">W3C mobileOK Checker</a></li>
<li>Javascript &amp; CSS minifyHere is the site which allows you to minify javascript and perhaps the css also<a href="http://www.vlead.in/resources/tools/minify-javascript/index.php">http://www.vlead.in/resources/tools/minify-javascript/index.php</a></li>
</ol>
<p>Following are the list of few articles which can also be referenced for different area of</p>
<p><strong>Web development tools</strong></p>
<p>There are many other tools available over the internet which can be utilized in daily <a href="http://www.dhanashree.com/web-development-services/asp-php-web-development" target="_blank">web development</a>.</p>
<p>Check out following link to improve your productivity</p>
<p><a href="http://mashable.com/2008/11/01/web-development-tools/">http://mashable.com/2008/11/01/web-development-tools/</a></p>
<p><strong>Web 2.0 application &amp; tools</strong></p>
<p><em><a href="http://www.go2web20.net/">http://www.go2web20.net</a></em></p>
<p><span style="text-decoration: underline;"><strong><em><br />
</em></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><span style="font-family: Calibri;"><br />
NOTE<span style="mso-spacerun: yes;"> </span>:</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/list-of-technology-which-can-be-adopted-into-development/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Storing and Retrieving image in SQL server 2005 &amp; asp.net using large value data type &amp; HTTP handler</title>
		<link>http://techinsight.dhanashree.com/storing-and-retrieving-image-in-sql-server-2005-asp-net-using-large-value-data-type-http-handler/</link>
		<comments>http://techinsight.dhanashree.com/storing-and-retrieving-image-in-sql-server-2005-asp-net-using-large-value-data-type-http-handler/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 13:51:13 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[C#.net]]></category>
		<category><![CDATA[SQL server 2005]]></category>
		<category><![CDATA[Web Developement]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>
		<category><![CDATA[SQL server]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=22</guid>
		<description><![CDATA[ASPX page :
&#60;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&#62;
&#60;div style=&#8221;padding: 200px;&#8221;&#62;
&#60;asp:Image ID=&#8221;imagebox&#8221; runat=&#8221;server&#8221; ImageUrl=&#8221;~/sql-image-store/image-handler.ashx&#8221; /&#62;
&#60;/div&#62;
&#60;/form&#62;
Handler code: image-handler.ashx 
&#60;%@ WebHandler Language=&#8221;C#&#8221; Class=&#8221;image_handler&#8221; %&#62;
using System;
using System.Web;
using System.IO;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
public class image_handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string xStrCon = System.Configuration.ConfigurationManager.ConnectionStrings["conStrImage"].ConnectionString;
SqlConnection xCon = new SqlConnection(xStrCon);
xCon.Open();
SqlCommand xCom = new SqlCommand(&#8220;select * from images where&#8221;, xCon);
SqlDataAdapter xAda = new SqlDataAdapter(xCom);
DataSet ds = new [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste"><strong><a href="http://www.dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">ASPX</a> page :</strong></div>
<div>&lt;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&gt;</div>
<div id="_mcePaste">&lt;div style=&#8221;padding: 200px;&#8221;&gt;</div>
<div id="_mcePaste">&lt;asp:Image ID=&#8221;imagebox&#8221; runat=&#8221;server&#8221; ImageUrl=&#8221;~/sql-image-store/image-handler.ashx&#8221; /&gt;</div>
<div id="_mcePaste">&lt;/div&gt;</div>
<div id="_mcePaste">&lt;/form&gt;</div>
<p><strong>Handler code: </strong>image-handler.ashx<strong> </strong></p>
<p>&lt;%@ WebHandler Language=&#8221;C#&#8221; Class=&#8221;image_handler&#8221; %&gt;</p>
<p>using System;</p>
<p>using System.Web;</p>
<p>using System.IO;</p>
<p>using System.Data;</p>
<p>using System.Data.Sql;</p>
<p>using System.Data.SqlClient;</p>
<p>using System.Configuration;</p>
<p>public class image_handler : IHttpHandler</p>
<p>{</p>
<p>public void ProcessRequest(HttpContext context)</p>
<p>{</p>
<p>string xStrCon = System.Configuration.ConfigurationManager.ConnectionStrings["conStrImage"].ConnectionString;</p>
<p>SqlConnection xCon = new SqlConnection(xStrCon);</p>
<p>xCon.Open();</p>
<p>SqlCommand xCom = new SqlCommand(&#8220;select * from images where&#8221;, xCon);</p>
<p>SqlDataAdapter xAda = new SqlDataAdapter(xCom);</p>
<p>DataSet ds = new DataSet();</p>
<p>xAda.Fill(ds);</p>
<p>// Image processing starts</p>
<p>byte[] bytImage = ReadFile(context.Server.MapPath(&#8220;banner.JPG&#8221;));</p>
<p>xCom.CommandText = &#8220;insert into images values(2,&#8217;kensington&#8217;,@imagedata)&#8221;;</p>
<p>xCom.Parameters.Add(new SqlParameter(&#8220;@imagedata&#8221;, (object)bytImage));</p>
<p>xCon.Close();</p>
<p>//Display image from SQL server</p>
<p>byte[] imageData = (byte[])ds.Tables[0].Rows[0][2];</p>
<p>context.Response.Clear();</p>
<p>context.Response.ContentType = &#8220;image/JPEG&#8221;;</p>
<p>context.Response.OutputStream.Write(imageData, 0, imageData.Length);</p>
<p>}</p>
<p>byte[] ReadFile(string sPath)</p>
<p>{</p>
<p>//Initialize byte array with a null value initially.</p>
<p>byte[] data = null;</p>
<p>//Use FileInfo object to get file size.</p>
<p>FileInfo fInfo = new FileInfo(sPath);</p>
<p>long numBytes = fInfo.Length;</p>
<p>//Open FileStream to read file</p>
<p>FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read);</p>
<p>//Use BinaryReader to read file stream into byte array.</p>
<p>BinaryReader br = new BinaryReader(fStream);</p>
<p>//When you use BinaryReader, you need to supply number of bytes to read from file.</p>
<p>//In this case we want to read entire file. So supplying total number of bytes.</p>
<p>data = br.ReadBytes((int)numBytes);</p>
<p>return data;</p>
<p>}</p>
<p>public bool IsReusable</p>
<p>{</p>
<p>get</p>
<p>{</p>
<p>return false;</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p><span style="text-decoration: underline;"><strong><em><br />
</em></strong></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span style="color: red;" lang="EN-IN"><span style="font-size: 11pt;"><span style="font-family: Calibri;"><br />
NOTE<span style="mso-spacerun: yes;"> </span>:</span></span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">If you are in need of any </span><a href="http://dhanashree.com/web-development-services/asp-php-web-development" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">Web Development</span></a><span style="font-size: 11pt; font-family: Calibri;"> feel free to <span style="text-decoration: underline;"><a href="http://dhanashree.com/contact-web-designing-company" target="_blank">Inquire us</a></span> .<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a></span>. Expertise in <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/dot-net-web-designing" target="_blank">Asp.net Development</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/asp-php-web-development/lamp-development-php-web-designing" target="_blank">Php Development</a></span>,<span style="mso-spacerun: yes;"> </span><span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/website-designing" target="_blank">Website designing</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/open-source-wordpress-joomla-oscommerce-customisation" target="_blank">Open Source customisation</a></span>. <span style="text-decoration: underline;"><a href="http://dhanashree.com/" target="_blank">Dhanashree Inc</a> </span>can be our <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/offshore-website-designing-company" target="_blank">offshore development company</a></span> / </span><a href="http://dhanashree.com/web-designing-outsource-advantages" target="_blank"><span style="font-size: 11pt; font-family: Calibri;">outsourcing</span></a><span style="font-size: 11pt; font-family: Calibri;"> <span style="text-decoration: underline;"><a href="http://dhanashree.com/dhanashree-web-development-profile" target="_blank">web development company</a></span>, <span style="text-decoration: underline;"><a href="http://dhanashree.com/web-development-services/dedicated-php-dotnet-developer" target="_blank">hire dedicated web programmers</a></span>.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 10pt;"><span lang="EN-IN"><span style="font-size: 11pt; font-family: Calibri;">Above information is for knowledge sharing<span style="mso-spacerun: yes;"> </span>if you have problem / issue / suggestion please intimate us with details for proper and prompt action.</span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/storing-and-retrieving-image-in-sql-server-2005-asp-net-using-large-value-data-type-http-handler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Developing custom AD rotator control with multiple Image Mapping using C#.net &amp; XML</title>
		<link>http://techinsight.dhanashree.com/developing-custom-ad-rotator-control-with-multiple-image-mapping-using-c-net-xml/</link>
		<comments>http://techinsight.dhanashree.com/developing-custom-ad-rotator-control-with-multiple-image-mapping-using-c-net-xml/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 07:48:24 +0000</pubDate>
		<dc:creator>kiran</dc:creator>
				<category><![CDATA[.Net 2.0]]></category>
		<category><![CDATA[C#.net]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[.net developement]]></category>
		<category><![CDATA[asp.net developement]]></category>
		<category><![CDATA[Web Developement]]></category>

		<guid isPermaLink="false">http://dhanashree.com/techblog/?p=3</guid>
		<description><![CDATA[We are all familiar with AD rotator control asp.net provides to show rotating/random ads on every page refresh.
But I found a limitation of this control while I needed to develop functionality where AD banners get changed on every page refresh as well as each banners should have multiple links which navigates to diff. URLs ( [...]]]></description>
			<content:encoded><![CDATA[<p>We are all familiar with AD rotator control asp.net provides to show rotating/random ads on every page refresh.</p>
<p>But I found a limitation of this control while I needed to develop functionality where AD banners get changed on every page refresh as well as each banners should have multiple links which navigates to diff. URLs ( multiple image mapping in each AD banners )</p>
<p>As this is not possible with AD rotator I have developed a custom asp.net control which provides all this flexibilities with all AD rotator features.</p>
<p><strong>Basic Concept:</strong></p>
<p>To make the control easy to use &amp; understand we will be keeping the concept of defining Ads same like AD rotator control using XML file.</p>
<p>Control will read the Ad banners from the XML file and render all the details with multiple image mappings in the aspx page.</p>
<p><strong>XML file structure: </strong></p>
<p>First and foremost step is to finalize the XML file structure that to be used in custom control to render the ads on random bases.</p>
<p>XML file will look as given in below sample file.</p>
<p><strong>bannes.xml</strong></p>
<p><strong> </strong></p>
<p>&lt;?xml version=”1.0″ encoding=”utf-8″ ?&gt;</p>
<p>&lt;banbers&gt;</p>
<p>&lt;banner&gt;</p>
<p>&lt;ImageUrl&gt;http://xyz.com/banner1.jpg&lt;/ImageUrl&gt;</p>
<p>&lt;AlternateText&gt;Site1 Main&lt;/AlternateText&gt;</p>
<p>&lt;mappings&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;0&lt;/left&gt;</p>
<p>&lt;top&gt;0&lt;/top&gt;</p>
<p>&lt;right&gt;50&lt;/right&gt;</p>
<p>&lt;bottom&gt;50&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;/mappings&gt;</p>
<p>&lt;/banner&gt;</p>
<p>&lt;banner&gt;</p>
<p>&lt;ImageUrl&gt;banners/5.jpg&lt;/ImageUrl&gt;</p>
<p>&lt;AlternateText&gt;b5&lt;/AlternateText&gt;</p>
<p>&lt;mappings&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;10&lt;/left&gt;</p>
<p>&lt;top&gt;10&lt;/top&gt;</p>
<p>&lt;right&gt;10&lt;/right&gt;</p>
<p>&lt;bottom&gt;10&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;25&lt;/left&gt;</p>
<p>&lt;top&gt;25&lt;/top&gt;</p>
<p>&lt;right&gt;25&lt;/right&gt;</p>
<p>&lt;bottom&gt;25&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;10&lt;/left&gt;</p>
<p>&lt;top&gt;10&lt;/top&gt;</p>
<p>&lt;right&gt;10&lt;/right&gt;</p>
<p>&lt;bottom&gt;10&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;25&lt;/left&gt;</p>
<p>&lt;top&gt;25&lt;/top&gt;</p>
<p>&lt;right&gt;25&lt;/right&gt;</p>
<p>&lt;bottom&gt;25&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;10&lt;/left&gt;</p>
<p>&lt;top&gt;10&lt;/top&gt;</p>
<p>&lt;right&gt;10&lt;/right&gt;</p>
<p>&lt;bottom&gt;10&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;map&gt;</p>
<p>&lt;left&gt;25&lt;/left&gt;</p>
<p>&lt;top&gt;25&lt;/top&gt;</p>
<p>&lt;right&gt;25&lt;/right&gt;</p>
<p>&lt;bottom&gt;25&lt;/bottom&gt;</p>
<p>&lt;navigateUrl&gt;google.com&lt;/navigateUrl&gt;</p>
<p>&lt;/map&gt;</p>
<p>&lt;/mappings&gt;</p>
<p>&lt;/banner&gt;</p>
<p>&lt;/banbers&gt;</p>
<p>Inside main <strong>banners</strong> TAG there will be multiple banners TAG to be added for each AD banner,</p>
<p>Each banner TAG will have child nodes(attributes) as listed below:</p>
<ol>
<li>Image URL – AD image URL to be specified here</li>
<li>Alternate text – alt attribute for image</li>
<li>Mappings  &#8211; list of all mappings with relative  <strong>left-right-top-Bottom </strong> attributes
<ol>
<li>Left – left side relative axis</li>
<li>Right – right side relative axis</li>
<li>Top– Top relative axis</li>
<li>Bottom– Bottom relative axis</li>
<li>Navigate URL – URL to navigate</li>
</ol>
</li>
</ol>
<p><strong>Developing Custom Control:</strong></p>
<p>Now next step is to build a custom asp.net control which will read the above XML structure and renders the data accordingly on ASPX page.</p>
<p><strong>C# code file will be as given below: </strong></p>
<p><strong> </strong></p>
<p><strong>ad-banners.cs</strong></p>
<p><strong> </strong></p>
<p>this control will have 1 public property where the XML file path will be given called</p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p>using System;</p>
<p>using System.Collections.Generic;</p>
<p>using System.ComponentModel;</p>
<p>using System.Text;</p>
<p>using System.Web;</p>
<p>using System.Web.UI;</p>
<p>using System.Web.UI.WebControls;</p>
<p>using System.Xml;</p>
<p>namespace InfoquestLibrary.Controls</p>
<p>{</p>
<p>[DefaultProperty("Text")]</p>
<p>[ToolboxData("&lt;{0}:banner runat=server /&gt;")]</p>
<p>public class banner : System.Web.UI.WebControls.WebControl</p>
<p>{</p>
<p>string _strImageURL, _strXMLpath;</p>
<p>[Bindable(true)]</p>
<p>[Category("Appearance")]</p>
<p>[DefaultValue("")]</p>
<p>[Localizable(true)]</p>
<p>public string ImageURL</p>
<p>{</p>
<p>get { return _strImageURL; }</p>
<p>set { _strImageURL = value; }</p>
<p>}</p>
<p>public string XMLpath</p>
<p>{</p>
<p>get { return _strXMLpath; }</p>
<p>set { _strXMLpath = value; }</p>
<p>}</p>
<p>public override void RenderBeginTag(HtmlTextWriter writer)</p>
<p>{</p>
<p>}</p>
<p>public override void RenderEndTag(HtmlTextWriter writer)</p>
<p>{</p>
<p>}</p>
<p>protected override void RenderContents(HtmlTextWriter output)</p>
<p>{</p>
<p>XmlDocument xDoc = new XmlDocument();</p>
<p>XmlNode xRandomNode;</p>
<p>bool useMapping = true;</p>
<p>int xIntRandomNumber;</p>
<p>Random r = new Random();</p>
<p>xDoc.Load(System.Web.HttpContext.Current.Server.MapPath(this.XMLpath));</p>
<p>xIntRandomNumber = r.Next(xDoc.ChildNodes[1].ChildNodes.Count);</p>
<p>xRandomNode = xDoc.ChildNodes[1].ChildNodes[xIntRandomNumber];</p>
<p>if (xRandomNode.ChildNodes[2].Equals(null))</p>
<p>{</p>
<p>useMapping = false;</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>if (xRandomNode.ChildNodes[2].ChildNodes.Count == 0)</p>
<p>useMapping = false;</p>
<p>}</p>
<p>if (xRandomNode.HasChildNodes)</p>
<p>{</p>
<p>this.ImageURL = xRandomNode.ChildNodes[0].InnerText;</p>
<p>}</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Src, this.ImageURL);</p>
<p>if (useMapping)</p>
<p>{</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Usemap, “#map” + this.ID);</p>
<p>}</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Border, “none”);</p>
<p>this.AddAttributesToRender(output);</p>
<p>output.RenderBeginTag(HtmlTextWriterTag.Img);</p>
<p>if (useMapping)</p>
<p>{</p>
<p>int xIntMaps, xIntCounter;</p>
<p>xIntMaps = xRandomNode.ChildNodes[2].ChildNodes.Count;</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Name, “map” + this.ID);</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Id, “map” + this.ID);</p>
<p>this.AddAttributesToRender(output);</p>
<p>output.RenderBeginTag(HtmlTextWriterTag.Map);</p>
<p>for (xIntCounter = 0; xIntCounter &lt; xIntMaps; xIntCounter++)</p>
<p>{</p>
<p>XmlNode xMap = xRandomNode.ChildNodes[2].ChildNodes[xIntCounter];</p>
<p>if (xMap.HasChildNodes)</p>
<p>{</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Shape, “rect”);</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Coords, xMap.ChildNodes[0].InnerText + “,” + xMap.ChildNodes[1].InnerText + “,” + xMap.ChildNodes[2].InnerText + “,” + xMap.ChildNodes[3].InnerText);</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Href, xMap.ChildNodes[4].InnerText);</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Title, “”);</p>
<p>output.AddAttribute(HtmlTextWriterAttribute.Alt, “”);</p>
<p>output.RenderBeginTag(HtmlTextWriterTag.Area);</p>
<p>output.RenderEndTag();</p>
<p>}</p>
<p>}</p>
<p>output.RenderEndTag();</p>
<p>}</p>
<p>}</p>
<p>protected override void OnPreRender(EventArgs e)</p>
<p>{</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong> </strong></p>
<p><strong>Using customer control in ASPX page:</strong></p>
<p><strong> </strong></p>
<p>Now we are done with developing customer control with all the required functionality.</p>
<p>And control now ready for use.</p>
<p><strong><em>Registering custom control</em></strong></p>
<p><strong><em> </em></strong></p>
<p>&lt;%@ Register Assembly=”code_center_library” TagPrefix=”TCC” Namespace=”TCC.Controls” %&gt;</p>
<p><strong><em>Defining Custom control in ASPX page</em></strong></p>
<p><strong><em> </em></strong></p>
<p>&lt;TCC:banner ID=”ads” runat=”server” XMLpath=”~/banner-mapping/bannes.xml” /&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://techinsight.dhanashree.com/developing-custom-ad-rotator-control-with-multiple-image-mapping-using-c-net-xml/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

