Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8115203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:23:26+00:00 2026-06-06T03:23:26+00:00

Before I start, I want to make it clear that my code is working

  • 0

Before I start, I want to make it clear that my code is working properly, and this is more of a “general best practice” question. I’m using knockout.js to load in my ASP.NET MVC2 model into knockout’s viewModel.

In my aspx page I have:

<script>
var model = <%= new JavaScriptSerializer().serialize(Model) %>; 
// the above line will display in my page's "View Source". Is this bad? slow? 
</script>

Then in my JavaScript include file at the top I have:

$(document).ready(function() {
    var viewModel = new MyViewModel();
    ko.applyBindings(viewModel);

    viewModel.modelProp(model);
});

The code totally works fine, but the concern I have with this is that the JSON output is viewable in the “View Source” option from the browser in the HTML output. I’m curious about two things:

  1. Does this also happen in ASP.NET MVC3? I’m using ASP.NET MVC2, hence I can’t use @Html.Raw(Json.Encode(Model)); — But does the MVC3 method result in the same issue?

  2. Is this something I should be concerned about? Is it a security issue? Is it a performance issue? The page’s source will be larger because I’m outputting the JSON into a JavaScript variable, no? Again, maybe it’s not an issue in MVC3?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:23:28+00:00Added an answer on June 6, 2026 at 3:23 am

    If I hear you correctly, you want to now if you should be concerned that people can see your json. I would not be concerned about that. In fact, not only can they see the json by viewing source, but they can also see it via a network sniffer like fiddler, httpwatch, or browser developer tools (F12). I’m not sure why you care if the json is visible because once it gets data bound to the UI, it will be there too.

    As a side note, by loading your KO viewmodel from MVC, that means your viewmodel will only refresh its model data when you post. If you load it via an ajax call (to perhaps an MVC action since you use asp.net mvc) you could avoid that page refresh. Just another option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NOTE: I've re written the original question to make it much more clear. I
the code below is working, but I want to make sure it's correct .
Before I start I must say that I maybe biting more than I can
I am working in android, i want to make a scrollview. this is my
I want to get one record before start date and end date DtpFrom means
Am using Mediainfo library in my C# project,before start invoking this dll,i just ran
I am working on a Media up-loader which uploads images to Server. Before start
Before you start flaming, I'm going to tell you that I am trying to
Before you start laughing at such a simple question let me explain: I am
Before you start marking this as a duplicate , read me out. The other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.