Add a handler to allow dowloading script or a MIME map - asp.net

I created a script for Internet Explorer which can be installed using GM4IE (Greasemonkey for Internet Explorer) and it has the extension .gm4ie.
When I try to give the download link to this file on my server, it gives this error:
http://i.stack.imgur.com/K7Rs4.jpg
page you are requesting cannot be
served because of the extension
configuration. If the page is a
script, add a handler. If the file
should be downloaded, add a MIME map.
How do I add this this hanlder or a mime map and where do I add this?

Try adding a MIME type to IIS.
For IIS7: http://technet.microsoft.com/en-us/library/cc725608(WS.10).aspx
You can of course just zip it if you don't wish to add the MIME type.

Related

IIS Handler Mappings for classic asp page include(.inc) file

I am mirgranting a classic ASP site to newer version of Windows server hosted in IIS 10.
When loading the default.asp page, I found in the browser's developer tool, network tab it says helpers.inc file could not be find. But it is in the same folder with the default page.
The helpers.inc file is invoked in the default.asp page by this code:
<script src="helpers.inc" language="VBScript" defer="true"></script>
If I try to access the helpers.inc file from browser, I will get this error:
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
Most likely causes:
•It is possible that a handler mapping is missing. By default, the static file handler processes all content.
•The feature you are trying to use may not be installed.
•The appropriate MIME map is not enabled for the Web site or application. (Warning: Do not create a MIME map for content that users should not download, such as .ASPX pages or .config files.)
•If ASP.NET is not installed.
I tried add a handler mapping for *.inc file using the %windir%\system32\inetsrv\asp.dll executable, but it doesn't seem working. Gives me a new error:
HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.
Most likely causes:
•The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler.
I am wondering what I need to let the include(.inc) file can be recognized/read by the asp page?
If this line is how it appears in the migrated code (without any modification)
<script src="helpers.inc" language="VBScript" defer="true"></script>
then one thing is clear.
This isn't a SSI (Server Side Include).
The tag defines a file with an .inc extension as a Client Side VBScript. At the moment though, you haven't told IIS that .inc is a file type it is allowed to serve as text/vbscript.
Note: Having client-side VBScript defined in the page will severely limited cross browser compatability because VBScript is only supported in older versions of Internet Explorer.
Why 404.3?
The reason for the 404.3 is because IIS blocks unknown file types. To fix this you need to add a MIME type mapping in IIS which I wouldn't usually recommend as .inc is sometimes used as an extension for SSI files, but as we have debunked that theory mapping the MIME type is the way go.
Why it's not an SSI
There are only three ways to run server-side script in a Classic ASP page;
Using processor tags
<%
...
%>
Using script tags with the runat="server" attribute.
<script language="VBScript" runat="server">
...
</script>
Adding an SSI using the #include directive.
<!-- #include virtual = "somefile.asp" -->
Useful Links
Answer to IIS 7.5 doesn't run *.inc as ASP Classic (argument for not using .inc extension for client-side script).
Answer to difference between mime types and extension filtering on IIS?.
Include works, but Lankymart's answer is correct.
I created a helpers.inc file:
Sub MakeAMsg(MsgText)
MsgBox MsgText
End Sub
I used Include and kept the .inc extension:
<script language=VBS>
<!--#include file=helpers.inc-->
makeamsg("This Used Include")
</script>
It works. I renamed the .inc with a VBS extension:
<SCRIPT language=VBS src=helpers.vbs></SCRIPT>
<script language=VBS>
makeamsg("This Used Script tags with vbs extension")
</script>
And that works, too.
I checked my server and by default .vbs was set to a mimetype of text/vbscript. (I'm in the middle of setting up another where I haven't changed anything, and it has this mapping, as well.)
So using #include does work, but either changing the extension to .vbs or adding a mimetype that duplicates the .vbs mime type would be better.

HTTP Error 404.3 - Not Found ... while downloading .dae files on ASP.Net

