Skip to content

Instantly share code, notes, and snippets.

@coreypnorris
Created May 7, 2015 18:17
Show Gist options
  • Select an option

  • Save coreypnorris/09b64c45ba6bfe4b206c to your computer and use it in GitHub Desktop.

Select an option

Save coreypnorris/09b64c45ba6bfe4b206c to your computer and use it in GitHub Desktop.
Return results in MVC controllers
namespace OdeToFood.Controllers
{
public class CuisineController : Controller
{
//
// GET: /Cuisine/
public ActionResult Search(string name)
{
var message = Server.HtmlEncode(name);
return Content(message);
return RedirectToAction("Index", "Home", new {name = "French"});
return RedirectToRoute("Default", new {controller = "Home", action = "About"});
return Json(new {firstname = "Corey", lastname = "Norris"}, JsonRequestBehavior.AllowGet);
// Note: You can use a File Result to return PDF files, spreadsheets, text files, and other content the user wants to download.
return File(Server.MapPath("~/Content/site.css"), "text/css");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment