HTML and CSS Reference
In-Depth Information
Figure 1-28. Adding HomeController
Add two action methods named Index() and SaveCanvas() to the HomeController class, as shown in
Listing 1-8.
Listing 1-8. Action Methods of HomeController
public ActionResult Index()
return View();
public JsonResult SaveCanvas(string data)
//add code to store canvas data in some database
Session[“canvas_data”] = data;
return Json(“Canvas data stored successfully!”);
The Index() action method simply returns the Index view, which you create in a moment. The
SaveCanvas() method is called from the client-side jQuery code. The return type of SaveCanvas() is a
JsonResult object, which represents a JavaScript Object Notation ( JSON) representation of .NET data
n Note JSON is a lightweight data-interchange format. It's a text-based format and is based on a subset of the
JavaScript programming language. Due to its text-based nature, it's easy to generate, read, write, and parse.
Search WWH ::

Custom Search