<?xml version="1.0" encoding="iso-8859-1"?><!-- generator="b2evolution/4.0.3" -->
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Web Developer - Author(s): pmch22</title>
		<link>http://blogs.lessthandot.com/index.php/WebDev/</link>
		<atom:link rel="self" type="application/rss+xml" href="http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2" />
		<description></description>
		<language>en-GB</language>
		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
		<admin:generatorAgent rdf:resource="http://b2evolution.net/?v=4.0.3"/>
		<ttl>60</ttl>
				<item>
			<title>Application Event Log for your website</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/application-event-log-for-your-website</link>
			<pubDate>Mon, 08 Dec 2008 10:17:20 +0000</pubDate>			<dc:creator>pmch22</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">247@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;A healthy application is one which does not throw up any application errors. However in unexpected situations when it happens, error gets logged on the web server&amp;#8217;s event log. It&amp;#8217;s usually takes a little while to scroll through the event viewer to find your error. One good option is to create a separate application error log for your website.  &lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s see some code now. Start by importing the System.Diagnostics namespace.&lt;br /&gt;
Server.GetLastError() is accessible only at two places &amp;#8211; 1. Page_Error event handler of a page . 2. Application_Error event handler in the global.asax &lt;/p&gt;

&lt;p&gt;In this article, we&amp;#8217;ll trap the unhandled errors in Application_Error event.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb36053&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&amp;lt;%Import &lt;span style=&quot;color: #0600FF;&quot;&gt;Namespace&lt;/span&gt;= &amp;#8220;&lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Diagnostics&lt;/span&gt;&amp;#8221;%&amp;gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; Application_Error&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; sender, EventArgs e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//Code that runs when an unhandled error occurs&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; LogName = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;MySiteAppLog&amp;quot;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; SourceName = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;MySiteAppSource&amp;quot;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//get the HTTPContxt object for the current request. &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HttpContext ctx = HttpContext.&lt;span style=&quot;color: #0000FF;&quot;&gt;Current&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Exception ex = ctx.&lt;span style=&quot;color: #0000FF;&quot;&gt;Server&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetLastError&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;GetBaseException&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; errorInfo = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;&amp;lt;br&amp;gt;Offending URL: &amp;quot;&lt;/span&gt; + ctx.&lt;span style=&quot;color: #0000FF;&quot;&gt;Request&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Url&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; errorInfo += &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;&amp;lt;br&amp;gt;Exception Details: &amp;quot;&lt;/span&gt; + ex.&lt;span style=&quot;color: #0000FF;&quot;&gt;Message&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;ToString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;// ctx.Server.ClearError();&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//Creates the application log when the first error occurs.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;!&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;EventLog.&lt;span style=&quot;color: #0000FF;&quot;&gt;SourceExists&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;SourceName&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; EventLog.&lt;span style=&quot;color: #0000FF;&quot;&gt;CreateEventSource&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;SourceName, LogName&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; EventLog MyLog = &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; EventLog&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MyLog.&lt;span style=&quot;color: #0000FF;&quot;&gt;Source&lt;/span&gt; = SourceName;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MyLog.&lt;span style=&quot;color: #0000FF;&quot;&gt;WriteEntry&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;errorInfo, EventLogEntryType.&lt;span style=&quot;color: #0000FF;&quot;&gt;Error&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Session.&lt;span style=&quot;color: #0000FF;&quot;&gt;Abandon&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb61492&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note in the above code, Server.ClearError() is commented. This brings the customErrors section of the web.config into play. Once the error occurs, the error is logged into the event log and then redirected to a custom error page. Therefore make sure the customErrors section of the web.config file has an entry like this&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb19249&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&amp;lt;customErrors mode= &amp;#8220;On&amp;#8221; defaultRedirect= &amp;#8220;AppError.&lt;span style=&quot;color: #0000FF;&quot;&gt;htm&lt;/span&gt;&amp;#8221;&amp;gt;&amp;lt;/customErrors&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb56547&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Continuing with the creation of Eventlog, create a sample page on your site to generate application error and then follow the below steps.&lt;/p&gt;

&lt;p&gt;1.Open Regedt32. &lt;/p&gt;

&lt;p&gt;2.Go to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog. &lt;/p&gt;

&lt;p&gt;3.Add FULL permissions to ASPNET  and Network services account. &lt;/p&gt;

&lt;p&gt;4.Browse to the sample page and create application error.&lt;/p&gt;

&lt;p&gt;5.This error should be logged in Eventlog as a new log -  MyAppLog. &lt;/p&gt;

&lt;p&gt;6.Once the log is created remove permissions to NetworkServices account in Event log. Network services account is needed only to create the log.  &lt;/p&gt;

&lt;p&gt;7.Repeat error again on the sample page. A new error should be logged in the event log.  &lt;/p&gt;

