// GET: /Home/RedirDemo
public ActionResult RedirDemo()
{
//連結
return RedirectToAction("Index");
}
// GET: /Home/ContentDemo
public ActionResult ContentDemo()
{
//傳XML
return Content("<xml>xml demo</xml>", "text/xml");
}
public ActionResult FileContentDemo()
{
string path = Server.MapPath("~/contents/customers.xml");
TextReader reader = new StreamReader(path);
string output = reader.ReadToEnd();
//傳檔案
return Content(output, "text/xml");
}
public ActionResult GetVideo()
{
//MP4
return File("~/contents/movie.mp4","video/mp4");
}
public ActionResult JsonDemo()
{
//傳JSON
return Json(new { name = "mark", age = 22 },
JsonRequestBehavior.AllowGet);
}
0 意見:
張貼留言