0

I am thinking of this idea: 1. Request data from server and write to javascript file in json format using C# 2. When the page loads, the page loads the js file and I can use the data using javascript?

is this a good or bad idea? is there any example somewhere doing that?

thanks

3 Answers 3

1

I'd take into account:

  • Performance, do you expect the dataset to be small enough to be managed by browsers? How complex are the relationships between your entities?
  • Security, how will you secure the data to avoid malicious code execution?

Taking into account these concerns I'd recommend JSON for data interfaces.

Sign up to request clarification or add additional context in comments.

2 Comments

it is only one table with 7 fields, as well as it will not contains that much data. only authorized person can load the json, and it is read only.
If he outputs JSON, he should be fine security wise - as long as he makes sure user-data ends up properly escaped in strings, which, unless he's reinventing the JSON outputter wheel, should be done by whatever JSON library he's using.
0

JavaScript performance varies by browser, and can go downhill under load, but with that small of a dataset you shouldn't have to worry about that.

If you are using MVC, AJAX and JSON are very easy.

Comments

0

My company does this occasionally when the page is meant to hold only static data. It looks something like this in a .aspx document:

var initialData = <asp:Literal runat="server" id="MyAwesomeLiteral" Text="null" />;

myObject.init(initialData);

This only works if you're confident that your data can't be manipulated to bad ends. If you have IDs, especially sequential ones, encrypt them.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.