???Asp.net MVC ?????????
???????????? ???????[ 2016/3/25 9:44:37 ] ??????????????????? ???????
????MVC???????????????á??????????????????????????WebForm?????????????MVC??????????????°?????Ч???????????Asp.net MVC???????????????????????????????????
?????????????Asp.net MVC?г????????????????????
???????ActionResult
????ActionResult?????????Action?????????asp.net mvc????????????ActionResult??????磺ContentResult??ViewResult??JsonResult??????????????????????????Response???????????????????????????????
??????????????????XML??????????б??
????public void GetUser()
????{
????var user = new UserViewModel()
????{
????Name = "richie"??
????Age = 20??
????Email = "abc@126.com"??
????Phone = "139********"??
????Address = "my address"
????};
????XmlSerializer serializer = new XmlSerializer(typeof(UserViewModel));
????Response.ContentType = "text/xml";
????serializer.Serialize(Response.Output?? user);
????}
?????????????Controller?ж??????????????????????????????????Controller?????????????MVC?????Action????????????ActionResult????????XML???л???δ?????????????á????????????????????????XmlResult?????
????public class XmlResult : ActionResult
????{
????private object _data;
????public XmlResult(object data)
????{
????_data = data;
????}
????public override void ExecuteResult(ControllerContext context)
????{
????var serializer = new XmlSerializer(_data.GetType());
????var response = context.HttpContext.Response;
????response.ContentType = "text/xml";
????serializer.Serialize(response.Output?? _data);
????}
????}
?????????Action??????????????????
????public XmlResult GetUser()
????{
????var user = new UserViewModel()
????{
????Name = "richie"??
????Age = 20??
????Email = "abc@126.com"??
????Phone = "139********"??
????Address = "my address"
????};
????return new XmlResult(user);
????}
????????????????????????????ActionResult????????磺CsvResult???
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11