<?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>RuslanY Blog &#187; Other</title>
	<atom:link href="http://ruslany.net/category/other/feed/" rel="self" type="application/rss+xml" />
	<link>http://ruslany.net</link>
	<description>IIS, FastCGI, PHP and other interesting stuff</description>
	<lastBuildDate>Fri, 30 Jul 2010 23:07:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Web Farm Framework 2.0 overview</title>
		<link>http://ruslany.net/2010/07/web-farm-framework-2-0-overview/</link>
		<comments>http://ruslany.net/2010/07/web-farm-framework-2-0-overview/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 23:00:28 +0000</pubDate>
		<dc:creator>ruslany</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[Web Farm]]></category>

		<guid isPermaLink="false">http://ruslany.net/?p=829</guid>
		<description><![CDATA[IIS team has recently released a Web Farm Framework 2.0 beta. The goal of the Web Farm Framework is to enable easy provisioning, deployment and managing of web farms. This blog post provides an example of what Web Farm Framework can do and how it can simplify the Web Farm management tasks. To demonstrate the capabilities of the [...]]]></description>
			<content:encoded><![CDATA[<p>IIS team has recently released a <a href="http://www.iis.net/download/webfarmframework">Web Farm Framework 2.0 beta</a>. The goal of the Web Farm Framework is to enable easy provisioning, deployment and managing of web farms. This blog post provides an example of what Web Farm Framework can do and how it can simplify the Web Farm management tasks.</p>
<p>To demonstrate the capabilities of the tool, we will create a simple web farm that looks as on the following diagram:</p>
<p><a href="http://ruslany.net/wp-content/uploads/2010/07/WFF_diagram1.png"><img class="alignnone size-medium wp-image-830 screenshot" title="WFF_diagram1" src="http://ruslany.net/wp-content/uploads/2010/07/WFF_diagram1-400x236.png" alt="" width="400" height="236" /></a></p>
<ul>
<li>The load balancer will be using the Application Request Routing for IIS 7 and will also act as a <strong>Web Farm Controller</strong>. Web Farm Controller manages all the machines within the web farm and it has the Web Farm Framework 2.0 installed.</li>
<li>The <strong>Primary Server</strong>, in addition to serving the web requests, also acts as an example server for all the other servers in the farm. Web Farm Framework will ensure that every new secondary server added to the web farm has exact same components installed and is configured exactly as the primary server.</li>
<li>The <strong>Secondary Server(s)</strong> will serve web requests. It’s configuration and content matches the primary server.<span id="more-829"></span></li>
</ul>
<h3>Setting up a web farm</h3>
<p>The example web farm will contain 3 servers:</p>
<ol>
<li>DEMOCONTROLLER – this is the load balancer and controller machine. It has ARR 2.0 and Web Farm Framework 2.0 installed.</li>
<li>DEMOPRIMARY – this is the primary content server that has a PHP application setup. Here is what is installed on the primary server:<br />
<a href="http://ruslany.net/wp-content/uploads/2010/07/WebFarm3.png"><img class="alignnone size-medium wp-image-831 screenshot" title="WebFarm3" src="http://ruslany.net/wp-content/uploads/2010/07/WebFarm3-400x190.png" alt="" width="400" height="190" /></a></li>
<li>DEMOSECONDARY – this is the secondary content server that is a clean OS installation without any components or content installed. There is nothing installed on that server:<br />
<a href="http://ruslany.net/wp-content/uploads/2010/07/WebFarm4.png"><img class="alignnone size-medium wp-image-832 screenshot" title="WebFarm4" src="http://ruslany.net/wp-content/uploads/2010/07/WebFarm4-400x151.png" alt="" width="400" height="151" /></a></li>
</ol>
<p>Once the <a href="http://www.iis.net/download/ApplicationRequestRouting">Application Request Routing 2.0</a> and <a href="http://www.iis.net/download/webfarmframework">Web Farm Framework 2.0</a> have been setup on the controller server, the new web farm can be created by using IIS Manager UI:</p>
<p><a href="http://ruslany.net/wp-content/uploads/2010/07/WebFarm1.png"><img class="alignnone size-full wp-image-833 screenshot" title="WebFarm1" src="http://ruslany.net/wp-content/uploads/2010/07/WebFarm1.png" alt="" width="359" height="204" /></a></p>
<p>In the “Add Server Farm” dialog specify the name for the web farm (e.g. demofarm) and make sure that “Server Farm is available for load balancing” and “Provision server farm” options are selected. You will also need to provide the credentials for the account that exists all all the web farm servers and that has administrative privileges on all those servers.</p>
<p><a href="http://ruslany.net/wp-content/uploads/2010/07/WebFarm2.png"><img class="alignnone size-medium wp-image-834 screenshot" title="WebFarm2" src="http://ruslany.net/wp-content/uploads/2010/07/WebFarm2-400x301.png" alt="" width="400" height="301" /></a></p>
<p>On next page add the primary server and the secondary server to it. The Web Farm Framework will verify that it can connect to those servers. If connection fails then most probably the firewall on a server is not configured correctly. Follow the instructions at <a href="http://learn.iis.net/page.aspx/913/system-and-platform-requirements-for-the-web-farm-framework-20-beta-for-iis-7/">System Requirements for the Web Farm Framework 2.0</a> to troubleshoot connection problems.</p>
<p><a href="http://ruslany.net/wp-content/uploads/2010/07/WebFarm5.png"><img class="alignnone size-medium wp-image-835 screenshot" title="WebFarm5" src="http://ruslany.net/wp-content/uploads/2010/07/WebFarm5-400x298.png" alt="" width="400" height="298" /></a></p>
<p>After both servers have been added, the Web Farm Framework starts provisioning the web farm. You can monitor the provision process by using the IIS Manager UI:</p>
<p><a href="http://ruslany.net/wp-content/uploads/2010/07/WebFarm6.png"><img class="alignnone size-medium wp-image-836 screenshot" title="WebFarm6" src="http://ruslany.net/wp-content/uploads/2010/07/WebFarm6-400x280.png" alt="" width="400" height="280" /></a></p>
<p>Here is what happens during the web farm provisioning:</p>
<ol>
<li>The Web Farm Agent component is installed on both content servers in web farm. The Web Farm Agent is used to establish communication between each content server and the controller.</li>
<li>The primary server is added to the Web Farm and Web Deployment Tool is installed on it. Web Deployment Tool is used to synchronize the web content and configuration across all servers in the web farm.</li>
<li>The primary server is queried for all the installed components and for the web content.</li>
<li>The secondary server is added to web farm and the Web Deployment Tool is installed there too. After that all the same components that were installed on the primary server are also installed on the secondary server.</li>
<li>Finally both servers are marked as ready for load balancing, which means that they are now included in the web farm and web request will be routed to them.<br />
<a href="http://ruslany.net/wp-content/uploads/2010/07/WebFarm8.png"><img class="alignnone size-medium wp-image-837 screenshot" title="WebFarm8" src="http://ruslany.net/wp-content/uploads/2010/07/WebFarm8-400x280.png" alt="" width="400" height="280" /></a></li>
</ol>
<p>After both servers have been added to the web farm, the secondary server has exact same components installed and exact same web content as the primary server:</p>
<p><a href="http://ruslany.net/wp-content/uploads/2010/07/WebFarm9.png"><img class="alignnone size-medium wp-image-838 screenshot" title="WebFarm9" src="http://ruslany.net/wp-content/uploads/2010/07/WebFarm9-400x209.png" alt="" width="400" height="209" /></a></p>
<p>The Web Farm Framework periodically checks all the servers to ensure that they are synchronized with the primary server. If any new component is installed on the primary server or if any content has been changed on the primary server, those changes will be propagated to secondary servers. As soon as another secondary server is added to the web farm, the provisioning process for that server will start automatically. This makes it very easy to add new servers to the web farm. Also, the servers in the web farm do not have to use exact same version of the operating system. For example a web farm can contain a mix of x86 and x64 machines, as well as Windows Server 2008 and 2008 R2.</p>
<h3>More information</h3>
<p>Automatic provisioning of the servers and applications in a web farm is one of the many capabilities of the Web Farm Framework. Other cool things included in Web Farm Framework are:</p>
<ul>
<li>Support for <a href="http://learn.iis.net/page.aspx/940/running-server-operations-using-the-web-farm-framework-20-beta-for-iis-7/">running server operations</a> on the web farm nodes, e.g. starting and stopping services, rebooting and so on;</li>
<li><a href="http://learn.iis.net/page.aspx/925/web-farm-framework-20-for-iis-7-apis/">API’s for managing web farms</a>;</li>
<li><a href="http://learn.iis.net/page.aspx/934/web-farm-framework-20-for-iis-7-cmdlets-for-windows-powershell/">PowerShell cmdlets</a> for managing web farms.</li>
</ul>
<p>More information about the Web Farm Framework 2.0 can be found at <a href="http://learn.iis.net/page.aspx/905/microsoft-web-farm-framework-20-beta-for-iis-7/">Microsoft Web Farm Framework 2.0 Beta for IIS 7</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ruslany.net/2010/07/web-farm-framework-2-0-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup IIS on Server Core – Windows Server 2008 R2</title>
		<link>http://ruslany.net/2009/02/setup-iis-on-server-core-windows-server-2008-r2/</link>
		<comments>http://ruslany.net/2009/02/setup-iis-on-server-core-windows-server-2008-r2/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 01:20:24 +0000</pubDate>
		<dc:creator>ruslany</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[ASPNET]]></category>
		<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://ruslany.net/?p=260</guid>
		<description><![CDATA[This post has been updated from its original version to correct the installation instructions, which have changed since the time the post was written in Feb 2009. With the addition of .NET Framework to Server Core in Windows Server 2008 R2 the Server Core installation option became even more appealing for those who want to use [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>This post has been updated from its original version to correct the installation instructions, which have changed since the time the post was written in Feb 2009.</p></blockquote>
<p>With the addition of .NET Framework to Server Core in Windows Server 2008 R2 the Server Core installation option became even more appealing for those who want to use a very low footprint server for hosting their applications. Availability of .NET framework provides the following great benefits:</p>
<ol>
<li><strong>ASP.NET support</strong> – you can now use Server Core to host your ASP.NET applications.</li>
<li><strong>IIS Remote Management</strong> – Server Core does not provide any user interface other than command line. But if you prefer to use IIS Manager UI to administer IIS, you can now use IIS Remote Manager to connect to IIS on Server Core and perform all the management tasks from within familiar UI of IIS Manager.</li>
<li><strong>PowerShell</strong> – Windows Server 2008 R2 includes IIS PowerShell snapin, which is also available on Server Core.</li>
</ol>
<p>This post describes how to setup and configure IIS on Server Core in Windows Server 2008 R2. Specifically the following tasks are described:</p>
<ul>
<li>Using oclist and ocsetup commands</li>
<li>Basic Installation of IIS</li>
<li>Installing ASP.NET</li>
<li>Installing PowerShell and IIS snap-in</li>
<li>Enabling IIS Remote Management</li>
</ul>
<p><span id="more-260"></span></p>
<h3>Using oclist and ocsetup commands</h3>
<p><strong>oclist</strong> command can be used to list the available and installed roles and services on the server. The output of the command looks similar to below:</p>
<p><a href="http://ruslany.net/wp-content/uploads/2009/02/oclist.png"><img class="alignnone size-medium wp-image-261" style="border: 0px;" title="oclist" src="http://ruslany.net/wp-content/uploads/2009/02/oclist-500x245.png" alt="oclist command output" width="500" height="245" /></a></p>
<p>It is important to understand how <strong>oclist</strong> renders component dependencies. For example, in the above screenshot the oclist output shows that IIS-FTPExtensibility is dependent on IIS-FTPSvc, so in order to install IIS-FTPExtensibility it is first necessary to install IIS-FTPSvc.</p>
<p><strong>ocsetup</strong> command can be used to install and uninstall individual roles and services.</p>
<h3>Basic Installation of IIS</h3>
<p>To perform basic and default installation of IIS on Server Core run the following command:</p>
<pre name="code" class="dos">
start /w ocsetup IIS-WebServerRole
</pre>
<p>After the command has run you can run <strong>oclist | more</strong> and check which IIS components have been installed.</p>
<h3>Installing .NET Framework</h3>
<p>If you plan to use ASP.NET or IIS Remote Management then it is necessary to install .NET Framework first. To install it use the following commands:</p>
<pre name="code" class="dos">
start /w ocsetup NetFx2-ServerCore
start /w ocsetup NetFx2-ServerCore-WOW64
</pre>
<h3>Installing ASP.NET</h3>
<p>To install ASP.NET on Server Core run the following commands in exact same order as listed below:</p>
<pre name="code" class="dos">
start /w ocsetup WAS-NetFxEnvironment
start /w ocsetup IIS-ISAPIExtensions
start /w ocsetup IIS-ISAPIFilter
start /w ocsetup IIS-NetFxExtensibility
start /w ocsetup IIS-ASPNET
</pre>
<h3>Installing PowerShell and IIS snap-in</h3>
<p>First, install the PowerShell by running the command as below:</p>
<pre name="code" class="dos">
start /w ocsetup MicrosoftWindowsPowerShell
</pre>
<p>Next, launch the PowerShell by running this command:</p>
<pre name="code" class="dos">
\windows\system32\WindowsPowerShell\v1.0\powershell.exe
</pre>
<p>After running this command you should see a PowerShell prompt.</p>
<p>In order to enable the IIS snapin it is necessary to change the script execution policy by running this command:</p>
<pre name="code" class="dos">
Set-ExecutionPolicy RemoteSigned
</pre>
<p><strong>Restart PowerShell</strong> for the policy changes to take effect. After re-entering the PowerShell import the IIS snapin:</p>
<pre name="code" class="dos">
import-module WebAdministration
</pre>
<p>After that you can get the list of available IIS cmdlets by typing</p>
<pre name="code" class="dos">
get-command –module WebAdministration
</pre>
<p>Refer to the article <a title="Managing IIS with IIS 7.0 PowerShell Snap-in" href="http://learn.iis.net/page.aspx/447/managing-iis-with-the-iis-70-powershell-snap-in/">Managing IIS with IIS 7.0 PowerShell Snap-in</a> for more information.</p>
<h3>Enabling IIS Remote Management</h3>
<p>In order to install IIS remote management service it is necessary to install .NET Framework first. Refer to the <strong>Installing .NET Framework</strong> section above for more details.</p>
<p>Install the IIS management service by executing this command:</p>
<pre name="code" class="dos">
start /w ocsetup IIS-ManagementService
</pre>
<p>Then enable remote management by running this command:</p>
<pre name="code" class="dos">
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WebManagement\Server ^
/v EnableRemoteManagement /t REG_DWORD /d 1
</pre>
<p>And finally start the management service:</p>
<pre name="code" class="dos">
net start wmsvc
</pre>
<p>Now you can connect to the IIS on the Server Core from a remote machine by using <a title="IIS Remote Manager" href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;g=6&amp;i=1626" target="_blank">IIS Remote Manager</a>.</p>
<p><em><strong>Acknowledgement</strong>: thanks to Saad Ladki and <a title="Thomas Deml blog" href="http://blogs.iis.net/thomad/">Thomas Deml </a>from IIS team for explaining to me all these steps.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://ruslany.net/2009/02/setup-iis-on-server-core-windows-server-2008-r2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Dynamic IP Restrictions for IIS 7.0 &#8211; Beta</title>
		<link>http://ruslany.net/2009/02/dynamic-ip-restrictions-for-iis-70-beta/</link>
		<comments>http://ruslany.net/2009/02/dynamic-ip-restrictions-for-iis-70-beta/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 02:34:00 +0000</pubDate>
		<dc:creator>ruslany</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[IIS News Item]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://ruslany.net/?p=245</guid>
		<description><![CDATA[Today IIS team has released the Dynamic IP Restrictions Extension for IIS 7.0 &#8211; Beta. The Dynamic IP Restrictions Extension provides IT Professionals and Hosters a configurable module that helps mitigate or block Denial of Service Attacks or cracking of passwords through Brute-force by temporarily blocking Internet Protocol (IP) addresses of HTTP clients who follow [...]]]></description>
			<content:encoded><![CDATA[<p>Today IIS team has released the Dynamic IP Restrictions Extension for IIS 7.0 &#8211; Beta. The Dynamic IP Restrictions Extension provides IT Professionals and Hosters a configurable module that helps mitigate or block Denial of Service Attacks or cracking of passwords through Brute-force by temporarily blocking Internet Protocol (IP) addresses of HTTP clients who follow a pattern that could be conducive to one of such attacks. This module can be configured such that the analysis and blocking could be done at the Web Server or the Web Site level.</p>
<h3>Install the Dynamic IP Restrictions Beta Today!</h3>
<p><a href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;g=6&amp;i=1825">Microsoft Dynamic IP Restrictions for IIS 7.0 &#8211; Beta (x86)</a></p>
<p><a href="http://www.iis.net/downloads/default.aspx?tabid=34&amp;g=6&amp;i=1826">Microsoft Dynamic IP Restrictions for IIS 7.0 &#8211; Beta (x64)</a></p>
<p>If IIS already has IPv4 Address and IP restrictions module enabled then Dynamic IP Restrictions installer will need to un-install the existing module in order to continue the setup process. Note that the existing IPv4 configuration will be preserved while old module is removed and new module is installed.<span id="more-245"></span></p>
<h3>Features</h3>
<p>The Dynamic IP Restrictions includes these key features:</p>
<ul>
<li><strong>Blocking of IP addresses based on number of concurrent requests</strong> &#8211; If HTTP client makes many concurrent requests then that client&#8217;s IP address gets temporarily blocked.</li>
<li><strong>Blocking of IP addresses based on number of requests over a period of time</strong> &#8211; If HTTP client makes many requests over short period of time then that client&#8217;s IP address gets temporarily blocked.</li>
<li><strong>Various deny actions</strong> &#8211; it is possible to specify what response to return to an HTTP client whose IP address is blocked. The module can return status codes 403 and 404 or just drop the HTTP connection and do not return any response.</li>
<li><strong>Logging of dynamically denied requests</strong> &#8211; all denied requests can be logged into a W3C formatted log file.</li>
<li><strong>Displaying currently blocked IP addresses</strong> &#8211; a list of currently blocked IP addresses can be obtained by using IIS Manager or by using IIS RSCA API&#8217;s.</li>
<li><strong>IPv6</strong> &#8211; the module fully supports IPv6 addresses.</li>
</ul>
<p>In additions to these features, the Dynamic IP Restrictions for IIS 7.0 provides the same functionality that exists in IIS 7.0 built-in IPv4 and Domain Restrictions. Because of that the Dynamic IP Restrictions is provided as a replacement for IPv4 and Domain Restrictions.</p>
<h3>More information</h3>
<p>Module walkthrough: <a href="http://learn.iis.net/page.aspx/548/using-dynamic-ip-restrictions/">http://learn.iis.net/page.aspx/548/using-dynamic-ip-restrictions/</a></p>
<p>Support forum: <a href="http://forums.iis.net/1043.aspx">http://forums.iis.net/1043.aspx</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ruslany.net/2009/02/dynamic-ip-restrictions-for-iis-70-beta/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ASP.NET postbacks and URL rewriting</title>
		<link>http://ruslany.net/2008/10/aspnet-postbacks-and-url-rewriting/</link>
		<comments>http://ruslany.net/2008/10/aspnet-postbacks-and-url-rewriting/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 05:04:11 +0000</pubDate>
		<dc:creator>ruslany</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[ASPNET]]></category>

		<guid isPermaLink="false">http://ruslany.net/2008/10/aspnet-postbacks-and-url-rewriting/</guid>
		<description><![CDATA[ASP.NET Web Forms extensively use postback mechanism in order to maintain the state of the server-side controls on the web page. This makes it somewhat tricky to perform URL rewriting for ASP.NET pages. When a server side form control is added to the web page, ASP.NET will render the response with HTML &#60;form&#62; tag that [...]]]></description>
			<content:encoded><![CDATA[<p>ASP.NET Web Forms extensively use postback mechanism in order to maintain the state of the server-side controls on the web page. This makes it somewhat tricky to perform URL rewriting for ASP.NET pages. When a server side form control is added to the web page, ASP.NET will render the response with HTML &lt;form&gt; tag that contains an action attribute pointing back to the page where the form control is. This means that if URL rewriting was used for that page, the action attribute will point back to the rewritten URL, not to the URL that was requested from the browser. This will cause the browser to show rewritten URL any time a postback occurs.</p>
<p><span id="more-105"></span>Let me demonstrate this on an example. Assume you have a very simple web form in a file called <strong>default.aspx. </strong>When you request <strong>http://localhost/default.aspx</strong> in a browser and then view the HTML source for the response, you will see that the response contains the &lt;form&gt; element, which looks similar to this:</p>
<pre name="code" class="html">
&lt;form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;Default.aspx&quot; id=&quot;form1&quot;&gt;
</pre>
<p>The <strong>action</strong> attribute contains the URL where the form data will be posted to when you click on the button in the web page.</p>
<p>Now, let&#8217;s create a very simple rewrite rule that rewrites URL from <strong>http://localhost/homepage</strong> to <strong>http://localhost/default.aspx</strong>.</p>
<pre name="code" class="xml">
&lt;rewrite&gt;
  &lt;rules&gt;
    &lt;rule name=&quot;MyRule&quot; patternSyntax=&quot;Wildcard&quot;&gt;
      &lt;match url=&quot;homepage&quot; /&gt;
      &lt;action type=&quot;Rewrite&quot; url=&quot;default.aspx&quot; /&gt;
    &lt;/rule&gt;
  &lt;/rules&gt;
&lt;/rewrite&gt;
</pre>
<p>When you request <strong>http://localhost/homepage</strong> in a browser, the URL will be rewritten in accordance to the above rule and the page will be shown correctly in the browser:</p>
<p><a href="http://ruslany.net/wp-content/uploads/2008/10/postback1.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" src="http://ruslany.net/wp-content/uploads/2008/10/postback1-thumb.png" border="0" alt="Postback1" width="504" height="276" /></a></p>
<p>However, when you click on the <strong>Submit</strong> button, the browser&#8217;s address bar will display <strong>http://localhost/default.aspx</strong>, thus exposing the internal URL, that you wanted to hide by using URL rewriting:</p>
<p><a href="http://ruslany.net/wp-content/uploads/2008/10/postback2.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" src="http://ruslany.net/wp-content/uploads/2008/10/postback2-thumb.png" border="0" alt="Postback2" width="504" height="266" /></a></p>
<p>A few workarounds to fix this behavior existed in previous versions of ASP.NET. For example, you could sub-class the form control, or use Control Adapter as explained <a title="ScottGu blog" href="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx" target="_blank">here</a>.  However, these workarounds were not very easy to implement. Luckily, the ASP.NET in .NET Framework 3.5 SP1 provides a very simple way to fix that. Now you can use the property of the <strong>HtmlForm</strong> class called <strong>Action</strong> to set the postback URL to the one that was requested by browser before any rewriting happened. In ASP.NET you can obtain that URL by using <strong>HttpRequest.RawUrl</strong> property. So, to fix the postback URL for your web form when you use URL Rewrite Module, you would need to add the following code to the page:</p>
<pre name="code" class="csharp">
protected void Page_Load(object sender, EventArgs e)
{
    form1.Action = Request.RawUrl;
}
</pre>
<p>After this change, if you reload the web page at <strong>http://localhost/homepage</strong> and then click on submit button you will see that the browser&#8217;s address bar still displays the correct URL:</p>
<p><a href="http://ruslany.net/wp-content/uploads/2008/10/postback3.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" src="http://ruslany.net/wp-content/uploads/2008/10/postback3-thumb.png" border="0" alt="Postback3" width="504" height="266" /></a></p>
<p>If you view the HTML for the response you will see that the &lt;form&gt; tag now contains the correct action URL:</p>
<pre name="code" class="html">
&lt;form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;/homepage&quot; id=&quot;form1&quot;&gt;
</pre>
<p>When you use ASP.NET master pages you could add the Page_Load method to the master page and that would take care of postback action URL for all the pages in your web application. Note thought that in order to be able to use the HtmlForm.Action property you have to upgrade to .NET Framework 3.5 SP1.</p>
]]></content:encoded>
			<wfw:commentRss>http://ruslany.net/2008/10/aspnet-postbacks-and-url-rewriting/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Wildcard script mapping and IIS 7 integrated pipeline</title>
		<link>http://ruslany.net/2008/09/wildcard-script-mapping-and-iis-7-integrated-pipeline/</link>
		<comments>http://ruslany.net/2008/09/wildcard-script-mapping-and-iis-7-integrated-pipeline/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 03:30:18 +0000</pubDate>
		<dc:creator>ruslany</dc:creator>
				<category><![CDATA[Other]]></category>
		<category><![CDATA[ASPNET]]></category>

		<guid isPermaLink="false">http://ruslany.net/2008/09/wildcard-script-mapping-and-iis-7-integrated-pipeline/</guid>
		<description><![CDATA[The big benefit of IIS 7 integrated request processing pipeline is the fact that all the nice and useful ASP.NET features can be used for any type of content on your web site; not just for ASP.NET-specific content. For example, ASP.NET SQL-based membership can be used to protect static files and folders. Also, ASP.NET extensibility [...]]]></description>
			<content:encoded><![CDATA[<p>The big benefit of IIS 7 integrated request processing pipeline is the fact that all the nice and useful ASP.NET features can be used for any type of content on your web site; not just for ASP.NET-specific content. For example, ASP.NET SQL-based membership can be used to protect static files and folders. Also, ASP.NET extensibility API&#8217;s, such as <strong>IHttpHandler</strong> and <strong>IHttpModule</strong> can be used to add custom modules and handlers that would be executed even for non-ASP.NET content.</p>
<p>IIS 6 did not have this level of integration. ASP.NET was plugged into IIS 6 as an ISAPI extension and by default was configured to handle ONLY requests mapped to that extension &#8211; for example any request that ended with &#8220;.aspx&#8221; would be be processed by ASP.NET extension. This obviously was a big limitation for customers who wanted to be able to use ASP.NET features for all other contend on web site. The most common way to workaround that was to use &#8220;Wildcard script mapping&#8221;. This post explains how an application that used wildcard script mapping in IIS 6 can be migrated over to IIS 7.</p>
<p><span id="more-95"></span> Assume you had configured ASP.NET in IIS 6 to handle all requests by using wildcard script mapping. For example you had an ASP.NET module for URL rewriting and you wanted this module to handle extension-less URLs.</p>
<p>This wildcard script map configuration is typically done within IIS 6 manager by opening the properties dialog for either web server or web site and selecting <strong>Home Directory</strong> tab, then clicking on <strong>Configuration</strong> button and then clicking on the <strong>Insert</strong> button for &#8220;Wildcard application maps&#8221;:</p>
<p><a href="http://ruslany.net/wp-content/uploads/2008/09/wildcardiis6.png"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" src="http://ruslany.net/wp-content/uploads/2008/09/wildcardiis6-thumb.png" border="0" alt="WildcardIIS6" width="390" height="379" /></a></p>
<p>Now, as you move your application to IIS 7, you want to configure it to achieve the same behavior of ASP.NET. There are two options on how this can be done: using <strong>Classic</strong> pipeline mode or using <strong>Integrated</strong> pipeline mode.</p>
<h3>Wildcard script mapping in IIS 7 classic pipeline mode</h3>
<p>With classic pipeline mode the ASP.NET is plugged into the IIS request processing pipeline as an ISAPI extension &#8211; exactly the same way as it was in IIS 6. In fact, if you open %WINDIR%\system32\inetsrv\config\applicationHost.config file and locate the &lt;handlers&gt; section inside of it you can see how IIS is configured to map ASP.NET specific requests to the <strong>aspnet_isapi.dll</strong>:</p>
<pre name="code" class="xml">
&lt;handlers accessPolicy=&quot;Read, Script&quot;&gt;
  ...
  &lt;add name=&quot;PageHandlerFactory-ISAPI-2.0&quot;
       path=&quot;*.aspx&quot; verb=&quot;GET,HEAD,POST,DEBUG&quot;
       modules=&quot;IsapiModule&quot;
       scriptProcessor=&quot;%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll&quot;
       preCondition=&quot;classicMode,runtimeVersionv2.0,bitness32&quot; responseBufferLimit=&quot;0&quot; /&gt;
  ...
&lt;/handlers&gt;
</pre>
<p>Notice the <strong>preCondition</strong> attribute for the handler mapping. Among other things this attribute is set to <strong>classicMode</strong>, which ensures that this handler mapping only takes effect when the application pool is configured to run in classic mode.</p>
<p>Now if you want to configure wildcard mapping for the ASP.NET running in classic mode, you can add one more handler mapping to the &lt;handlers&gt; section just before the handler mapping for static files:</p>
<pre name="code" class="xml">
&lt;handlers accessPolicy=&quot;Read, Script&quot;&gt;
  ...
  &lt;add name=&quot;ASP.NET-ISAPI-2.0-Wildcard&quot;
     path=&quot;*&quot; verb=&quot;GET,HEAD,POST,DEBUG&quot;
     modules=&quot;IsapiModule&quot;
     scriptProcessor=&quot;%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll&quot;
     preCondition=&quot;classicMode,runtimeVersionv2.0,bitness32&quot; responseBufferLimit=&quot;0&quot; /&gt;
  &lt;add name=&quot;StaticFile&quot;
     path=&quot;*&quot; verb=&quot;*&quot;
     modules=&quot;StaticFileModule,DefaultDocumentModule,DirectoryListingModule&quot;
     resourceType=&quot;Either&quot; requireAccess=&quot;Read&quot; /&gt;
&lt;/handlers&gt;
</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>The relative order of the wildcard handler mapping is important: if you define this handler mapping after the &#8220;StaticFile&#8221; handler mapping then &#8220;StaticFile&#8221; will handle all the requests and no requests will ever come to ASP.NET wildcard handler.</p>
<p>As you may already know the ASP.NET wildcard handler mapping in IIS 7 is subject to the same performance limitations as existed in IIS 6. The problem with this kind of handler mapping is that ALL requests are processed by it, including requests for static files. The ASP.NET static file handler is not as powerful as native IIS static file handler. Plus static files served by ASP.NET will not be cached by IIS in kernel mode. Because of these performance limitations it is recommended that you use IIS 7 integrated pipeline to achieve the same functionality as with wildcard mappings in IIS 6.</p>
<h3>IIS 7 integrated pipeline instead of wildcard script mapping</h3>
<p>With integrated pipeline, the ASP.NET functionality is fully integrated into the main request processing in IIS, which means that all ASP.NET features are now available for any type of requests. This effectively eliminates the need for the wildcard handler mapping. Now you can use your existing ASP.NET modules and have them applied to all requests.</p>
<p>For example let&#8217;s say you had a URL rewriting module written in ASP.NET. On IIS 6 this module was registered inside of the &lt;system.web&gt; section in web.config file as below:</p>
<pre name="code" class="xml">
&lt;system.Web&gt;
  &lt;httpModules&gt;
    ...
    &lt;add name=&quot;MyUrlRewrite&quot;
         type=&quot;SomeNamespace.MyModules.UrlRewrite, SomeNamespace.MyModules&quot; /&gt;
    ...
  &lt;/httpModules&gt;
&lt;/system.Web&gt;
</pre>
<p><a href="http://11011.net/software/vspaste"></a><a href="http://11011.net/software/vspaste"></a></p>
<p><a href="http://11011.net/software/vspaste"></a>Since on IIS 6 this module was only executed for requests to managed content, it only worked for URLs that had .aspx extension, such <em>as http://example.com/archive/2008/08/26/post-title.<strong>aspx</strong></em>. If you wanted it to handle extension-less URLs you had to configure wildcard script mapping for ASP.NET. With IIS 7 integrated pipeline you do not have to do that anymore. In order to make this module apply to extension-less URLs you need to register it within the &lt;system.webServer&gt; section inside of web.config file as below:</p>
<pre name="code" class="xml">
&lt;system.webServer&gt;
  &lt;modules &gt;
    ...
    &lt;add name=&quot;MyUrlRewrite&quot;
         type=&quot;SomeNamespace.MyModules.UrlRewrite, SomeNamespace.MyModules&quot;
         preCondition=&quot;&quot; /&gt;
    ...
  &lt;/modules&gt;
&lt;system.webServer&gt;
</pre>
<p>Make sure that you leave the preCondition attribute empty here as it would enforce that the module will be executed for all requests, not just for requests for ASP.NET specific content.</p>
<p>Registering your managed modules this way does not have such dramatic performance impact as when using wildcard script mappings. Even though the module is invoked for all requests to web application, all the existing handler mappings are still in effect, which means that the static files are still served by the native IIS static file handler. Another benefit of registering your module this way is that now it can be applied to requests for PHP, ASP or any other dynamic pages. You would not be able to do that if you used wildcard script mappings.</p>
<p>One last thing to mention here is that you can also use the attribute on the &lt;modules&gt; section called <strong>runAllManagedModulesForAllRequests</strong>.</p>
<pre name="code" class="xml">
&lt;system.webServer&gt;
  &lt;modules runAllManagedModulesForAllRequests=&quot;True&quot; &gt;
    ...
    &lt;add name=&quot;MyUrlRewrite&quot;
         type=&quot;SomeNamespace.MyModules.UrlRewrite, SomeNamespace.MyModules&quot;
         preCondition=&quot;ManagedHandler&quot; /&gt;
    ...
  &lt;/modules&gt;
&lt;system.webServer&gt;
</pre>
<p>This attributes forces IIS to ignore the preCondition=&#8221;managedHandler&#8221; attribute, hence all managed modules will be invoked for all requests to web application.</p>
]]></content:encoded>
			<wfw:commentRss>http://ruslany.net/2008/09/wildcard-script-mapping-and-iis-7-integrated-pipeline/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Introduction</title>
		<link>http://ruslany.net/2008/07/introduction/</link>
		<comments>http://ruslany.net/2008/07/introduction/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 05:29:11 +0000</pubDate>
		<dc:creator>ruslany</dc:creator>
				<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://ruslany.net/?p=16</guid>
		<description><![CDATA[My name is Ruslan Yakushev. I am a program manager on IIS team, working on some of the very interesting projects that are being developed in the team right now. I have joined the team about a year ago, and was thinking about starting a blog for a while now. The primary work responsibilities kept [...]]]></description>
			<content:encoded><![CDATA[<p>My name is Ruslan Yakushev. I am a program manager on IIS team, working on some of the very interesting projects that are being developed in the team right now. I have joined the team about a year ago, and was thinking about starting a blog for a while now. The primary work responsibilities kept me busy, so I have been postponing blog idea for a while. Every time I needed to make an announcement or an update on IIS community site, I asked some of my colleagues  on the team to blog my content. Finally, I figured that I should probably start my own blog, so I could have all the freedom of publishing my own content any time I want.</p>
<p>Being a technical program manager on the team, I like to use (in other words &#8211; &#8220;dogfood&#8221;) the products that team develops. Hence I decided to self-host my own blog by using latest version of IIS. Also, I have been working with <a href="http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis7/" target="_blank">FastCGI</a> and <a href="http://www.iis.net/php" target="_blank">PHP</a> for a while now, and became quite familiar with many popular <a href="http://learn.iis.net/page.aspx/271/php-applications-on-iis/" target="_blank">PHP applications</a>. As a result I chose to run my blog by using latest version of <a href="http://wordpress.org/" target="_blank">WordPress</a>, which is a very nice and easy to use blog engine application. Finally, I am using my favorite feature of IIS 7.0 &#8211; <a href="http://learn.iis.net/page.aspx/460/using-url-rewrite-module/" target="_blank">URL rewriter</a> &#8211; to enable &#8220;<a href="http://learn.iis.net/page.aspx/466/enabling-pretty-permalinks-in-wordpress/" target="_blank">pretty permalinks</a>&#8221; on my blog.</p>
<p>I plan to use this blog to publish information related to FastCGI, PHP, URL rewriter and IIS in general. I hope you&#8217;ll find this content useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://ruslany.net/2008/07/introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