&lt;p&gt;8.Repeat from remote system(to test as  non- admin user). &lt;/p&gt;

&lt;p&gt;9.Check event log.  &lt;/p&gt;


&lt;p&gt;The only drawback to create to an application specific event log is that you need admin rights on the web server. If that&amp;#8217;s not possible, you can send out an email or write to a log file on the server. Code to send email  -&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb27236&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&amp;lt;%Import &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Web&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Mail&lt;/span&gt;%&amp;gt;&lt;br /&gt;&amp;nbsp;MailMessage &amp;nbsp;errMail = &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; MailMessage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;errMail.&lt;span style=&quot;color: #0000FF;&quot;&gt;To&lt;/span&gt;= &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;ITgroup@company.com&amp;quot;&lt;/span&gt;;&lt;br /&gt;errMail.&lt;span style=&quot;color: #0000FF;&quot;&gt;From&lt;/span&gt;= &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;web@company.com&amp;quot;&lt;/span&gt;; &lt;br /&gt;errMail.&lt;span style=&quot;color: #0000FF;&quot;&gt;Subject&lt;/span&gt; = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Application error on website&amp;quot;&lt;/span&gt;;&lt;br /&gt;errMail.&lt;span style=&quot;color: #0000FF;&quot;&gt;Body&lt;/span&gt; = errorInfo;&lt;br /&gt;SmtpMail.&lt;span style=&quot;color: #0000FF;&quot;&gt;SmtpServer&lt;/span&gt; = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Mailserverip&amp;quot;&lt;/span&gt;;&lt;br /&gt;SmtpMai.&lt;span style=&quot;color: #0000FF;&quot;&gt;Send&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;errMail&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb8011&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Having an application specific event log helps you to view all the errors in one shot and saves you the time of browsing the regular event log and searching errors for your site.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/application-event-log-for-your-website&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>A healthy application is one which does not throw up any application errors. However in unexpected situations when it happens, error gets logged on the web server&#8217;s event log. It&#8217;s usually takes a little while to scroll through the event viewer to find your error. One good option is to create a separate application error log for your website.  </p>

<p>Let&#8217;s see some code now. Start by importing the System.Diagnostics namespace.<br />
Server.GetLastError() is accessible only at two places &#8211; 1. Page_Error event handler of a page . 2. Application_Error event handler in the global.asax </p>

<p>In this article, we&#8217;ll trap the unhandled errors in Application_Error event.</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb69274'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb69274','cb80826'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb69274" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">&lt;%Import <span style="color: #0600FF;">Namespace</span>= &#8220;<span style="color: #000000;">System</span>.<span style="color: #0000FF;">Diagnostics</span>&#8221;%&gt;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0600FF;">void</span> Application_Error<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span> </li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span> </li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">//Code that runs when an unhandled error occurs</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> LogName = <span style="color: #808080;">&quot;MySiteAppLog&quot;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> SourceName = <span style="color: #808080;">&quot;MySiteAppSource&quot;</span>;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//get the HTTPContxt object for the current request. &nbsp;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; HttpContext ctx = HttpContext.<span style="color: #0000FF;">Current</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; Exception ex = ctx.<span style="color: #0000FF;">Server</span>.<span style="color: #0000FF;">GetLastError</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GetBaseException</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> errorInfo = <span style="color: #808080;">&quot;&lt;br&gt;Offending URL: &quot;</span> + ctx.<span style="color: #0000FF;">Request</span>.<span style="color: #0000FF;">Url</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; errorInfo += <span style="color: #808080;">&quot;&lt;br&gt;Exception Details: &quot;</span> + ex.<span style="color: #0000FF;">Message</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008080; font-style: italic;">// ctx.Server.ClearError();</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//Creates the application log when the first error occurs.</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>!<span style="color: #000000;">&#40;</span>EventLog.<span style="color: #0000FF;">SourceExists</span><span style="color: #000000;">&#40;</span>SourceName<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; EventLog.<span style="color: #0000FF;">CreateEventSource</span><span style="color: #000000;">&#40;</span>SourceName, LogName<span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; EventLog MyLog = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> EventLog<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; MyLog.<span style="color: #0000FF;">Source</span> = SourceName;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; MyLog.<span style="color: #0000FF;">WriteEntry</span><span style="color: #000000;">&#40;</span>errorInfo, EventLogEntryType.<span style="color: #0000FF;">Error</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; Session.<span style="color: #0000FF;">Abandon</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li></ol></div><div id="cb80826" style="display: none; color: red;"></div></div></div>

