publicar un objeto JO en una acción
Yo estaba leyendo Rick Strahls
Me gustaría poder usar JObject en la acción. Escribí un controlador como este
public class AlbumsController : Controller
{
[System.Web.Http.HttpPost]
public string PostAlbum(JObject jsonData)
{
return "success";
}
}
la parte delantera se ve así
cuando el ajax se llama me sale un error
$("#a").click(function () {
var album = {
AlbumName: "PowerAge",
Entered: "1/1/1977"
}
$.ajax(
{
url: "Albums/PostAlbum",
type: "POST",
contentType: "application/json",
data: JSON.stringify({ Album: album }),
success: function (result) {
alert(result.Result);
}
});
});
POST http://localhost:50066/Albums/PostAlbum 500 (Internal Server Error)
jquery-1.7.1.js: 8102 enviar jquery-1.7.1.js: 8102 jQuery.extend.ajax jquery-1.7.1.js: 7580 (función anónima) álbumes: 74 jQuery.event.dispatch jquery-1.7.1 .js: 3256 elemData.handle.eventHandle