jquery ajax 调用web api传递复杂参数

前台

@{
    Layout = null;
}





    
    Index
    
    


    

后台

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace MvcApplication21.Controllers
{
    public class TestController : ApiController
    {
        /// 
        /// post /api/Test/AddSchool
        /// 
        [HttpPost]
        public SchoolModel AddSchool(SchoolModel item)
        {
            return item;
        }
    }
    public class SchoolModel : School
    {
        public List Students { get; set; }
    }
    public class School
    {
        public int SchoolID { get; set; }
        public string SchoolName { get; set; }
    }
    public class Student
    {
        public int StudentID { get; set; }
        public string StudentName { get; set; }
        public int SchoolID { get; set; }
    }
}


你可能感兴趣的:(c#,web)