I open a work item and go into the Attachments tab. I double click on a .doc attachment. Instead of opening the file in Word, it instead kicks off the browser, which in turn brings down the file.
Is there a way to get TFS to run the attachment directly in Word?
Attachments are accessed from the server through a given URL :
http://mytfs/tfs/default/WorkItemTracking/v1.0/AttachFileHandler.ashx?FileID=115&FileName=mydoc.doc
Visual Studio basically do a Shell Exec of this URL, which starts your default web browser.
You have two implementations of a Work Item form:
So there's no other way and I doubt there's a custom tool on the net to shorten that process...
Looking at the HTTP Response Headers of AttachFileHandler.ashx the "problem" is because the content is being returned as file:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 11688
Content-Type: application/octet-stream
Server: Microsoft-IIS/7.0
X-AspNet-Version: 4.0.30319
content-disposition: filename=Screenshot.png
X-Powered-By: ASP.NET
Date: Fri, 17 Aug 2012 08:51:44 GMT
It's the content-disposition
header that is forcing a Save As dialog even though the browser could just display the image directly. See the note on 19.5.1 Content-Disposition from w3.org:
If this header is used in a response with the application/octet- stream content-type, the implied suggestion is that the user agent should not display the response, but directly enter a 'save response as...' dialog.
I suspect TFS does it like this so that it can return any file regardless of whether the receiving browser can handle the content natively, e.g., uses a plug-in for PDFs. Maybe it would be possible to modify AttachFileHandler.ashx to change the way it returns content?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With