When I try to access a file extension .dae on IIS server... I get this error:
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
Looks like I am not able to configure something on my IIS Server. Can somebody please direct me to the right places. I am using Visual Express 2012 for web.
Since directory browsing is disabled for you, only few file types are accessible for the client,
like scripts and images.
In order to allow other file types, try this link. don't forget to replace the dmg with dae of course.

uploaded file content type not correct

I have a simple upload page using the html file element. I choose a .pdf file to upload and when I inspect the Content type of the file when it goes to server the value is "application/msword" instead of "application/pdf"
any ideas?
Thanks,
rod.
That depends on your browser settings. Try a few other file types and check what you get there. Is Acrobate installed?
What browser are you using?
Here is some background info:
http://techblog.procurios.nl/k/n618/news/view/15872/14863/Mimetype-corruption-in-Firefox.html
We have our own internal mime type mapping in addition to what we get from the browser.

IIS - wont serve an .ini file

I have a .ini file in the virtual directory of IIS. When i try to open the same in IE i get file not found HTTP 404 error.
http://www.virtualdirectoryname/sample.ini
Any inputs.
Please suggest some solution.
Thanks,
Karthick
By default, IIS will only serve files for which the extension matches a defined MIME type. See the following support article for reference - http://support.microsoft.com/kb/326965
To allow .ini files to be downloaded, follow the steps from the KB article linked above:
Open the IIS Microsoft Management Console (MMC), right-click the local computer name, and then click Properties.
Click MIME Types.
Click New.
In the Extension box, type the file name extension that you want (in this case, .ini).
In the MIME Type box, type application/octet-stream.
Note: this is specific to IIS 6 or IIS 5.x - The process is slightly different for IIS 7.x

File extension problems with classic ASP

I am running a classic ASP website where my online users can attach files to the internal message system. But whenever they upload an attachment with more then 3 characters in the file extension, the server gives me a 404.
Files like mypicture.jpg works fine, but files like mydocument.docx doesn't work?
Any suggestions?
IIS6 will only serve documents where the file extension is mapped to a mime type in the mime map property for the server or the site. In order to serve the more recent Office 2007 document types you will need to add extra mappings.
There are a number of places where you can find a list of these new mime types.
This is a simple one; from Office 2007 mime types for IIS:
.docm,application/vnd.ms-word.document.macroEnabled.12
.docx,application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotm,application/vnd.ms-word.template.macroEnabled.12
.dotx,application/vnd.openxmlformats-officedocument.wordprocessingml.template
.potm,application/vnd.ms-powerpoint.template.macroEnabled.12
.potx,application/vnd.openxmlformats-officedocument.presentationml.template
.ppam,application/vnd.ms-powerpoint.addin.macroEnabled.12
.ppsm,application/vnd.ms-powerpoint.slideshow.macroEnabled.12
.ppsx,application/vnd.openxmlformats-officedocument.presentationml.slideshow
.pptm,application/vnd.ms-powerpoint.presentation.macroEnabled.12
.pptx,application/vnd.openxmlformats-officedocument.presentationml.presentation
.xlam,application/vnd.ms-excel.addin.macroEnabled.12
.xlsb,application/vnd.ms-excel.sheet.binary.macroEnabled.12
.xlsm,application/vnd.ms-excel.sheet.macroEnabled.12
.xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltm,application/vnd.ms-excel.template.macroEnabled.12
.xltx,application/vnd.openxmlformats-officedocument.spreadsheetml.template
Adding all mime-types to IIS in one step is very simple:
The easiest way to do this is stopping IIS and editing the metabase
XML file (C:\WINDOWS\system32\inetsrv\MetaBase.xml) using a text
editor. Search for the <IIsMimeMap Location="/LM/MimeMap" /> element
and append the lines above to the MimeMap attribute
The server probably has no mime-type defined for docx and such file extensions.

Resources