<p>Note in the above code, Server.ClearError() is commented. This brings the customErrors section of the web.config into play. Once the error occurs, the error is logged into the event log and then redirected to a custom error page. Therefore make sure the customErrors section of the web.config file has an entry like this</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb5060'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb5060','cb59300'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb5060" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">&lt;customErrors mode= &#8220;On&#8221; defaultRedirect= &#8220;AppError.<span style="color: #0000FF;">htm</span>&#8221;&gt;&lt;/customErrors&gt;</li></ol></div><div id="cb59300" style="display: none; color: red;"></div></div></div>
<p>Continuing with the creation of Eventlog, create a sample page on your site to generate application error and then follow the below steps.</p>

<p>1.Open Regedt32. </p>

<p>2.Go to HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog. </p>

<p>3.Add FULL permissions to ASPNET  and Network services account. </p>

<p>4.Browse to the sample page and create application error.</p>

<p>5.This error should be logged in Eventlog as a new log -  MyAppLog. </p>

<p>6.Once the log is created remove permissions to NetworkServices account in Event log. Network services account is needed only to create the log.  </p>

<p>7.Repeat error again on the sample page. A new error should be logged in the event log.  </p>

<p>8.Repeat from remote system(to test as  non- admin user). </p>

<p>9.Check event log.  </p>


<p>The only drawback to create to an application specific event log is that you need admin rights on the web server. If that&#8217;s not possible, you can send out an email or write to a log file on the server. Code to send email  -</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb76501'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb76501','cb95228'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb76501" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">&lt;%Import <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">Mail</span>%&gt;</li><li style="" class="li2">&nbsp;MailMessage &nbsp;errMail = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> MailMessage<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">errMail.<span style="color: #0000FF;">To</span>= <span style="color: #808080;">&quot;ITgroup@company.com&quot;</span>;</li><li style="" class="li2">errMail.<span style="color: #0000FF;">From</span>= <span style="color: #808080;">&quot;web@company.com&quot;</span>; </li><li style="" class="li1">errMail.<span style="color: #0000FF;">Subject</span> = <span style="color: #808080;">&quot;Application error on website&quot;</span>;</li><li style="" class="li2">errMail.<span style="color: #0000FF;">Body</span> = errorInfo;</li><li style="" class="li1">SmtpMail.<span style="color: #0000FF;">SmtpServer</span> = <span style="color: #808080;">&quot;Mailserverip&quot;</span>;</li><li style="" class="li2">SmtpMai.<span style="color: #0000FF;">Send</span><span style="color: #000000;">&#40;</span>errMail<span style="color: #000000;">&#41;</span>;</li></ol></div><div id="cb95228" style="display: none; color: red;"></div></div></div>

<p>Having an application specific event log helps you to view all the errors in one shot and saves you the time of browsing the regular event log and searching errors for your site.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/application-event-log-for-your-website">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/application-event-log-for-your-website#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=247</wfw:commentRss>
		</item>
				<item>
			<title>Intranet site for Reporting Services Reports</title>
			<link>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/intranet-site-for-reporting-services-rep</link>
			<pubDate>Fri, 28 Nov 2008 17:40:40 +0000</pubDate>			<dc:creator>pmch22</dc:creator>
			<category domain="main">Web Design, Graphics &amp; Styling</category>			<guid isPermaLink="false">231@http://blogs.lessthandot.com/</guid>
						<description>&lt;p&gt;Recently I was asked if I could design an intranet site to provide a single point access to all reports developed using Reporting Services. To begin with I developed a site where the Report URL was saved as a hyperlink on the page. Soon I realized that there were 50 odd reports and new reports keep getting added every now and then. This way I would have to keep updating the hyperlinks forever. I had to make the site dynamic by getting the latest reports from the report server. From security standpoint, access of the reports should be based on the login and any changes in security should be reflected realtime.&lt;/p&gt;

&lt;p&gt;Reporting Services web service is the simplest way to meet the above requirements. The web service resides on your reporting server.  The Web Service includes a ton of methods that enable you to read and manage the report server and its contents. Let me dive right into the implementation part.&lt;br /&gt;
1. Open Visual Studio, create a new website.&lt;br /&gt;
2. Add the web service reference to your application using Add Web Reference. The path of the web service would be &lt;a href=&quot;http://reportservername/ReportServer/ReportService.asmx&quot;&gt;http://reportservername/ReportServer/ReportService.asmx&lt;/a&gt;&lt;br /&gt;
Change the web reference name say ReportingService and click Add Web Reference. This name will become the namespace for the web service proxy. &lt;/p&gt;
&lt;div class=&quot;image_block&quot;&gt;&lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/WebDev/RSWebService.JPG&quot; alt=&quot;&quot; title=&quot;&quot; width=&quot;640&quot; height=&quot;400&quot; /&gt;&lt;/div&gt;

&lt;p&gt;Once the reference is added,open the web.config file. You&amp;#8217;ll notice a new section has been added the web.config&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;xml&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;xml&quot; id=&quot;cb49336&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;appSettings&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;key&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Reporting.ReportService&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;value&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://reportservername/ReportServer/ReportService.asmx&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/appSettings&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb76393&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;3. Next, we need add reference to the Microsoft.ReportViewer.WebForms inorder to use the Report Viewer.Go to Website. Add Reference. Select &lt;br /&gt;
Microsoft.ReportViewer.WebForms. Click Add. This would add the Report Viewer to the toolbox and new sections to the web.config.&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;xml&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;xml&quot; id=&quot;cb67285&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;assemblies&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;assembly&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/assemblies&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;buildProviders&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;extension&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;.rdlc&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/buildProviders&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;httpHandlers&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;verb&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;*&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;path&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Reserved.ReportViewerWebControl.axd&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/httpHandlers&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb52228&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;4. Now we move on to creating a new page and designing the layout of the page. Typically the design would be given by user group but in my case I had to create a layout and present it for approval. As I browsed the report manager, I realized that we had several folders and each folder had reports related to a department or task. I had to organize the reports in such a way it would be easy for novice users to use it without any help. I cannot list all the reports as that would show too many reports to the user (depending on their access level of course) and that can be overwhelming!! Therefore I decided to use 2 combo boxes, one to list the folders and the second to list the reports in each folder. I also have a Run Report button the page. User can select a report in the combo box and click Run Report. This would display the in a new window.&lt;/p&gt;


&lt;div class=&quot;image_block&quot;&gt;&lt;img src=&quot;http://blogs.lessthandot.com/media/blogs/WebDev/reportcatalog.JPG&quot; alt=&quot;&quot; title=&quot;&quot; width=&quot;640&quot; height=&quot;400&quot; /&gt;&lt;/div&gt;

&lt;p&gt;5. We start by including the Reporting Services namespace to the code behind file. Then create an instance of the ReportingService proxy class on the page load event. Pass the client login credentials.&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb17738&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; ReportingServices;&lt;br /&gt;&amp;nbsp;&lt;span style=&quot;color: #0600FF;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; Page_Load&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; sender, EventArgs e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;!Page.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsPostBack&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReportingService rs = &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; ReportingService&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rs.&lt;span style=&quot;color: #0000FF;&quot;&gt;Credentials&lt;/span&gt; = &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Net&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;CredentialCache&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;DefaultCredentials&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;CatalogItem item &lt;span style=&quot;color: #0600FF;&quot;&gt;in&lt;/span&gt; rs.&lt;span style=&quot;color: #0000FF;&quot;&gt;ListChildren&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;, &lt;span style=&quot;color: #0600FF;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;item.&lt;span style=&quot;color: #0000FF;&quot;&gt;Type&lt;/span&gt; == ItemTypeEnum.&lt;span style=&quot;color: #0000FF;&quot;&gt;Folder&lt;/span&gt; &amp;amp;&amp;amp; item.&lt;span style=&quot;color: #0000FF;&quot;&gt;Name&lt;/span&gt; != &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Data Sources&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//skip datasource folder.&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #008080; font-style: italic;&quot;&gt;//DropDownList1.Items.Add(new ListItem(item.Name, item.Path));&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lbModules.&lt;span style=&quot;color: #0000FF;&quot;&gt;Items&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Add&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; ListItem&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;item.&lt;span style=&quot;color: #0000FF;&quot;&gt;Name&lt;/span&gt;, item.&lt;span style=&quot;color: #0000FF;&quot;&gt;Path&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb69667&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;ListChildren method requires 2 parameters. The first parameter is the path of the folder to look in and the second parameter is a flag to indicate if the method should recurse through subdirectories. &lt;br /&gt;
The method returns an array of catalogitem objects based on the user permissions. The catalog items can be reports,data sources,folders Once we get the array of catalog items, we loop through the array and read the properties of each catalogitem. A catalogitem properties give us information about the item like Name,Created By, Description, Path, Type etc. Here we mainly make use of the type and Name. If an item is of type &amp;#8220;Folder&amp;#8221; we add the item to combo box. Since we don&amp;#8217;t want to show data sources folder to users, we check for the name &amp;#8220;Data Sources&amp;#8221; and ignore it.&lt;/p&gt;

