404 when trying to serve static files with non-english characters - iis

I have Windows 2008 R2 Server with IIS 7.5.
I am trying to serve static files with non-English (Hebrew) names, but cannot get it working.
I have 4 files:
a.jpg
א.jpg
b.txt
ב.txt
When I try to go to http://.../a.jpg and http://.../b.txt, I am getting the right files.
But when I try to access http://.../א.jpg or http://.../ב.txt it won't work.
Even if I encode the file names before going to url i.e http://../%D7%90.jpg it won't work as well.
I am getting a regular 404 server error:
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
I tried the following, but it didin't help:
1.adding globalization settings to web.config:
<configuration>
<system.web>
<globalization
fileEncoding="utf-8"
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
</system.web>
</configuration>
2.adding .jpg and .txt to MIME Types settings in IIS.
What am I missing here?

I found a solution to this problem.
It was all about UrlScan IIS extension...
All I had to do is:
Go to the UrlScan folder inside windir%\system32\inetsrv [32bit] and %windir%\syswow64\inetsrv [64bit]
Open UrlScan.ini and change AllowHighBitCharacters to 1

Related

Azure Web App File Download - Problem with special characters

i have a problem downloading files with special characters...
My web site (mvc.net framework) can upload files with the name "dummy _ + [] ## # ##] [#] 3.pdf", i can see it physically on my FTP server but when i try to download with url "https://fakeurl.con/Attachments/dummy _ + [] ## # ##] [#] 3.pdf" i have a 404 (The resource cannot be found.).
I tried adding in web.config file:
requestPathInvalidCharacters=""
system.webServer -> security --> requestFiltering -> allowDoubleEscaping="true"
system.webServer -> security --> requestFiltering -> allowHighBitCharacters="true"
But nothing has changed...
Someone can help me?
Thanks
Valerio
The allowDoubleEscaping setting actually works, however there are some reasons causing the file could not be open.
Firstly I try without allowHighBitCharacters setting and set the allowDoubleEscaping, eventually only the # could not be recognized, so I change it to %23 and the it will work.
Secondly I add the allowHighBitCharacters and then all special character won't work.
So just only use the allowDoubleEscaping and if don't mind convert # to %23.

Orchard CMS: Resources getting a 404 (Not Found)

I'm creating a theme for Orchard CMS 1.10. I'm using a Bootstrap template as a basis. There are quite a number of CSS and JavaScript files that I'm including. All of them however are not being found.
I created a ResourceManifest class to define them:
manifest.DefineScript("ThemejQuery").SetUrl("~/Scripts/plugins/jquery-1.11.3.min.js");
manifest.DefineScript("Bootstrap").SetUrl("~/Scripts/plugins/bootstrap/js/bootstrap.min.js").SetDependencies("ThemejQuery");
manifest.DefineScript("jQueryScrollTo").SetUrl("~/Scripts/plugins/jquery-scrollTo/jquery.scrollTo.min.js").SetDependencies("ThemejQuery");
manifest.DefineScript("BackToTop").SetUrl("~/Scripts/plugins/back-to-top.js").SetDependencies("ThemejQuery");
and am calling them so in my Document.cshtml:
Script.Require("jQuery").AtFoot();
Script.Require("Bootstrap").AtFoot();
Script.Require("jQueryScrollTo").AtFoot();
Script.Require("BackToTop").AtFoot();
In each directory that these css and js files reside, I'm including a web.config file to allow access:
the web.config files all look like:
and yet none of these files are being served. I don't believe that the paths are an issue, e.g. using '~/Scripts'. The paths are correct (as far as I can see):
I've googled the hell out of this but cannot find a solution. I've tried running this within IIS Express in Visual Studio as well as full-blown IIS. Any ideas?
You need to change the addHandler of your web.config (inside Scripts or Styles) addHandler like:
<add name="StaticFileHandler" path="*" verb="*" modules="StaticFileModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
Drop the '~/Scripts', the resource manager looks for scripts in the modules 'Script' folder and for styles in the 'Styles' folder.

How to allow web.config files as normal files and allow download IIS inside a virtual directory

