Asp.Net MVC (면도기 뷰 엔진)에 다시 도움이 필요합니다. 내보기 (색인) 내가 가지고에서 MVC3 (면도기) Json 컨트롤러에서 역 직렬화 된 데이터 가져 오기
@model IEnumerable<Movie>
나는 컨트롤러 모델을 전달하려는 :이 방법으로 모델을 캐릭터 라인 화 :
<script type="text/javascript">
function postData(){
var urlact='@Url.Action("createDoc")';
var model ='@Html.Raw(Json.Encode(Model));
$.ajax({
data: JSON.stringify(model),
type:"POST",
url:urlact,
datatype:"json",
contentType:"application/json; charset=utf-8"
});
}
</script>
모든 것이 작동하는 것 같다, 내가 알고 원인 캐릭터 라인 데이터는 다음과 같습니다
'[{"ID":1,"Title":"The Lord of the Rings: The Fellowship of the Ring","ReleaseDate":"\/Date(1007938800000)\/","Genre":"Fantasy","Price":93000000.00},{"ID":2,"Title":"The Lord of the Rings: The Two Towers","ReleaseDate":"\/Date(1039042800000)\/","Genre":"Fantasy","Price":94000000.00},{"ID":3,"Title":"The Lord of the Rings: The Return of the King","ReleaseDate":"\/Date(1070233200000)\/","Genre":"Fantasy","Price":94000000.00}]';
문제는 : 컨트롤러, methodName로 에서 "createDoc" (스크립트에 선언) 나는 액세스 할 수없는 문자열 화 된 데이터
[HttpPost]
public ActionResult createDoc(IEnumerable<Movie> movies)
{
//...using movies list
return View();
}
가 왜 캐릭터 라인 데이터에 액세스 할 수 없습니다 : 웹에 설립 다음 몇 가지 샘플, 내 방법은 다음과 같이인가? 컨트롤러 메서드에서 모델을 deserialize하기 위해 호출 할 수있는 메서드가 있습니까? 또한 stringify() 대신 serialize() 메서드를 사용할 수 있습니까? 그렇다면 구문은 무엇입니까?보기 & 컨트롤러 쪽보기?
감사합니다.
무엇이 오류입니까? movies 매개 변수가 null입니까? 오류가 발생합니까? – Dismissile
아니, 난 그냥 내 createDoc 행동에 아무것도 할 수 없습니다. 아무것도 게시되지 않은 것처럼 보입니다. (모르겠다. 아마도 입력 매개 변수에 대한 선언이 잘못되었을 것이다.) – Jack88PD