&lt;p&gt;6.The next method  ListReports is written for SelectedIndexChanged event of the folders combobox which means when an item in the folders combobox is selected this event is fired. As the name suggests this method lists all the reports in the selected folder item. We pass the path of the selected folder as a parameter to the List Children method. This time we check if the Item.type is Report.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb49941&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; ListReports&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; sender, EventArgs e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; path = &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lbReports.&lt;span style=&quot;color: #0000FF;&quot;&gt;Items&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Clear&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReportingService rs = &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; ReportingService&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rs.&lt;span style=&quot;color: #0000FF;&quot;&gt;Credentials&lt;/span&gt; = &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Net&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;CredentialCache&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;DefaultCredentials&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; path = lbModules.&lt;span style=&quot;color: #0000FF;&quot;&gt;SelectedValue&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;foreach&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;CatalogItem item &lt;span style=&quot;color: #0600FF;&quot;&gt;in&lt;/span&gt; rs.&lt;span style=&quot;color: #0000FF;&quot;&gt;ListChildren&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;path, &lt;span style=&quot;color: #0600FF;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;item.&lt;span style=&quot;color: #0000FF;&quot;&gt;Type&lt;/span&gt; == ItemTypeEnum.&lt;span style=&quot;color: #0000FF;&quot;&gt;Report&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lbReports.&lt;span style=&quot;color: #0000FF;&quot;&gt;Items&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Add&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; ListItem&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;item.&lt;span style=&quot;color: #0000FF;&quot;&gt;Name&lt;/span&gt;, item.&lt;span style=&quot;color: #0000FF;&quot;&gt;Path&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;lbReports.&lt;span style=&quot;color: #0000FF;&quot;&gt;Items&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Count&lt;/span&gt; &amp;gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lbReports.&lt;span style=&quot;color: #0000FF;&quot;&gt;Visible&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb99684&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;7. Now to run the report.  This is a simple javascript function to open the report in a new window. Pass the path of the report the new window.&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;javascript&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;javascript&quot; id=&quot;cb75997&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;function OpenReport()&lt;br /&gt;&amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; var path=document.getElementById(&amp;quot;lbReports&amp;quot;).value;&lt;br /&gt;&amp;nbsp; &amp;nbsp; alert(path);&lt;br /&gt;&amp;nbsp; &amp;nbsp; window.open(&amp;quot;OpenReport.aspx?&amp;amp;Path=&amp;quot;+path,&amp;quot;&amp;quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb24652&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;8. Our next task is to display the report on a web page.  Start by creating a new page. Drag and drop the report viewer control from the toolbox. In the code behind file get the path of the selected report from the query string and set the path of the report viewer.&lt;/p&gt;

&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;csharp&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;csharp&quot; id=&quot;cb88378&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;using&lt;/span&gt; Microsoft.&lt;span style=&quot;color: #0000FF;&quot;&gt;Reporting&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;WebForms&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&lt;span style=&quot;color: #0600FF;&quot;&gt;public&lt;/span&gt; partial &lt;span style=&quot;color: #FF0000;&quot;&gt;class&lt;/span&gt; OpenReport : &lt;span style=&quot;color: #000000;&quot;&gt;System&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Web&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;UI&lt;/span&gt;.&lt;span style=&quot;color: #0000FF;&quot;&gt;Page&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #0600FF;&quot;&gt;void&lt;/span&gt; Page_Load&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;object&lt;/span&gt; sender, EventArgs e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #FF0000;&quot;&gt;string&lt;/span&gt; ReportPath=&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReportPath = Request.&lt;span style=&quot;color: #0000FF;&quot;&gt;QueryString&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;Path&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;ReportPath != &lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt; || ReportPath != &lt;span style=&quot;color: #0600FF;&quot;&gt;null&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #0600FF;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;!Page.&lt;span style=&quot;color: #0000FF;&quot;&gt;IsPostBack&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReportViewer1.&lt;span style=&quot;color: #0000FF;&quot;&gt;ShowParameterPrompts&lt;/span&gt; = &lt;span style=&quot;color: #0600FF;&quot;&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ReportViewer1.&lt;span style=&quot;color: #0000FF;&quot;&gt;ProcessingMode&lt;/span&gt; = ProcessingMode.&lt;span style=&quot;color: #0000FF;&quot;&gt;Remote&lt;/span&gt;;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ServerReport svrReport = ReportViewer1.&lt;span style=&quot;color: #0000FF;&quot;&gt;ServerReport&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;svrReport.&lt;span style=&quot;color: #0000FF;&quot;&gt;ReportServerUrl&lt;/span&gt; = &lt;a href=&quot;http://www.google.com/search?q=new+msdn.microsoft.com&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;new&lt;/span&gt;&lt;/a&gt; Uri&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #808080;&quot;&gt;&amp;quot;http://reportservername/ReportServer/&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; svrReport.&lt;span style=&quot;color: #0000FF;&quot;&gt;ReportPath&lt;/span&gt; = ReportPath;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb80419&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Deployment  -Where to host?&lt;/p&gt;

