コード例 #1
0
        public ActionResult Awesome()
        {
            var model = new Awesome {
                date = DateTime.UtcNow.ToShortDateString(),
                id = "awesomwe_id",
                message = "hey you are seeing this in message"
            };

            return RespondTo(format => {
                format.Default = RedirectToAction("show");
                format.Json = () => {
                    model.id = "awesome_json";
                    return Json(model, JsonRequestBehavior.AllowGet);
                };
                format.Xml = () => {
                    model.id = "awesome_xml";
                    return Xml(model);
                };
                format["yml"] = () => {
                    model.id = "awesome_yml";
                    return View("awesome.yml", model);
                };
                format.Html = () => {
                    Flash.Success("Nothing to see here");
                    return RedirectToAction("show");
                };
            });
        }
コード例 #2
0
        public ActionResult Awesome()
        {
            var model = new Awesome {
                date    = DateTime.UtcNow.ToShortDateString(),
                id      = "awesomwe_id",
                message = "hey you are seeing this in message"
            };

            return(RespondTo(format => {
                format.Any(() => RedirectToAction("show"));
                format.Json(() => {
                    model.id = "awesome_json";
                    return Json(model, JsonRequestBehavior.AllowGet);
                });
                format.Xml(() => {
                    model.id = "awesome_xml";
                    return Xml(model);
                });
                format.Mime("yml", () => {
                    model.id = "awesome_yml";
                    return View("awesome.yml", model);
                });
                format.Html(() => {
                    Flash.Success("Nothing to see here");
                    return RedirectToAction("show");
                });
            }));
        }