Reading Json file from angularJs causing error - json

I am trying to read a json file from my visual studio 2013 environment. It is throwing some error as mentioned below
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.
However its working fine on plnkr http://plnkr.co/edit/std1ngB40YIJBmC94Zdm?p=preview
Can someone please let me know how to resolve the same ?
Error screen shot
Folder Structure

Have you set up the mime map correctly? I only see a screenshot for the handler mapping.
Open IIS Manager
Display properties for the IIS Server
Click MIME Types and then add the JSON extension:
File name extension: .json MIME
type: application/json
Go back to the properties for IIS Server
Click on Handler Mappings
Add a script map
Request path: *.json
Executable: C:\WINDOWS\system32\inetsrv\asp.dll
Name: JSON
If this still fails to work remove the script map completed and just stick with the mime map, I do not know why you are adding the script map in the first place.

I done lot of research on this issue and finally its resolved :) :)
I tried the answer given by #James Trotter as well but didn't get success.
I don't know why MIME in IIS didn't work but it worked when I added it in web.config
SOLUTION :
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
For More Information
Allow loading of JSON files in Visual Studio Express 2013 for Web

Related

Unable to open Json file on Server

I published a json file on to my website using ftp. When I tried to access my site using mtsite.com/abc.json it throws the below error.
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
My file is on hosted site on azure. Even if file in on server why did it say that file is not found?
Any place in azure portal where I can add or allow Mime type json? I cannot add web.config file as My files are all HTML and Json.
By default IIS (and so the Azure App Service) doesn't serve .json files. You need to enable this feature in your web.config. If don't already have one, create it in the root directory.
Open your web.config and place this code
<staticContent>
<remove fileExtension=".json"/>
<mimeMap fileExtension=".json" mimeType="application/json"/>
</staticContent>
under the nodes
<configuration>
<system.webServer>
And it should be fixed.
Here you can find a basic web.config template that i've made a while ago
P.S: Even though you are using only HTML and JSON, this is the only way to go (as there is not a UI solution in the portal). In this way you could also control other aspect of your website, for example the redirect to HTTPS for the HTTP requests.

MIME type ('text/html') is not executable, and strict MIME type checking is enabled while trying to render angular2 using express

I'm trying to use Angular2 and NodeJS, express in my new project and running into an issue. Ive used cli to ng build the Angular2 project and have the dist folder generated.
Now when I try to point this folder using express, I can see only the "Hello world" html in the index.html. In the networks tab on dev tools on chrome, I can see the .js files getting called with 200OK but however they seem to return the index.html in response. And on browser console, I see errors on the js files as below.
Refused to execute script from 'https://localhost:8080/inline.bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Same error for rest of the js files.
I've tried:
1. CORS to allow *
2. Content-type: application/javascript on before res.sendFile(__dist+'index.html');
3. ng serve seem to work file from localhost:4200 though. But I need express to render the page.
Not sure how to solve the issue. Any suggestions are appreciated.
Try
app.use(express.static('your angular dist folder here'))
For more info about serving static files, you can get here.

Resource interpreted as Stylesheet but transferred with MIME type text/html in IIS7.5

I have a web application that I'm trying to install in my local IIS. I'm using IIS 7.5. The problem I'm having is that my application comes up but my css styles gives me Resource interpreted as Stylesheet but transferred with MIME type text/html error. This only happens while I'm not authenticated in the application. So I tried different options for this error.
Verified my MIME type on the application. The .css type is set to type/CSS.
Verified all my permissions for the folder in the Security Tab. Assigned to IIS_IUSRS and for NETWORK SERVICE groups Full Control to the Root folder. (Even tried adding Everyone to share with Read/Write access)
The only thing that "worked" was adding the specific CSS folder to my web.config. The problem with this approach is that I didn't needed to do this before for this application. So there should be something that is causing this problem.
<location path="css">
<system.web>
<authorization>
<allow users="?" />
</authorization>
</system.web>
</location>
Also tried adding the .htaccess file (even though this is not Apache). To see if this worked and not.
Verified the Static Content that is checked in the Add Features section.
I'm running out of options for this one. If anyone know anything else that should be consider, will be very appreciated.
Thanks in advance.
I had a similar problem once and I was able to solve it by re-installing the IIS
Hope that helps!

flash cannot find xml file

i have a flash app that loads data from an xml file.
i get a network error 404 not found for the xml file but it shows the correct path to the xml file.
"NetworkError: 404 Not Found - http://www.mysite.com/movie/StartDATA.xml" this path is correct.
also i can call up this XML file in browser.
also this works on my localhost, just will not work on live server (have tried 2 different servers).
i thought a permission problem so i set XML to read/write all but also that does not work.
i am out of ideas now.

loading .json files generates 404 errors

My first Azure website is a simple test site I've had for a while that makes ajax calls back to the server for JSON data. All the data files have .json extensions. Azure will not 'see' these files. If I change the extension to .txt it servers them up fine.
Do I have to muck with IIS to get this .json to be seen?
I too found Ahmed Sabbour's blog post helpful, but it created an additional problem for me. Whilst the fix worked for the Azure Web App when I then tried to run the app locally it died horribly, throwing HTTP 500.19 everywhere. It took me a while to figure out how to fix this whilst maintaining a single web.config. The solution was (albeit a bit of a fudge) to remove the fileExtension first and then add it back in:
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
For my narrow purposes this was fine and I hope this might save someone time trying to figure this out.
Citing Ahmed Sabbour with his blog post http://blogs.msdn.com/b/africaapps/archive/2013/06/07/how-to-serve-static-json-files-from-a-windows-azure-website.aspx you have to do the following:
"If you upload a .json file to your Windows Azure website and try to access it, it would give you a 404 File Not Found error, because the MIME Type of .json is not set by default. This also applies in general to any file that might need a specific MIME Type.
To fix this issue, FTP into your website and upload the following Web.config file which will set the correct MIME types. If you already have a Web.config file in place, just add the below to the appropriate section.
<?xml version="1.0"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
". I did this and the 404 was gone.
It appears that Azure (Cloud Services, at least) knows how to serve JSON from a deployed ASP.NET MVC project. The problem in my case was that the Build Action on the JSON file's property page was not set correctly. Changing the Build Action to Content fixed it for me.
have you tried adding the specific MIME type to your server's config file?
http://www.iis.net/configreference/system.webserver/staticcontent/mimemap
If you add the mime type as
application/json; charset=utf
that should work.