&lt;p&gt;The simplest way to deploy the application on your intranet is by hosting the site on the reporting server.  When the application and the reporting server are on the same machine, enable impersonation in web config file. Doing so will pass the user credentials directly to the report server.&lt;/p&gt;
&lt;div class=&quot;codebox&quot;&gt;&lt;div class=&quot;codeheader&quot;&gt;Code: &lt;span&gt;xml&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;codeholder&quot;&gt;&lt;div class=&quot;xml&quot; id=&quot;cb84557&quot; style=&quot;display: block; color: rgb(0, 0, 0);&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;authentication&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;mode&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Windows&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;identity&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;impersonate&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;&amp;#8211;To&lt;/span&gt; allow only authorized users to access the intranet site, include&amp;#8211;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;authorization&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;allow&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;users&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;*&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;deny&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;users&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;?&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/authorization&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div id=&quot;cb93224&quot; style=&quot;display: none; color: red;&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When the reporting server and web server are on different machines, Kerberos authenication protocol is required to pass the user credentails from web server to reporting server.&lt;/p&gt;


&lt;p&gt;That&amp;#8217;s about it. Creating a repository of reports is pretty straighforward using Reporting Services web service. I hope you&amp;#8217;ll find this example useful.&lt;/p&gt;&lt;div class=&quot;item_footer&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;a href=&quot;http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/intranet-site-for-reporting-services-rep&quot;&gt;Original post&lt;/a&gt; blogged on &lt;a href=&quot;http://lessthandot.com/&quot;&gt;LessThanDot&lt;/a&gt;.&lt;/small&gt;&lt;/p&gt;&lt;/div&gt;</description>
			<content:encoded><![CDATA[<p>Recently I was asked if I could design an intranet site to provide a single point access to all reports developed using Reporting Services. To begin with I developed a site where the Report URL was saved as a hyperlink on the page. Soon I realized that there were 50 odd reports and new reports keep getting added every now and then. This way I would have to keep updating the hyperlinks forever. I had to make the site dynamic by getting the latest reports from the report server. From security standpoint, access of the reports should be based on the login and any changes in security should be reflected realtime.</p>

<p>Reporting Services web service is the simplest way to meet the above requirements. The web service resides on your reporting server.  The Web Service includes a ton of methods that enable you to read and manage the report server and its contents. Let me dive right into the implementation part.<br />
1. Open Visual Studio, create a new website.<br />
2. Add the web service reference to your application using Add Web Reference. The path of the web service would be <a href="http://reportservername/ReportServer/ReportService.asmx">http://reportservername/ReportServer/ReportService.asmx</a><br />
Change the web reference name say ReportingService and click Add Web Reference. This name will become the namespace for the web service proxy. </p>
<div class="image_block"><img src="http://blogs.lessthandot.com/media/blogs/WebDev/RSWebService.JPG" alt="" title="" width="640" height="400" /></div>

<p>Once the reference is added,open the web.config file. You&#8217;ll notice a new section has been added the web.config</p>

<div class="codebox"><div class="codeheader"><span>xml</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb91326'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb91326','cb71776'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="xml" id="cb91326" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;appSettings<span style="font-weight: bold; color: black;">&gt;</span></span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;add</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;Reporting.ReportService&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;http://reportservername/ReportServer/ReportService.asmx&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/appSettings<span style="font-weight: bold; color: black;">&gt;</span></span></span></li></ol></div><div id="cb71776" style="display: none; color: red;"></div></div></div>


<p>3. Next, we need add reference to the Microsoft.ReportViewer.WebForms inorder to use the Report Viewer.Go to Website. Add Reference. Select <br />
Microsoft.ReportViewer.WebForms. Click Add. This would add the Report Viewer to the toolbox and new sections to the web.config.</p>
<div class="codebox"><div class="codeheader"><span>xml</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb44450'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb44450','cb62521'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="xml" id="cb44450" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;assemblies<span style="font-weight: bold; color: black;">&gt;</span></span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;add</span> <span style="color: #000066;">assembly</span>=<span style="color: #ff0000;">&quot;Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/assemblies<span style="font-weight: bold; color: black;">&gt;</span></span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;buildProviders<span style="font-weight: bold; color: black;">&gt;</span></span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;add</span> <span style="color: #000066;">extension</span>=<span style="color: #ff0000;">&quot;.rdlc&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/buildProviders<span style="font-weight: bold; color: black;">&gt;</span></span></span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;httpHandlers<span style="font-weight: bold; color: black;">&gt;</span></span></span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;add</span> <span style="color: #000066;">verb</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;Reserved.ReportViewerWebControl.axd&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/httpHandlers<span style="font-weight: bold; color: black;">&gt;</span></span></span></li></ol></div><div id="cb62521" style="display: none; color: red;"></div></div></div>
<p>4. Now we move on to creating a new page and designing the layout of the page. Typically the design would be given by user group but in my case I had to create a layout and present it for approval. As I browsed the report manager, I realized that we had several folders and each folder had reports related to a department or task. I had to organize the reports in such a way it would be easy for novice users to use it without any help. I cannot list all the reports as that would show too many reports to the user (depending on their access level of course) and that can be overwhelming!! Therefore I decided to use 2 combo boxes, one to list the folders and the second to list the reports in each folder. I also have a Run Report button the page. User can select a report in the combo box and click Run Report. This would display the in a new window.</p>


<div class="image_block"><img src="http://blogs.lessthandot.com/media/blogs/WebDev/reportcatalog.JPG" alt="" title="" width="640" height="400" /></div>

<p>5. We start by including the Reporting Services namespace to the code behind file. Then create an instance of the ReportingService proxy class on the page load event. Pass the client login credentials.</p>
<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb79232'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb79232','cb54585'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb79232" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">using</span> ReportingServices;</li><li style="" class="li2">&nbsp;<span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp;<span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp;<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>!Page.<span style="color: #0000FF;">IsPostBack</span><span style="color: #000000;">&#41;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReportingService rs = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ReportingService<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.<span style="color: #0000FF;">Credentials</span> = <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Net</span>.<span style="color: #0000FF;">CredentialCache</span>.<span style="color: #0000FF;">DefaultCredentials</span>;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>CatalogItem item <span style="color: #0600FF;">in</span> rs.<span style="color: #0000FF;">ListChildren</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;/&quot;</span>, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>item.<span style="color: #0000FF;">Type</span> == ItemTypeEnum.<span style="color: #0000FF;">Folder</span> &amp;&amp; item.<span style="color: #0000FF;">Name</span> != <span style="color: #808080;">&quot;Data Sources&quot;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//skip datasource folder.</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//DropDownList1.Items.Add(new ListItem(item.Name, item.Path));</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lbModules.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ListItem<span style="color: #000000;">&#40;</span>item.<span style="color: #0000FF;">Name</span>, item.<span style="color: #0000FF;">Path</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp;<span style="color: #000000;">&#125;</span></li></ol></div><div id="cb54585" style="display: none; color: red;"></div></div></div>

<p>ListChildren method requires 2 parameters. The first parameter is the path of the folder to look in and the second parameter is a flag to indicate if the method should recurse through subdirectories. <br />
The method returns an array of catalogitem objects based on the user permissions. The catalog items can be reports,data sources,folders Once we get the array of catalog items, we loop through the array and read the properties of each catalogitem. A catalogitem properties give us information about the item like Name,Created By, Description, Path, Type etc. Here we mainly make use of the type and Name. If an item is of type &#8220;Folder&#8221; we add the item to combo box. Since we don&#8217;t want to show data sources folder to users, we check for the name &#8220;Data Sources&#8221; and ignore it.</p>

<p>6.The next method  ListReports is written for SelectedIndexChanged event of the folders combobox which means when an item in the folders combobox is selected this event is fired. As the name suggests this method lists all the reports in the selected folder item. We pass the path of the selected folder as a parameter to the List Children method. This time we check if the Item.type is Report.</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb72508'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb72508','cb57208'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb72508" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> ListReports<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> path = <span style="color: #808080;">&quot;&quot;</span>;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; lbReports.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Clear</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; ReportingService rs = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ReportingService<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; rs.<span style="color: #0000FF;">Credentials</span> = <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Net</span>.<span style="color: #0000FF;">CredentialCache</span>.<span style="color: #0000FF;">DefaultCredentials</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path = lbModules.<span style="color: #0000FF;">SelectedValue</span>;</li><li style="" class="li2">&nbsp; </li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>CatalogItem item <span style="color: #0600FF;">in</span> rs.<span style="color: #0000FF;">ListChildren</span><span style="color: #000000;">&#40;</span>path, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>item.<span style="color: #0000FF;">Type</span> == ItemTypeEnum.<span style="color: #0000FF;">Report</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lbReports.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> ListItem<span style="color: #000000;">&#40;</span>item.<span style="color: #0000FF;">Name</span>, item.<span style="color: #0000FF;">Path</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>lbReports.<span style="color: #0000FF;">Items</span>.<span style="color: #0000FF;">Count</span> &gt; <span style="color: #FF0000;">0</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lbReports.<span style="color: #0000FF;">Visible</span> = <span style="color: #0600FF;">true</span>;</li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2"><span style="color: #000000;">&#125;</span></li></ol></div><div id="cb57208" style="display: none; color: red;"></div></div></div>

<p>7. Now to run the report.  This is a simple javascript function to open the report in a new window. Pass the path of the report the new window.</p>
<div class="codebox"><div class="codeheader"><span>javascript</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb92217'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb92217','cb94685'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="javascript" id="cb92217" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1">function OpenReport()</li><li style="" class="li2">&nbsp; &nbsp; {</li><li style="" class="li1">&nbsp; &nbsp; var path=document.getElementById(&quot;lbReports&quot;).value;</li><li style="" class="li2">&nbsp; &nbsp; alert(path);</li><li style="" class="li1">&nbsp; &nbsp; window.open(&quot;OpenReport.aspx?&amp;Path=&quot;+path,&quot;&quot;);</li><li style="" class="li2">&nbsp; &nbsp; }</li></ol></div><div id="cb94685" style="display: none; color: red;"></div></div></div>

<p>8. Our next task is to display the report on a web page.  Start by creating a new page. Drag and drop the report viewer control from the toolbox. In the code behind file get the path of the selected report from the query string and set the path of the report viewer.</p>

<div class="codebox"><div class="codeheader"><span>csharp</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb46833'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb46833','cb28270'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="csharp" id="cb46833" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #0600FF;">using</span> Microsoft.<span style="color: #0000FF;">Reporting</span>.<span style="color: #0000FF;">WebForms</span>;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1"><span style="color: #0600FF;">public</span> partial <span style="color: #FF0000;">class</span> OpenReport : <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">Page</span></li><li style="" class="li2"><span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span> ReportPath=<span style="color: #808080;">&quot;&quot;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; ReportPath = Request.<span style="color: #0000FF;">QueryString</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">&quot;Path&quot;</span><span style="color: #000000;">&#93;</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>ReportPath != <span style="color: #808080;">&quot;&quot;</span> || ReportPath != <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>!Page.<span style="color: #0000FF;">IsPostBack</span><span style="color: #000000;">&#41;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReportViewer1.<span style="color: #0000FF;">ShowParameterPrompts</span> = <span style="color: #0600FF;">true</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReportViewer1.<span style="color: #0000FF;">ProcessingMode</span> = ProcessingMode.<span style="color: #0000FF;">Remote</span>;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ServerReport svrReport = ReportViewer1.<span style="color: #0000FF;">ServerReport</span>;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp;svrReport.<span style="color: #0000FF;">ReportServerUrl</span> = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Uri<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;http://reportservername/ReportServer/&quot;</span><span style="color: #000000;">&#41;</span>;</li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; svrReport.<span style="color: #0000FF;">ReportPath</span> = ReportPath;</li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp;</li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></li><li style="" class="li1"><span style="color: #000000;">&#125;</span></li></ol></div><div id="cb28270" style="display: none; color: red;"></div></div></div>

<p>Deployment  -Where to host?</p>

<p>The simplest way to deploy the application on your intranet is by hosting the site on the reporting server.  When the application and the reporting server are on the same machine, enable impersonation in web config file. Doing so will pass the user credentials directly to the report server.</p>
<div class="codebox"><div class="codeheader"><span>xml</span><div class="codebox_javascript_links"><a href="http://blogs.lessthandot.com" onclick="linenumberOnOff('cb56177'); return false;">Line number Off</a> | <a href="http://blogs.lessthandot.com#" onclick="expandCode('cb56177','cb66082'); return false;">Hide</a> | <a href="http://blogs.lessthandot.com#" onclick="selectCode(this); return false;">Select all</a></div></div><!-- we need this dummy div to fix a firefox bug when selecting code lines --><div class="codeholder"><div class="xml" id="cb56177" style="display: block; color: rgb(0, 0, 0);"><ol><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;authentication</span> <span style="color: #000066;">mode</span>=<span style="color: #ff0000;">&quot;Windows&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;identity</span> <span style="color: #000066;">impersonate</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;&#8211;To</span> allow only authorized users to access the intranet site, include&#8211;<span style="font-weight: bold; color: black;">&gt;</span></span></li><li style="" class="li2"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;authorization<span style="font-weight: bold; color: black;">&gt;</span></span></span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;allow</span> <span style="color: #000066;">users</span>=<span style="color: #ff0000;">&quot;*&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;deny</span> <span style="color: #000066;">users</span>=<span style="color: #ff0000;">&quot;?&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span></li><li style="" class="li1"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/authorization<span style="font-weight: bold; color: black;">&gt;</span></span></span></li></ol></div><div id="cb66082" style="display: none; color: red;"></div></div></div>

<p>When the reporting server and web server are on different machines, Kerberos authenication protocol is required to pass the user credentails from web server to reporting server.</p>


<p>That&#8217;s about it. Creating a repository of reports is pretty straighforward using Reporting Services web service. I hope you&#8217;ll find this example useful.</p><div class="item_footer"><p><small><a href="http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/intranet-site-for-reporting-services-rep">Original post</a> blogged on <a href="http://lessthandot.com/">LessThanDot</a>.</small></p></div>]]></content:encoded>
								<comments>http://blogs.lessthandot.com/index.php/WebDev/WebDesignGraphicsStyling/intranet-site-for-reporting-services-rep#comments</comments>
			<wfw:commentRss>http://blogs.lessthandot.com/index.php/WebDev/?tempskin=_rss2&#38;disp=comments&#38;p=231</wfw:commentRss>
		</item>
			</channel>
</rss>
