When working in a .net environment, is appending a JSON file with .js a common good practice?
-
I have used JSON only in PHP environments and never had a problem with dynamically generated content. But when building a recent site in a .net environment, the data was not being passed through. I found out that the server will parse JSON and return in a different format. So something should be set up on the server to make sure that JSON is being parsed properly. I found this article on Microsoft's website that gage a tutorial on JSON: http://msdn.microsoft.com/en-us/library/bb299886.aspx But when I brought this up to other devs, one mentioned that he just renames his JSON file to a JavaScript file. I tried it, it works totally fine. So why would anyone do the lengthy way described in various tutorials throughout the web? or implement anything else. I am guessing that this (renaming as a JavaScript file) is just a hack and there might be other downfalls? Anyone else interested in reading about JSON, here are some links that are out there: http://www.codeproject.com/Articles/159450/fastJSON http://json.codeplex.com/
-
Answer:
File content types are inferred by the file extensions. The .json file extension is likely not recognized, as opposed to the common .js extension. Try mapping .json to application/json on the server. The client application should receive the Content-Type header and handle it appropriately. Only as a last resort I'd suggest muddling the file extension to appear as JavaScript -- because it technically isn't.
Rick Viscomi at Quora Visit the source
Related Q & A:
- How do I convert a PDF file to PDF/A in Delphi?Best solution by softwarerecs.stackexchange.com
- How to delete a line from a .txt file in node.js?Best solution by c-sharpcorner.com
- When i do a search and click on a result a get a page addressed rc10 overture what do i do?Best solution by Yahoo! Answers
- How to put a video file on to a disc?Best solution by wikihow.com
- Would a drop of sweat on a capacitive touchscreen be considered a touch?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.