i have a problem, i work with MVC and i am trying to save HTML code of view in a DB field. I have on JS side of my MVC Solution the following code:
var data = { id_perizia: $("#id_perizia").val(), pinSessione: $("#pin_sessione").val(), saveRegistration: flgSave, markup: document.documentElement.innerHTML }
$.ajax({
type: "POST",
url: WebPerizie.baseUrl + "Registra/stopRecording",
data: data,
success: function (resp) {
window.location.href = WebPerizie.baseUrl + "PT_PERIZIE/Edit/" + $("#id_perizia").val();
},
failure: function () {
//console.log("Failed:::" + resp);
},
error: function (e) {
//console.log("Status code Error==="+e.status);
},
});
and my controller function parameter is:
public ActionResult stopRecording(decimal id_perizia, string pinSessione, bool saveRegistration, byte[] markup)
from the debugger i enter in the Controller, but i don't understand because the markup variable is always null. When i use in the browser console the command:
$("html").html();
or
document.documentElement.innerHTML
i always get the HTML code of the page in the markup variable, but in the controller i have null. I have the sensation i wrong to pass the variable markup to the controller and the markup variable has the right value in the JS code. What do you think about it? What do i wrong? Can i get the HTML View code directly from the controller? If i can, is it a better solution?