Forum Moderators: open

Message Too Old, No Replies

.Net Webreponse issue

how to trap http put headers?

         

RossWal

8:52 pm on Dec 4, 2003 (gmt 0)

10+ Year Member



I wrote a .net application that acts an an interface between site users and a repository of MS Word docs. I use the WebRequest object to read the doc, and the WebResponse to send it down to the client.

Suddenly, some clients are getting a dialog box prompting them to download the content. They don't have the option to read it directly. I believe the problem was introduced by MS Security patches applied to the browsers. So far, it seems that IE 6 clients are OK, but not IE 5.x, but that's far from certain. The 5.x clients can read regular word docs, just not the ones I'm serving through my .net page.

I suspect the problem has to do with HTTP put headers, but I can't figure out how to view them. This is behind a firewall, and so I can't use the available utilities.

Will IIS 6 log put headers? Other thoughts? I need to get this fixed ASAP, so I appreciate your comments.

Thanks,
Toss

RossWal

12:09 am on Dec 5, 2003 (gmt 0)

10+ Year Member



I've been able to view the response headers (mistakenly called 'put' in prior post). There is a very suspicious one 'Tranfer-Encoding: chunked'. I've found references to that property for the WebRequest but not the WebResponse. I think it's being copied over from the web request to the response. Clearing the response headers does not get rid of it, nor is there an explicit property for it on the WebResponse object.

Here are headers from the one that won't display:
Server: Microsoft-IIS/5.0
Date: Fri, 05 Dec 2003 00:53:02 GMT
Accept-Ranges: bytes
Transfer-Encoding: chunked
Cache-Control: private
Content-Type: application/msword; charset=utf-8

and here are headers from the one that will:
Server: Microsoft-IIS/5.0
Date: Fri, 05 Dec 2003 01:01:34 GMT
Content-Type: application/msword
Accept-Ranges: bytes
Last-Modified: Fri, 03 Oct 2003 21:33:48 GMT
ETag: "c023e87f689c31:8f7"
Content-Length: 225280

Thoughts, oh brilliant ones?

Any comentary on what the Etag is or Transfer-Encoding?

Thanks again,
Ross

edicius

4:10 pm on Dec 8, 2003 (gmt 0)

10+ Year Member



RossWall:

The ContentType property of a Response object automatically appends a character set attribute to the Content-Type string.

Example:


Content-Type: application/msword; charset=utf-8

Internet Explorer takes this Content-Type and searches the registry for the reference to the document; but can't find a match because of the extra charset attribute.

Classic ASP didn't add this character set attribute by default - but ASP.NET is "nice" enough to automatically add it for you (even though it breaks things in this case).

The solution is to set the Response.Charset property to "".

Example:


Response.ContentType = "application/msword"
Response.Charset = ""

You can read all the nitty-gritty details in the following KB article:

[support.microsoft.com...]

RossWal

7:07 pm on Dec 8, 2003 (gmt 0)

10+ Year Member



edicius,
You are "Da (Wo?)Man"!

I searched the KB last week, but apparently didn't choose the right keywords.

Thanks!

edicius

7:49 pm on Dec 9, 2003 (gmt 0)

10+ Year Member



I'd actually bookmarked that one awhile back... ran into the same thing when trying to write a PDF directly to the Response Stream.

Glad it worked out for you! :)