Get IIS6 to serve JSON files (inc. POST,GET)? - json

By default, IIS6 does not serve .json (no wildcard MIME type).
Therefore a 404 not found is thrown. I then add a new MIME type (.json, text/plain or application/x-javascript or application/json) which works fine.
However, when you then add a new mapping (Home Directory -> Configuration -> Add) with .json, C:\WINDOWS\system32\inetsrv\asp.dll, "GET,POST" and try to browse to the file, you get a 404.
If you remove the mapping and try and POST or GET to it, you get a 405.
...
Suggestions?

By default, IIS in W2K3 and above won't serve files that aren't of a MIME type that it knows about (instead returning 404 errors).
You need to add a MIME type to IIS to allow it to serve that type of file. You can set it at the site level or at the server level.
To set this for the entire server:
Open the properties for the server in IIS Manager and click MIME Types
Click "New". Enter "JSON" for the extension and "application/json" for the MIME type.
Update
Given this post is found in the Sencha "getting started guide", I thought it's worth upgrading the steps.
On Win 7 Enterprise SP 1 with 64-bit
The IIS has a different outlook. So the steps:
*. Open IIS Manager. Then you get following window.
*. Right click on MIME and choose open feature
*. Click on ADD from top right corner Actions menu
*. Rest is as per Evan's.

Make sure you have Active Server Pages Allowed in the Web Service Extensions section of your IIS configuration.
IIS Manager -> (local computer) -> Web Service Extensions -> Active Server Pages

If you don't have IIS installed, obviously, you'll want to install it prior to launching the IIS Manager. I needed (on Windows 7) to go to: 'control panel/program and features' then click 'turn windows features on or off'
Reference: http://www.howtogeek.com/howto/windows-vista/how-to-install-iis-on-windows-vista/
It appears that starting the IIS Manager is different for different systems. I did 'start/run/inetmgr.
Reference: http://msdn.microsoft.com/en-us/library/bb763170(v=vs.100).aspx
Reference: http://technet.microsoft.com/en-us/library/cc770472(v=ws.10).aspx
Troy Frericks.
#

Related

For PyCharm/WebStorm my IDE's local server is not detecting other directories

When I select a html file to open "in browser" in Webstorm it works and it opens under the localhost. The issue I'm having is that this webstorm internal server is not detecting any of the other paths in my project root like images and javascript files.
I should note that this feature has worked before on other projects I started from scratch using "new project." The difference with this project is that I opened a directory as a project.
The built-in webserver serves files from http://localhost:<built-in server port>/<project root>. Forward slashes in URLs tell the browser to resolve them relative to the web server root (localhost:63342 in your case), causing 404 errors.
If you like to change the default web path on built-in web server, you have to re-configure the server by editing your system hosts file accordingly - see http://youtrack.jetbrains.com/issue/WEB-8988#comment=27-577559.

Unable to connect to https://myserver/VaultService

I have just installed Vault on my machine, I intend touse it single user.
When trying to use it for the first time, I get the error message below.
Is there anything I should enable?
I have the correct passwords.
I am using the Admin account.
I have Windows * 64 bits, Vault is also 64 bits.
Thanks to Beth's answer below, now I can at least visualise the following page, but still not be able to follow the links in it.
This is the result I get when I click on the links(Picture below).
Error messages are below, but the formatting is not good.
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.
Things you can try: If you want to serve this content as a static file, add an explicit MIME map.
Detailed Error Information: Module StaticFileModule Notification ExecuteRequestHandler Handler StaticFile Error Code 0x80070032
Requested URL http://vrindavana:80/VaultService/Admin/default.aspx Physical Path C:\inetpub\wwwroot\VaultService\Admin\default.aspx
Logon Method Anonymous
Logon User Anonymous
IIS:
I have IIS installed and if I browse it I see what's on the picture below.
First try reaching the Vault server using a browser. Try the URL http://<your Vault server name>/vaultservice/index.html. If you can not reach that page, then change to either the FQDN or the IP address.
If you still cannot reach the index.html page, then try reaching it using a browser right on the server and use localhost. The URL would then be http://localhost/vaultservice/index.html.
Let me know the results of these URLs first and then I'll give you next steps.
Beth
SourceGear Technical Support
Thanks for the update.
The error seems to indicate a problem with the .NET Framework. Here are the next steps you should try.
1) Register the .NET framework with IIS. Run a command-prompt as administrator and then change directories until you get to the highest version of the 4.x .NET framework. It might look something like cd C:\Windows\Microsoft.net\framework64\v4.0.30319, but I'm not sure of the entire path on your machine. Then run the command aspnet_regiis -i.
Then try your web page again.
2) If you then get a 404.2 error, then open your IIS Manager, click on the machine name and then click on ISAPI and CGI restrictions. Make sure the .NET frameworks are set to Allow there.

HTML5 offline appcache custom fonts not loading or displaying properly when server is down

