コード例 #1
0
        public ActionResult BindToChildViewModel(ModelBinderViewModel viewModel)
        {
            var json = JsonConvert.SerializeObject(viewModel, Formatting.Indented);

            Debugger.Break();
            return(this.Content(json));
        }
コード例 #2
0
        // White list
        public ActionResult BindToViewModelInclude([Bind(Include = nameof(ModelBinderViewModel.Name))] ModelBinderViewModel viewModel)
        {
            var data = this.HttpContext.Request.Form;
            var json = JsonConvert.SerializeObject(viewModel, Formatting.Indented);

            Debugger.Break();
            return(this.Content(json));
        }
コード例 #3
0
        public ActionResult BindToChild(ModelBinderViewModel viewModel)
        {
            if (this.ModelState.IsValid)
            {
                var json = JsonConvert.SerializeObject(viewModel, Formatting.Indented);
                return(this.Content(json));
            }

            return(this.View(viewModel));
        }
コード例 #4
0
        public ActionResult JsonModelBinder([ModelBinder(typeof(JsonModelBinder))] ModelBinderViewModel viewModel)
        {
            if (this.ModelState.IsValid)
            {
                Debugger.Break();

                var json = JsonConvert.SerializeObject(viewModel, Formatting.Indented);
                return(this.Content(json));
            }

            return(this.View(this.HttpContext.Request.Form[nameof(JsonViewModel.Json)]));
        }
コード例 #5
0
 public ActionResult BasicMappingForm(ModelBinderViewModel model)
 {
     return(this.Json(model));
 }