IIS7: content length inconsistency due to use of Rewrite and OutboundRules URLs

I'm having trouble setting up outbound rules to work with IIS7, here is a script that gives me sadness. My ultimate goal is to get any outgoing modules that work in multiple browsers. In this example, I use a rule that strips.aspx from various HTML tags.

Scenario 1 (content length mismatch):

To get this specific rule for working in IIS7, I had to turn off dynamic compression and turn off caching by default. I was able to rewrite the HTML, but there was another problem that made it unusable.

When I try to rewrite content using outboundrules, I have a problem when Chrome and Firefox do a continuous download due to "content length mismatch" in the headers (thanks to Fiddler for helping me identify it). Rewriting works, but it leads to the content length being incorrect, and therefore these two browsers look like they load forever. Chrome, in particular, is causing the problem because javascript seems to hang up, and therefore nothing jquery works until someone physically clicks the stop button.

These are the relevant sections of web.config that I started by giving me this script:

<system.webServer> <rewrite> <urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" /> <modules runAllManagedModulesForAllRequests="true" /> <outboundRules> <rule name="Remove .aspx from links in the response" preCondition="IsHTML" stopProcessing="false"> <match filterByTags="A, Area, Base, Form, Frame, IFrame, Link, Img, Script" pattern="(.*)\.aspx(\?.*)?$" /> <action type="Rewrite" value="{R:1}{R:2}" /> </rule> <preConditions> <preCondition name="IsHTML"> <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> </preCondition> </preConditions> </outboundRules> </rewrite> <caching enabled="false" enableKernelCache="false" /> </system.webServer> 

While researching this problem, I found this question with stackedoverflow , which mentioned the rewriteBeforeCache = "true" attribute in the outboundRules tag, as well as this blog post that states the same thing that I ran into content length issues.

If I change this attribute, it will lead me to the fact that the rules of outgoing messages will not work further.

Scenario 2 (Outbound rules do not work):

So, due to the previous information, I started setting up web.config and was able to resolve the content length mismatch using the rewriteBeforeCache attribute in the outboundRules tag. To make this attribute work, I was able to turn on caching again. This fixed a mismatch in the response length from Scenario 1, but now none of the outboundRules \ rule elements work. I tried a few simple rules, and they work fine when I remove the rewriteBeforeCache attribute, but this calls scenario 1:

 <system.webServer> <rewrite> <urlCompression doStaticCompression="false" doDynamicCompression="true" dynamicCompressionBeforeCache="false" /> <modules runAllManagedModulesForAllRequests="true" /> <outboundRules rewriteBeforeCache="true"> <rule name="Remove .aspx from links in the response" preCondition="IsHTML" stopProcessing="false"> <match filterByTags="A, Area, Base, Form, Frame, IFrame, Link, Img, Script" pattern="(.*)\.aspx(\?.*)?$" /> <action type="Rewrite" value="{R:1}{R:2}" /> </rule> <preConditions> <preCondition name="IsHTML"> <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> </preCondition> </preConditions> </outboundRules> </rewrite> </system.webServer> 

Scenario 1 causes one error with browsers in IIS7; Scenario 2 leads to a shutdown of the outgoing sources.

I changed any number of options with disabling caching, transfers in chunk mode and try every combination that I can think of to try.

Additional notes for AppPool: IIS7, .NET4.0, classic pipeline

Does anyone else have any ideas on what other options I should decide other than switching to an IIS7.5 server?

+4
source share

Source: https://habr.com/ru/post/1486126/


All Articles