These fonts load perfectly fine when the server is running OR when the client is offline. But as soon as I shut down my server (let's assume it can't be contacted because it's down) the fonts break and this is what I get in console:
Application Cache Error event: Manifest fetch failed (-1) [URL]
and
Resource interpreted as Font but transferred with MIME type text/html: [URL]
I'm running a localhost and I can only assume that this will be the behavior in the wild since even when I'm offline it still checks the Manifest like so in the console:
Document was loaded from Application Cache with manifest [URL]
Application Cache Checking event
Application Cache NoUpdate event
Can anyone shed some light on this?
The manifest fetched failed error always happens when you go offline. The second error means that the fonts were not received as the correct MIME type, so you will need to add a .htaccess or something that will set the mime types correctly. Also make sure that the file extension for the fonts is correct.

How do I use Access-Control-Allow-Origin? Does it just go in between the html head tags?

I've been reading about Access-Control-Allow-Origin because it seems effective at allowing cross domain requests since I have access to the external site. My question ism how do I use Access-Control-Allow-Origin to allow cross domain requests. I tried this (don't laugh) (by the way all I want is for a single number, 1 or 0 to be returned)
<html>
<head>
Access-Control-Allow-Origin: *
</head>
<body>
1
</body>
</html>
Am I close? Thanks for your help. If there is an easier way to do a simple cross-domain request let me know.
There are 3 ways to allow cross domain origin (excluding jsonp):
Set the header in the page directly using a templating language like PHP. Keep in mind there can be no HTML before your header or it will fail.
Modify the server configuration file (apache.conf) and add this line. Note that "*" represents allow all. Some systems might also need the credential set. In general allow all access is a security risk and should be avoided:
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Credentials true
To allow multiple domains on Apache web servers add the following to your config file
SetEnvIf Origin "http(s)?://(www\.)?(example.org|example.com)$" AccessControlAllowOrigin=$0$1
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header set Access-Control-Allow-Credentials true
For development use only hack your browser and allow unlimited CORS using the Chrome Allow-Control-Allow-Origin extension
Disable CORS in Chrome: Quit Chrome completely. Open a terminal and execute the following. Just be cautious you are disabling web security:
open -a Google\ Chrome --args --disable-web-security --user-data-dir
That is an HTTP header. You would configure your webserver or webapp to send this header ideally. Perhaps in htaccess or PHP.
Alternatively you might be able to use
<head>...<meta http-equiv="Access-Control-Allow-Origin" content="*">...</head>
I do not know if that would work. Not all HTTP headers can be configured directly in the HTML.
This works as an alternative to many HTTP headers, but see #EricLaw's comment below. This particular header is different.
Caveat
This answer is strictly about how to set headers. I do not know anything about allowing cross domain requests.
About HTTP Headers
Every request and response has headers. The browser sends this to the webserver
GET /index.htm HTTP/1.1
Then the headers
Host: www.example.com
User-Agent: (Browser/OS name and version information)
.. Additional headers indicating supported compression types and content types and other info
Then the server sends a response
Content-type: text/html
Content-length: (number of bytes in file (optional))
Date: (server clock)
Server: (Webserver name and version information)
Additional headers can be configured for example Cache-Control, it all depends on your language (PHP, CGI, Java, htaccess) and webserver (Apache, etc).
<?php header("Access-Control-Allow-Origin: http://example.com"); ?>
This command disables only first console warning info
console
Result:
console result
If you are using npm and want to load some files/folders allowing cross origin resource sharing(CORS) try the following,
install the http-server:
npm install http-server -g
Go to your files/folders folder and run the command below to make your files/folders available at http://127.0.0.1:8080 . This a good choice when you want to keep the files in a safe place and control who can request inferences to it. The -c1 parameter is added to disable caching, and
the --cors flag enables cross origin resource sharing(CORS) allowing the hosted files to be used by the client side JavaScript for a given domain.
http-server -c1 --cors .
It worked for me in WSL-ubuntu terminal on windows 10. It should work with npm CLI on any OS.
Thank you.
If you use Java and spring MVC you just need to add the following annotation to your method returning your page :
#CrossOrigin(origins = "*")
"*" is to allow your page to be accessible from anywhere.
See https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/Access-Control-Allow-Origin for more details about that.

Uploadify for IIS 7, saving to a subfolder

Uploadify works for Visual Studio but not for IIS 7 (same machines), using Forms authentication. Does anyone have a working uploadify configuration for IIS 7 where they save to a subfolder?
I'm using the Uploadify jQuery control for client-side uploads.
I think my IIS 7 configuration has issues with it. The uploadify POST immediately returns a HTTP 1.1 302 Found, back to my login page.
I've tried to allow anonymous access to the uploading section(subfolder) plus the page(script) that processes the image in the web.config, using the location node(configuration ... location). Seems like the Uploadify post is immediately blocked.
Again, this worked fine just using Visual Studio 2008, but when I run the site on the same machine I get the redirect.
Your thoughts/ideas are very welcomed!
It seems that the many nested master pages included Forms Authentication code to ensure the user was authenticated. This was the source of the redirect ...
I had same problem as you. Check path of your *.axd script. When you have path like uploader.axd uploader work fine only in root. Try path with slash like this -> /uploader.axd.