Hi DWs
Is it possible to set Content-Disposition for some files?
.hex, .bin
its making some problems for a client that the browser sets the files as zip files.
//Bille
Hi DWs
Is it possible to set Content-Disposition for some files?
.hex, .bin
its making some problems for a client that the browser sets the files as zip files.
//Bille
You can from web.config:
http://serverfault.com/questions/320450/conditionally-set-content-disposition-header
But you cannot be sure it always works. IE i.e. will serve .png as image no matter what you send out.
Nicolai
cool thanks!
thats ok, I think that's the best we can do :-)
//Peter Bille
Nic, where should I put the rewrite section without messing up dynamicweb?
Just below </system.serviceModel> before </configuration> ends?
Just put it in the node structure below. You probably have system.webserver node already, add the rewrite node and add your outboundrules node inside the rewrite node.
<configuration>
<system.webServer>
<rewrite>
Hi Nicolai.
I have put this together to the rewrite. Do you notice any problems?
<rewrite>
<outboundRules>
<rule name="download hex filer" preCondition="ErHex">
<match serverVariable="RESPONSE_Content-Disposition" pattern=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" pattern="(.*)\\([^/]+)\.hex$" />
</conditions>
<action type="Rewrite" value="attachment; filename={C:2}.hex" />
</rule>
<preConditions>
<preCondition name="ErHex">
<add input="{REQUEST_FILENAME}" pattern="\.hex$" />
</preCondition>
</preConditions>
</outboundRules>
<outboundRules>
<rule name="download bin filer" preCondition="ErBin">
<match serverVariable="RESPONSE_Content-Disposition" pattern=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" pattern="(.*)\\([^/]+)\.bin$" />
</conditions>
<action type="Rewrite" value="attachment; filename={C:2}.bin" />
</rule>
<preConditions>
<preCondition name="ErBin">
<add input="{REQUEST_FILENAME}" pattern="\.bin$" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
It seems ok. But notice I have not tried this at home!
Also make sure you merge these configurations into one Ouboundrules node.
BR Nicolai
ok like this.
<rewrite>
<outboundRules>
<rule name="download hex filer" preCondition="ErHex">
<match serverVariable="RESPONSE_Content-Disposition" pattern=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" pattern="(.*)\\([^/]+)\.hex$" />
</conditions>
<action type="Rewrite" value="attachment; filename={C:2}.hex" />
</rule>
<preConditions>
<preCondition name="ErHex">
<add input="{REQUEST_FILENAME}" pattern="\.hex$" />
</preCondition>
</preConditions>
<rule name="download bin filer" preCondition="ErBin">
<match serverVariable="RESPONSE_Content-Disposition" pattern=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" pattern="(.*)\\([^/]+)\.bin$" />
</conditions>
<action type="Rewrite" value="attachment; filename={C:2}.bin" />
</rule>
<preConditions>
<preCondition name="ErBin">
<add input="{REQUEST_FILENAME}" pattern="\.bin$" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
Yes.
Your website will tell you if it is wrong :-)
cool thanks :-)
You must be logged in to post in the forum