I have a situation where a user can click on a link to open a Word .doc file, and rather than coming up in Word it displays as text and so is unreadable. Can you please give me some clues on how to resolve this? Thanks.
What is wierd is that it shows in the window as text, but if you right click and download, it comes down as .htm. If you then load to .htm file into Word, it looks fine.
If server side MIME type is set correctly, then we can only guess the web browser recognizes it wrongly. You may use Fiddler or Network Monitor to analyze the packets arrive on browser side, and then see whether it does receive correct MIME info but interprets
it wrongly. Once that's confirmed, you can start to check how to tune the browser settings. But if Fiddler or Network Monitor shows wrong MIME info, you need to go back to the server side.
Lex Li
http://lextm.com
---------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
This was put in there at the direction of a Microsoft engineer, to prevent folks from opening the files without going through .Net security.
Since you are using integrated pipeline, which is fully asp.net integrated. So you don't need to map non-asp.net extensions to asp.net dll to take advantage of asp.net features(e.g forms authentication). As I know, ASP.NET also handles files based on their
extensions, you may check httphandlers section in asp.net root web.config file(C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\web.config) for details. There you may see different handlers are specified for different extensions. Surely, files with .pdf,.doc
will be mapped to the wildcard one, hence processed incorrectly. So I suggest you remove this handler mappings entries but use modules instead, this will still make you benifit from asp.net feature for these non-asp.net requests.
Thanks.
Marked as answer by Lloydz on Mar 26, 2012 01:56 AM
Thanks for your feedback. If I am understanding this correctly, you are saying that the HTTP handlers are not necessary. This is true for opening the files, but if I take those out then I lose the security on the files and they can be accessed directly bypassing
.net security. What I need is to have the .net security invoked, and still be able to open the files correctly. How can this be accomplished? Thanks.
You can take advantage of .net security without mapping the file extension to asp.net in integrated pipeline. I suggest you check the following article for details:
How to Take Advantage of the IIS 7.0 Integrated Pipeline
gerhard_acsl...
4 Posts
doc files
Mar 16, 2012 03:39 AM|LINK
lextm
4484 Posts
Re: doc files
Mar 16, 2012 08:26 AM|LINK
See if you get MIME type correctly set up,
http://technet.microsoft.com/en-us/library/cc753281%28v=ws.10%29.aspx
http://lextm.com
---------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
gerhard_acsl...
4 Posts
Re: doc files
Mar 16, 2012 03:49 PM|LINK
.doc is set to msword, so looks okay.
What is wierd is that it shows in the window as text, but if you right click and download, it comes down as .htm. If you then load to .htm file into Word, it looks fine.
Any clues?
lextm
4484 Posts
Re: doc files
Mar 17, 2012 02:35 AM|LINK
http://lextm.com
---------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
gerhard_acsl...
4 Posts
Re: doc files
Mar 18, 2012 05:12 PM|LINK
I found what is causing the issue, it is the following code in the web.config.
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="pdf" path="*.pdf" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv4.0,bitness32" />
<add name="doc" path="*.doc" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="docx" path="*.docx" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="xls" path="*.xls" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="xlsx" path="*.xlsx" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="txt" path="*.txt" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="ppt" path="*.ppt" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="pptx" path="*.pptx" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="msg" path="*.msg" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="fax" path="*.fax" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" />
<add name="Reserved-ReportViewerWebControl-axd" path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
This was put in there at the direction of a Microsoft engineer, to prevent folks from opening the files without going through .Net security.
So the question becomes, how do I keep in the security as above, and still have the file open correctly?
Thanks for your help.
Lloydz
2335 Posts
Microsoft
Re: doc files
Mar 22, 2012 02:44 AM|LINK
Since you are using integrated pipeline, which is fully asp.net integrated. So you don't need to map non-asp.net extensions to asp.net dll to take advantage of asp.net features(e.g forms authentication). As I know, ASP.NET also handles files based on their extensions, you may check httphandlers section in asp.net root web.config file(C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\web.config) for details. There you may see different handlers are specified for different extensions. Surely, files with .pdf,.doc will be mapped to the wildcard one, hence processed incorrectly. So I suggest you remove this handler mappings entries but use modules instead, this will still make you benifit from asp.net feature for these non-asp.net requests.
Thanks.
AlvinBasil
6 Posts
Re: doc files
Mar 22, 2012 06:49 AM|LINK
All the information given about the docs is superb.
gerhard_acsl...
4 Posts
Re: doc files
Mar 23, 2012 12:40 PM|LINK
Lloydz
2335 Posts
Microsoft
Re: doc files
Mar 26, 2012 01:44 AM|LINK
You can take advantage of .net security without mapping the file extension to asp.net in integrated pipeline. I suggest you check the following article for details:
How to Take Advantage of the IIS 7.0 Integrated Pipeline
http://learn.iis.net/page.aspx/244/how-to-take-advantage-of-the-iis-integrated-pipeline/
Thanks.