I am working on a Unity 3D game which upon build for Windows generates game.exe and game_Data file and folder. The Game_Data folder contains a directory called **Game_Data\Mono\etc\mono\2.0**.
The directory files are shown in image.
The Browsers directory contains one file called Compact.browser.
The Current Scenario.
1. These game files are hosted on a server where IIS 7.5 is running.
The game resource files are served in virtual directory of the game website.
I've made few changes to the website's root web.config file so that all filetypes are allowed to download only in the game resources folder on server.
Yes, all file types including .html, .aspx, .xml, .config, .browser, .map etc are all downloading as normal files.
The problem
As you see the directory structure there is a web.config file inside the game resources folder. The file has nothing to do with website configuration but with the game (which is on client side after downloading).
As the files are served as individual files each file is downloaded separately. So when the client tries to download all files including the contents of the above folder.
Due to this web.config file, contents of the directory is not downloading. If I delete this web.config file all of the .aspx, .config, .map files are downloading. Also there are some other folders where many different files are downloading properly.
But this web.config file is also required for the game, and it is not allowing it be downloaded with other files too in the directory shown above.
I've tried to look into the solution. Found some hints to avoid inheritance in nested config files. But actually I want to completely treat this file as a normal file, not as a site configuration file.
I think you got my problem. Please let me know your suggestions. You can say adding Mime types. But actuall all of the file types are downloading including .config files. Except the file named web.config.
I'm having the same problem, and I think I found the solution: there is a way to tell IIS not to interpret web.config files.
To do this, modify the C:\Windows\System32\inetsrv\config\applicationHost.config file (I haven't found a way to do this in the IIS user interface), by specifying allowSubDirConfig="false" for the relevant <virtualDirectory> element:
<configuration>
<system.applicationHost>
<!-- ... -->
<sites>
<site name="Default Web Site" id="1">
<application path="/">
<virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
<virtualDirectory path="/Staging" physicalPath="C:\inetpub\wwwroot\Staging" allowSubDirConfig="false" />
</application>
<bindings> <!-- ... --> </bindings>
</site>
See http://www.iis.net/configreference/system.applicationhost/sites/site/application/virtualdirectory for the details.
The problem is, it still won't let you download the web.config file, it keeps returning a 404 - Not found, even after removing all handlers.
Edit - found the solution. The short answer is that in your web.config, you should clear the fileExtensions and hiddenSegments lists:
<system.webServer>
<security>
<requestFiltering>
<hiddenSegments>
<clear />
</hiddenSegments>
<fileExtensions>
<clear />
</fileExtensions>
</requestFiltering>
</security>
I've written a blog article about it that explains all the details.

Open .obj in Azure Error [duplicate]

I am using three.js for webGL to load .obj
but I have a problem when loading .obj in Windows Azure runnning Windows Server 2008
I using Google chrome browser and it gives the error below:
GET http://websiteaddress.net/webGL/obj/test.mtl 404 (Not Found)
even, I used their original source code to load .obj file it has the same error
and when i try to navigate other images file in the server i can preview it
eg: (website.net/images/test.gif) - i can see the test.gif image in the browser
but when i navigate to .obj, i receive error in the browser:
(eg : website.net/obg/test.obj)
404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.
i can view my .obj locally but not when I put it in Azure!
can anyone helps me? Thanks!
[SOLVED] LOADING .OBJ (Wavefront) FILE IN WINDOWS HOSTING RETURN 404 ERROR [SOLVED]
As I was Working with Three.js and loading a .obj file works great for me in localhost but when running the files from the Windows Hosting it return 404 for the .obj file.
So, we need to add this lines to the web.config file of the project root folder (if you don't have the file in your project root folder then go ahead and create one. )
web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".obj" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
Place the web.config to correct location and Enjoy :)
You will need to add a mime type definition in your application to tell IIS how this file should be served. The mime map referred to in the error message should be defined in the web.config file. Here's an example.
<system.webServer>
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4" />
<mimeMap fileExtension=".m4v" mimeType="video/m4v" />
</staticContent>
</system.webServer>
Click on the link below for a full list of mime types:
Full list of mime types.
I found an answer to my problem, is because the file extension .obj is not yet map to the MIME type in my Azure server:
Check the link below on how to add it:
http://technet.microsoft.com/en-us/library/cc725608(v=ws.10).aspx
and you could check here for the MIME type:
http://filext.com/file-extension/OBJ
Once you have map .obj to MIME, you will have no problem to load it anymore! :)
I thought I should add what I ended up doing after finding this post. I'm using .mtl files for material (in addition to the .obj) for a THREE JS project. Since I'm using MTLLoader to get the materials as well (my models aren't just flat-color), I had to add the following line:
web.config
<!-- Instruct IISNODE to treate .obj+.mtl models as application/octet data -->
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".obj" mimeType="application/octet-stream" />
<mimeMap fileExtension=".mtl" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>

Providing .jad file download link

We are trying to provide a download link to abc.jad file in index.html. abc.jad and index.html are both in the same folder. Following is the link.
download
In addition, we defined the mime type for .jad file in web.config as follows
<mimeMap fileExtension=".jad" mimeType="text/vnd.sun.j2me.app-descriptor" />
In spite of these, we are still not able to download this file from the web browser. It always gives the error HTTP Error 404 - File or directory not found
The server is IIS with .net 2.0
Can you please help?
i know is a little bit late but you are missing these MIME types:
(you have to set these types to your folder on IIS Admin Console)
.cod
application/vnd.rim.cod
.jad
text/vnd.sun.j2me.app-descriptor
.jar
application/java-archive

Resources