title: ASP.NET Postback error under Reverse Proxy with IIS 8.5, URL Rewrite 2.0 and ARR 3.0
body: <p>I would like to setup a reverse proxy in IIS but in my configuration I get problems with ASP.NET postbacks. When you click on any submit button of the proxied website then you get a 404 error. The URL in browser address bar is changed to the rewritten URL.</p>
  
  <p>For example, the website that I need to proxy is <a href="http://website.com/host" rel="noreferrer">http://website.com/host</a>. Here <a href="http://website.com" rel="noreferrer">http://website.com</a> and <a href="http://website.com/host" rel="noreferrer">http://website.com/host</a> are separate web applications. Host is running as a virtual folder under website.com. </p>
  
  <p>I want to access the Host from this URL: <a href="http://me.local/myhost" rel="noreferrer">http://me.local/myhost</a>. In IIS me.local is an asp.net web application and Myhost is added as another application as child of me.local. Everything works just fine as long as you don't click on submit button anywhere on the proxied website. Once you do this then you get to page <a href="http://me.local/host" rel="noreferrer">http://me.local/host</a> which results in 404 error. When you look at page's html source then form's action url is set correctly to /myhost</p>
  
  <p>Why does the error happen? Is it possible to fix it in IIS, or do we need to make changes to the host application?</p>
  
  <p>My server is running IIS 8.5. The host server is an old one with IIS 6, and web application can be asp.net 1.1 or asp.net 2.0.</p>
  
  <p>The section with rewrite rules from web.config of "myhost" application is:</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;system.webServer&gt;
          &lt;rewrite&gt;
              &lt;rules&gt; 
                  &lt;rule name="Route the requests for host" stopProcessing="true"&gt; 
                      &lt;match url="^(.*)" /&gt; 
                      &lt;conditions&gt; 
                          &lt;add input="{CACHE_URL}" pattern="^(https?)://" /&gt; 
                      &lt;/conditions&gt; 
                      &lt;action type="Rewrite" url="{C:1}://website.com/host/{R:1}" /&gt; 
                      &lt;serverVariables&gt; 
                          &lt;set name="HTTP_ACCEPT_ENCODING" value="" /&gt; 
                      &lt;/serverVariables&gt; 
                  &lt;/rule&gt;
                  &lt;rule name="hostToDefault" stopProcessing="true"&gt;
                      &lt;match url="^" /&gt;
                      &lt;conditions&gt;
                          &lt;add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /&gt;
                      &lt;/conditions&gt;
                      &lt;action type="Redirect" url="default.aspx" appendQueryString="false" /&gt;
                  &lt;/rule&gt;
                  &lt;rule name="RedirectUserFriendlyURL1" stopProcessing="true"&gt;
                      &lt;match url="^(.*)default\.aspx$" /&gt;
                      &lt;conditions&gt;
                          &lt;add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" /&gt;
                      &lt;/conditions&gt;
                      &lt;action type="Redirect" url="(.*)" appendQueryString="false" /&gt;
                  &lt;/rule&gt;
              &lt;/rules&gt; 
              &lt;outboundRules&gt; 
                  &lt;rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1"&gt; 
                      &lt;match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://website.com/(.*)" /&gt; 
                      &lt;action type="Rewrite" value="/{R:2}" /&gt; 
                  &lt;/rule&gt; 
                  &lt;rule name="NonhostRewriteRelativePaths" preCondition="ResponseIsHtml1"&gt; 
                      &lt;match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(?!host)(.*)" negate="false" /&gt; 
                      &lt;action type="Rewrite" value="http://website.com/{R:1}" /&gt; 
                  &lt;/rule&gt; 
                  &lt;rule name="hostRelativePaths" preCondition="ResponseIsHtml1"&gt; 
                      &lt;match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/host/(.*)" negate="false" /&gt; 
                      &lt;action type="Rewrite" value="/myhost/{R:1}" /&gt; 
                  &lt;/rule&gt;
                  &lt;rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1"&gt;
                      &lt;match filterByTags="A, Form, Img" pattern="^(.*)myhost/default\.aspx$" /&gt;
                      &lt;action type="Rewrite" value="{R:1}/myhost/default" /&gt;
                  &lt;/rule&gt;                 
                  &lt;preConditions&gt; 
                      &lt;preCondition name="ResponseIsHtml1"&gt; 
                          &lt;add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /&gt; 
                      &lt;/preCondition&gt; 
                  &lt;/preConditions&gt; 
              &lt;/outboundRules&gt;
          &lt;/rewrite&gt;
          &lt;urlCompression doStaticCompression="false" doDynamicCompression="false" /&gt;
      &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>