Skip to content

Instantly share code, notes, and snippets.

@adamtal3
adamtal3 / readme.md
Last active August 29, 2016 11:34 — forked from benpriebe/readme.md
Transferring Server data to JavaScript with initial Page Request

Transferring Server data to JavaScript with initial Page Request

Often you want to return data with your call to retrieve a web page/control from ASP.NET MVC so that it can be accessed via JavaScript as a ViewModel (using KnockoutJS or equivalent).

Typically, you make a server call to retrieve the web page using the standard ASP.NET controller action and then make a AJAX call to go retrieve the model to populate your JavaScript ViewModel.

Wouldn't it be nice if you could send back the model with the page request and avoid a separate AJAX call?

How