<?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>Powertips &#187; C#</title>
	<atom:link href="http://scripting.chaindb.com/category/dotnet/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://scripting.chaindb.com</link>
	<description>Programmer tips</description>
	<lastBuildDate>Thu, 22 Dec 2011 02:57:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Exception: Thread was being aborted</title>
		<link>http://scripting.chaindb.com/2009/05/27/exception-thread-was-being-aborted/</link>
		<comments>http://scripting.chaindb.com/2009/05/27/exception-thread-was-being-aborted/#comments</comments>
		<pubDate>Wed, 27 May 2009 08:51:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Exception]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[Thead]]></category>

		<guid isPermaLink="false">http://scripting.chaindb.com/?p=422</guid>
		<description><![CDATA[Try using flush method instead of end method of object. Read Forum]]></description>
			<content:encoded><![CDATA[<p>Try using <strong>flush </strong>method instead of <strong>end </strong>method of object.</p>
<p><a href="http://www.velocityreviews.com/forums/t106778-thread-was-being-aborted.html">Read Forum</a></p>
]]></content:encoded>
			<wfw:commentRss>http://scripting.chaindb.com/2009/05/27/exception-thread-was-being-aborted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Replace Multiple space with only one space</title>
		<link>http://scripting.chaindb.com/2009/05/26/how-to-replace-multiple-space-with-only-one-space/</link>
		<comments>http://scripting.chaindb.com/2009/05/26/how-to-replace-multiple-space-with-only-one-space/#comments</comments>
		<pubDate>Wed, 27 May 2009 03:53:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[Regular Expression]]></category>
		<category><![CDATA[vb.net description]]></category>

		<guid isPermaLink="false">http://scripting.chaindb.com/?p=419</guid>
		<description><![CDATA[Use regular expression RegexOptions options = RegexOptions.None; Regex regex = new Regex(@&#8221;[ ]{2,}&#8221;, options); tempo = regex.Replace(tempo, @&#8221; &#8220;); VB.Net Dim str As String = &#8220;Sample space 01&#8243; Dim opts As RegexOptions = RegexOptions.None Dim regx As New Regex(&#8220;[ ]{2,}&#8221;, opts) str = regx.Replace(str, &#8221; &#8220;)]]></description>
			<content:encoded><![CDATA[<p>Use regular expression</p>
<p>RegexOptions options = RegexOptions.None;<br />
Regex regex = new Regex(@&#8221;[ ]{2,}&#8221;, options);<br />
tempo = regex.Replace(tempo, @&#8221; &#8220;);</p>
<p>VB.Net </p>
<p>            Dim str As String = &#8220;Sample       space      01&#8243;<br />
            Dim opts As RegexOptions = RegexOptions.None<br />
            Dim regx As New Regex(&#8220;[ ]{2,}&#8221;, opts)</p>
<p>            str = regx.Replace(str, &#8221; &#8220;)</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7360303176440694";
/* scripting_Banner (468 x 60) */
google_ad_slot = "0537236933";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://scripting.chaindb.com/2009/05/26/how-to-replace-multiple-space-with-only-one-space/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subtracting Days of the Date</title>
		<link>http://scripting.chaindb.com/2009/05/26/subtracting-days-of-the-date/</link>
		<comments>http://scripting.chaindb.com/2009/05/26/subtracting-days-of-the-date/#comments</comments>
		<pubDate>Wed, 27 May 2009 01:17:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Date Formatting]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[Date]]></category>

		<guid isPermaLink="false">http://scripting.chaindb.com/?p=411</guid>
		<description><![CDATA[To subtract the date with a specified number of days, use the built in shared function of the Date which Date.Today.Add(Days), where Days is a day number. Instead of passing a positive number of days, put a negative sign in it. Example to subtract 2 days from the current date. Date.Today.Add(-2) or you can also [...]]]></description>
			<content:encoded><![CDATA[<p>To subtract the date with a specified number of days, use the built in shared function of the Date which <strong>Date.Today.Add(Days)</strong>, where <strong>Days</strong> is a day number. Instead of passing a positive number of days, put a negative sign in it.</p>
<p>Example to subtract 2 days from the current date.</p>
<p>Date.Today.Add(-2)</p>
<p>or you can also use the <strong>DateAdd()</strong> function and pass a negative day number.<br />
<script type="text/javascript"><!--
google_ad_client = "pub-7360303176440694";
/* scripting_336x280, created 5/12/10 */
google_ad_slot = "2066664949";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://scripting.chaindb.com/2009/05/26/subtracting-days-of-the-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Convert String to Date Format</title>
		<link>http://scripting.chaindb.com/2009/05/03/how-to-convert-string-to-date-format/</link>
		<comments>http://scripting.chaindb.com/2009/05/03/how-to-convert-string-to-date-format/#comments</comments>
		<pubDate>Mon, 04 May 2009 03:30:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Date Formatting]]></category>
		<category><![CDATA[String Manipulation]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[Date Format]]></category>
		<category><![CDATA[DateTime]]></category>

		<guid isPermaLink="false">http://scripting.chaindb.com/?p=323</guid>
		<description><![CDATA[To Convert String To Date Format, use the DateTime.ParseExact function DateTime.ParseExact(s as String, format as String, provider As IFormatProvider) as DateTime Parameters: s Type: System.String A string that contains a date and time to convert.  format Type: System.String A format specifier that defines the required format of s.  provider Type: System.IFormatProvider An object that supplies culture-specific format information about s.  Example: [...]]]></description>
			<content:encoded><![CDATA[<p>To Convert String To Date Format, use the <strong>DateTime.ParseExact</strong> function</p>
<p>DateTime.ParseExact(s as String, format as String, provider <span>As</span> IFormatProvider) as DateTime</p>
<h4 class="subHeading">Parameters:</h4>
<dl>
<dt><span class="parameter">s</span></dt>
<dd>Type: <a id="ctl00_mainContentContainer_ctl26" onclick="javascript:Track('ctl00_mainContentContainer_cpe123287_c|ctl00_mainContentContainer_ctl26',this);" href="http://msdn.microsoft.com/en-us/library/system.string.aspx">System<span class="nu">.</span>String</a><br />
<span><span>A string that contains a date and time to convert. </span><br />
</span></dd>
</dl>
<dl>
<dt><span class="parameter">format</span></dt>
<dd>Type: <a id="ctl00_mainContentContainer_ctl28" onclick="javascript:Track('ctl00_mainContentContainer_cpe123287_c|ctl00_mainContentContainer_ctl28',this);" href="http://msdn.microsoft.com/en-us/library/system.string.aspx">System<span class="nu">.</span>String</a><br />
<span><span>A format specifier that defines the required format of <span class="parameter">s</span>. </span><br />
</span></dd>
</dl>
<dl>
<dt><span class="parameter">provider</span></dt>
<dd>Type: <a id="ctl00_mainContentContainer_ctl30" onclick="javascript:Track('ctl00_mainContentContainer_cpe123287_c|ctl00_mainContentContainer_ctl30',this);" href="http://msdn.microsoft.com/en-us/library/system.iformatprovider.aspx">System<span class="nu">.</span>IFormatProvider</a><br />
<span><span>An object that supplies culture-specific format information about <span class="parameter">s</span>. </span></span></dd>
</dl>
<p>Example:<br />
 
<div class="geshi no vbnet">
<ol>
<li class="li1">
<div class="de1">    <span class="kw2">Private</span> <span class="kw6">Function</span> ToDate<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="kw2">As</span> DateTime</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">        <span class="kw6">Dim</span> <span class="kw7">str</span> <span class="kw2">As</span> <span class="kw2">String</span> <span class="sy0">=</span> <span class="st0">&quot;20060505&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">        <span class="kw6">Dim</span> mDate <span class="kw2">As</span> DateTime</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"> </div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">        mDate <span class="sy0">=</span> DateTime.<span class="me1">ParseExact</span><span class="br0">&#40;</span><span class="kw7">str</span>, <span class="st0">&quot;yyyyMMdd&quot;</span>, System.<span class="me1">Globalization</span>.<span class="me1">CultureInfo</span>.<span class="me1">CurrentCulture</span>.<span class="me1">DateTimeFormat</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">        <span class="kw2">Return</span> mDate</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">    <span class="kw6">End</span> <span class="kw6">Function</span></div>
</li>
</ol>
</div>
<p><a href="http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx">Read More about DateTime.ParseExact Method (String, String, IFormatProvider)</a></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7360303176440694";
/* scripting_Banner (468 x 60) */
google_ad_slot = "0537236933";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://scripting.chaindb.com/2009/05/03/how-to-convert-string-to-date-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Create Custom HTTP Module in  .NET</title>
		<link>http://scripting.chaindb.com/2009/04/30/how-to-create-custom-http-module-in-net/</link>
		<comments>http://scripting.chaindb.com/2009/04/30/how-to-create-custom-http-module-in-net/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 07:28:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[Http Module]]></category>

		<guid isPermaLink="false">http://scripting.chaindb.com/?p=319</guid>
		<description><![CDATA[http://support.microsoft.com/kb/307996 Create a new Visual Studio .NET C# Class Library project named MyModule. Set a reference to the System.Web.dll assembly. Add the following directive to the class: using System.Web; Rename the class SyncModule.cs, and then change the class definition to reflect this. Implement the IHttpModule interface. Your class definition should appear as follows: public class [...]]]></description>
			<content:encoded><![CDATA[<p>http://support.microsoft.com/kb/307996</p>
<ol style="position: relative;">
<li style="position: relative;">Create a new Visual Studio .NET C# Class Library project named MyModule.</li>
<li style="position: relative;">Set a reference to the<span class="Apple-converted-space"> </span><strong>System.Web.dll</strong><span class="Apple-converted-space"> </span>assembly.</li>
<li style="position: relative;">Add the following directive to the class:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">using System.Web;</pre>
</div>
</div>
</li>
<li style="position: relative;">Rename the class SyncModule.cs, and then change the class definition to reflect this.</li>
<li style="position: relative;">Implement the<span class="Apple-converted-space"> </span><strong>IHttpModule</strong><span class="Apple-converted-space"> </span>interface. Your class definition should appear as follows:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">public class SyncModule : IHttpModule</pre>
</div>
</div>
</li>
<li style="position: relative;">Decide to which events you will subscribe. The following list outlines the available events from the<span class="Apple-converted-space"> </span><strong>HttpApplication</strong><span class="Apple-converted-space"> </span>object to which you can subscribe:
<ul style="position: relative;">
<li style="position: relative;"><strong>AcquireRequestState</strong>: Call this event to allow the module to acquire or create the state (for example, session) for the request.</li>
<li style="position: relative;"><strong>AuthenticateRequest</strong>: Call this event when a security module needs to authenticate the user before it processes the request.</li>
<li style="position: relative;"><strong>AuthorizeRequest</strong>: Call this event by a security module when the request needs to be authorized. Called after authentication.</li>
<li style="position: relative;"><strong>BeginRequest</strong>: Call this event to notify a module that new request is beginning.</li>
<li style="position: relative;"><strong>Disposed</strong>: Call this event to notify the module that the application is ending for some reason. Allows the module to perform internal cleanup.</li>
<li style="position: relative;"><strong>EndRequest</strong>: Call this event to notify the module that the request is ending.</li>
<li style="position: relative;"><strong>Error</strong>: Call this event to notify the module of an error that occurs during request processing.</li>
<li style="position: relative;"><strong>PostRequestHandlerExecute</strong>: Call this event to notify the module that the handler has finished processing the request.</li>
<li style="position: relative;"><strong>PreRequestHandlerExecute</strong>: Call this event to notify the module that the handler for the request is about to be called.</li>
<li style="position: relative;"><strong>PreSendRequestContent</strong>: Call this event to notify the module that content is about to be sent to the client.</li>
<li style="position: relative;"><strong>PreSendRequestHeaders</strong>: Call this event to notify the module that the HTTP headers are about to be sent to the client.</li>
<li style="position: relative;"><strong>ReleaseRequestState</strong>: Call this event to allow the module to release state because the handler has finished processing the request.</li>
<li style="position: relative;"><strong>ResolveRequestCache</strong>: Call this event after authentication. Caching modules use this event to determine if the request should be processed by its cache or if a handler should process the request.</li>
<li style="position: relative;"><strong>UpdateRequestCache</strong>: Call this event after a response from the handler. Caching modules should update their cache with the response.</li>
</ul>
<p>This sample uses the<span class="Apple-converted-space"> </span><strong>BeginRequest</strong><span class="Apple-converted-space"> </span>event.</li>
<li style="position: relative;">Implement the<span class="Apple-converted-space"> </span><strong>Init</strong><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><strong>Dispose</strong><span class="Apple-converted-space"> </span>methods of the<span class="Apple-converted-space"> </span><strong>IHttpModule</strong><span class="Apple-converted-space"> </span>interface as follows:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">public void Init(HttpApplication app)
{
   app.BeginRequest += new EventHandler(OnBeginRequest);
}

public void Dispose(){ }</pre>
</div>
</div>
</li>
<li style="position: relative;">Create a delegate for an event as follows:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">public delegate void MyEventHandler(Object s, EventArgs e);</pre>
</div>
</div>
</li>
<li style="position: relative;">Define a private local variable of the type<span class="Apple-converted-space"> </span><strong>MyEventHandler</strong><span class="Apple-converted-space"> </span>to hold a reference to the event:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">private MyEventHandler _eventHandler = null;</pre>
</div>
</div>
</li>
<li style="position: relative;">Create an event that hooks up the delegate to the method in the Global.asax file or class that inherits from the<span class="Apple-converted-space"> </span><strong>HttpApplication</strong><span class="Apple-converted-space"> </span>object:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">public event MyEventHandler MyEvent
{
   add { _eventHandler += value; }
   remove { _eventHandler -= value; }
}</pre>
</div>
</div>
</li>
<li style="position: relative;">Create the<span class="Apple-converted-space"> </span><strong>OnBeginRequest</strong><span class="Apple-converted-space"> </span>method, which hooks up to the<span class="Apple-converted-space"> </span><strong>BeginRequest</strong><span class="Apple-converted-space"> </span>event of<strong>HttpApplication</strong>:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">public void OnBeginRequest(Object s, EventArgs e)
{
   HttpApplication app = s as HttpApplication;
   app.Context.Response.Write("Hello from OnBeginRequest in custom module.&lt;br&gt;");
   if(_eventHandler!=null)
      _eventHandler(this, null);
}</pre>
</div>
</div>
</li>
<li style="position: relative;">Compile the project.</li>
</ol>
<p><span class="Apple-style-span" style="border-collapse: separate; color: #000000; font-family: Verdana; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16px; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"></p>
<h3 id="tocHeadRef" style="margin: 15px 0px 5px; font-size: 115%;">Deploy the Module</h3>
<ol style="position: relative;">
<li style="position: relative;">Create a new directory under C:\Inetpub\Wwwroot named Module.</li>
<li style="position: relative;">Create a subdirectory named Bin in the newly created Module directory. The resultant path is C:\Inetpub\Wwwroot\Module\Bin.</li>
<li style="position: relative;">Copy MyModule.dll from your project&#8217;s Bin\Debug directory to the C:\Inetpub\Wwwroot\Module\Bin directory.</li>
<li style="position: relative;">Follow these steps to mark the new Module directory as a Web application:
<ol style="position: relative;">
<li style="position: relative;">Open Internet Services Manager.</li>
<li style="position: relative;">Right-click the Module directory, and then click<span class="Apple-converted-space"> </span><strong>Properties</strong>.</li>
<li style="position: relative;">On the<span class="Apple-converted-space"> </span><strong>Directory</strong><span class="Apple-converted-space"> </span>tab, click<span class="Apple-converted-space"> </span><strong>Create</strong>.</li>
<li style="position: relative;">Click<span class="Apple-converted-space"> </span><strong>OK</strong><span class="Apple-converted-space"> </span>to close the<span class="Apple-converted-space"> </span><strong>Module Properties</strong><span class="Apple-converted-space"> </span>dialog box.</li>
</ol>
</li>
</ol>
<div class="topOfPage" style="margin: 10px 0px;"><a style="color: #07679a; text-decoration: none;" href="#top"><img style="border-style: none; margin: 0px 3px; font-size: 65%; vertical-align: text-bottom;" src="/library/images/support/kbgraphics/public/en-us/uparrow.gif" alt="" />Back to the top</a></div>
<h3 id="tocHeadRef" style="margin: 15px 0px 5px; font-size: 115%;">Configure the System</h3>
<ol style="position: relative;">
<li style="position: relative;">In the C:\Inetpub\Wwwroot\Module\ directory, create a new file named Web.config.</li>
<li style="position: relative;">Paste the following text in Web.config:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">&lt;configuration&gt;
   &lt;system.web&gt;
      &lt;httpModules&gt;
         &lt;add name="MyModule" type="MyModule.SyncModule, MyModule" /&gt;
      &lt;/httpModules&gt;
   &lt;/system.web&gt;
&lt;/configuration&gt;</pre>
</div>
</div>
</li>
</ol>
<div class="topOfPage" style="margin: 10px 0px;"><a style="color: #07679a; text-decoration: none;" href="#top"><img style="border-style: none; margin: 0px 3px; font-size: 65%; vertical-align: text-bottom;" src="/library/images/support/kbgraphics/public/en-us/uparrow.gif" alt="" /><br />
</a></div>
<h3 id="tocHeadRef" style="margin: 15px 0px 5px; font-size: 115%;">Test the Module</h3>
<ol style="position: relative;">
<li style="position: relative;">In the C:\Inetpub\Wwwroot\Module directory, create a new .aspx file named Test.aspx.</li>
<li style="position: relative;">Paste the following text into Test.aspx:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">&lt;%@Page Language="C#"%&gt;
&lt;% Response.Write("Hello from Test.aspx.&lt;br&gt;"); %&gt;</pre>
</div>
</div>
</li>
<li style="position: relative;">In the C:\Inetpub\Wwwroot\Module directory, create a Global.asax file.</li>
<li style="position: relative;">Paste the following code into Global.asax:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">&lt;%@ Import Namespace="MyModule" %&gt;

&lt;script language="C#" runat=server &gt;
protected void MyModule_OnMyEvent(Object src, EventArgs e)
{
  Context.Response.Write("Hello from MyModule_OnMyEvent called in Global.asax.&lt;br&gt;");
}
&lt;/script&gt;</pre>
</div>
</div>
</li>
<li style="position: relative;">Request the Test.aspx page. You should see the following lines of text:
<div class="kb_codebody" style="position: relative; overflow-x: auto; margin-bottom: 10px; border: 12px 1px 1px solid #7fbae2;">
<div class="kb_codecontent" style="border: 0px solid #7fbae2; margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;">
<pre class="code" style="margin: 0px; padding: 10px 10px 20px; position: relative; color: #333333; width: 1px; font-family: Consolas,'Courier New',Courier,monospace;">Hello from OnBeginRequest in custom module.
Hello from MyModule_OnMyEvent called in Global.asax.
Hello from Test.aspx.</pre>
</div>
</div>
</li>
</ol>
<div class="topOfPage" style="margin: 10px 0px;"><a style="color: #07679a; text-decoration: none;" href="#top"><br />
</a></div>
<p></span></p>
<p><a title="How to Create Custom Http Module in Visual C# .Net" href="http://support.microsoft.com/kb/307996" target="_blank">Read More</a></p>
<p><a title="ASP.NET HTTP Modules and HTTP Handlers Overview" href="http://support.microsoft.com/kb/307985/EN-US/" target="_blank"><span class="Apple-style-span" style="border-collapse: separate; color: #000000; font-family: Verdana; font-size: 11px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 16px; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">ASP.NET HTTP Modules and HTTP Handlers Overview</span></a></p>
]]></content:encoded>
			<wfw:commentRss>http://scripting.chaindb.com/2009/04/30/how-to-create-custom-http-module-in-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging Problem</title>
		<link>http://scripting.chaindb.com/2009/04/23/debugging-problem/</link>
		<comments>http://scripting.chaindb.com/2009/04/23/debugging-problem/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 00:33:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Compiler Errors And Messages]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[Debug]]></category>

		<guid isPermaLink="false">http://scripting.chaindb.com/?p=284</guid>
		<description><![CDATA[Problem: The breakpoint will not currently be hit. No symbols have been loaded for this document Solution: Make sure that you are compiling in Debug mode not Release mode.]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>The breakpoint will not currently be hit. No symbols have been loaded for this document</p>
<p><strong>Solution:</strong></p>
<p>Make sure that you are compiling in Debug mode not Release mode.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7360303176440694";
/* 728x90, created 11/30/08 */
google_ad_slot = "2160681765";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://scripting.chaindb.com/2009/04/23/debugging-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>String to Numeric Conversion</title>
		<link>http://scripting.chaindb.com/2009/04/23/string-to-numeric-conversion/</link>
		<comments>http://scripting.chaindb.com/2009/04/23/string-to-numeric-conversion/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 15:38:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[Conversion]]></category>
		<category><![CDATA[Numeric]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">http://scripting.chaindb.com/?p=276</guid>
		<description><![CDATA[Data Conversion in c# .net Numeric Type Method decimal Convert.ToDecimal(String) float Convert.ToSingle(String) double Convert.ToDouble(String) short Convert.ToInt16(String) long Convert.ToInt64(String) ushort Convert.ToUInt16(String) uint Convert.ToUInt32(String) ulong Convert.ToUInt64(String)   How to: Convert a string to an int (C# Programming Guide)  ]]></description>
			<content:encoded><![CDATA[<h3>Data Conversion in c# .net</h3>
<table border="0">
<tbody>
<tr>
<th>Numeric Type</th>
<th>Method</th>
</tr>
<tr>
<td><span><span class="input">decimal</span></span></td>
<td><span><a id="ctl00_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/en-us/library/hf9z3s65.aspx">Convert.ToDecimal(String)</a></span></td>
</tr>
<tr>
<td><span><span class="input">float</span></span></td>
<td><span><a id="ctl00_mainContentContainer_ctl06" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl06',this);" href="http://msdn.microsoft.com/en-us/library/faab9yks.aspx">Convert.ToSingle(String)</a></span></td>
</tr>
<tr>
<td><span><span class="input">double</span></span></td>
<td><span><a id="ctl00_mainContentContainer_ctl07" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl07',this);" href="http://msdn.microsoft.com/en-us/library/zh1hkw6k.aspx">Convert.ToDouble(String)</a></span></td>
</tr>
<tr>
<td><span><span class="input">short</span></span></td>
<td><span><a id="ctl00_mainContentContainer_ctl08" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl08',this);" href="http://msdn.microsoft.com/en-us/library/basyfs27.aspx">Convert.ToInt16(String)</a></span></td>
</tr>
<tr>
<td><span><span class="input">long</span></span></td>
<td><span><a id="ctl00_mainContentContainer_ctl09" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl09',this);" href="http://msdn.microsoft.com/en-us/library/0zahhahw.aspx">Convert.ToInt64(String)</a></span></td>
</tr>
<tr>
<td><span><span class="input">ushort</span></span></td>
<td><span><a id="ctl00_mainContentContainer_ctl10" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl10',this);" href="http://msdn.microsoft.com/en-us/library/5cat4fzy.aspx">Convert.ToUInt16(String)</a></span></td>
</tr>
<tr>
<td><span><span class="input">uint</span></span></td>
<td><span><a id="ctl00_mainContentContainer_ctl11" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl11',this);" href="http://msdn.microsoft.com/en-us/library/hs06dadw.aspx">Convert.ToUInt32(String)</a></span></td>
</tr>
<tr>
<td><span><span class="input">ulong</span></span></td>
<td><span><a id="ctl00_mainContentContainer_ctl12" onclick="javascript:Track('ctl00_mainContentContainer_ctl00|ctl00_mainContentContainer_ctl12',this);" href="http://msdn.microsoft.com/en-us/library/f65a8ex6.aspx">Convert.ToUInt64(String)</a></span></td>
</tr>
</tbody>
</table>
<p> </p>
<p><a title="Convert a string to an int in c#" href="http://msdn.microsoft.com/en-us/library/bb397679.aspx" target="_blank">How to: Convert a string to an int (C# Programming Guide)</a></p>
<p> </p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7360303176440694";
/* scripting_468x15, created 5/12/10 */
google_ad_slot = "3352621531";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://scripting.chaindb.com/2009/04/23/string-to-numeric-conversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>@ Symbol in C##</title>
		<link>http://scripting.chaindb.com/2009/04/23/symbol-in-c/</link>
		<comments>http://scripting.chaindb.com/2009/04/23/symbol-in-c/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 15:31:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[symbol]]></category>

		<guid isPermaLink="false">http://scripting.chaindb.com/?p=272</guid>
		<description><![CDATA[The @ symbol tells the string constructor to ignore escape characters and line break The following two strings are therefore identical: &#160; string p1 = &#34;\\\\My Documents\\My Files\\&#34;; string p2 = @&#34;\\My Documents\My Files\&#34;;]]></description>
			<content:encoded><![CDATA[<p>The @ symbol tells the string constructor to ignore escape characters and line break</p>
<p>The following two strings are therefore identical:</p>
<div class="geshi no cnet">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">string p1 = &quot;\\\\My Documents\\My Files\\&quot;;
</div>
</li>
<li class="li1">
<div class="de1">string p2 = @&quot;\\My Documents\My Files\&quot;;</div>
</li>
</ol>
</div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-7360303176440694";
/* scripting_336x280, created 5/12/10 */
google_ad_slot = "2066664949";
google_ad_width = 336;
google_ad_height = 280;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://scripting.chaindb.com/2009/04/23/symbol-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

