1. Return to the. ascx page
1. Create an action
Public actionresult ascx ()
{
Return partialview (); // return some views
}
2. Create a View File
Then, access the display result through http: // localhost: 4116/admin/ascx.
Ii. return text content
Public actionresult text ()
{
Return content ("this is a piece of text ");
}
3. Return a serialized JSON result
Public actionresult showjson ()
{
Mvcapplication2.models. member M = new mvcapplication2.models. Member ();
M. Name = "James ";
M. Sex = "male ";
M. Age = "24 ";
Return JSON (m );
}
Output result {"name": "ZOU Jian", "sex": true} Note: This is not verified.
4. Output JS files
Most JS files are static files, but sometimes JS files may need to be dynamically generated. In this case, we can output
public ActionResult Js() { return JavaScript("var x=0;"); }
We can access it to get a normal page, but its content-type: Application/X-JavaScript; charset = UTF-8
V. page Jump
1. Jump to URL
public ActionResult rdurl() { return Redirect("http://www.baidu.com"); }
2. Jump to action
public ActionResult rdaction() { return RedirectToAction("Index","Eice"); }
3. Jump to the routing rule
Public actionresult rdrouting () {return redirecttoroute ("default", // route name New {controller = "eice", Action = "Index "});}6. Display files
Public actionresult FN () {return file ("/content/site.css" // file path, "text/CSS" // file type );}
Previous Article: ASP. net mvc two actionresult Return Value