Skip to content

Instantly share code, notes, and snippets.

@lionhylra
Created November 2, 2013 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lionhylra/7275878 to your computer and use it in GitHub Desktop.
Save lionhylra/7275878 to your computer and use it in GitHub Desktop.
controller
public string Welcome(string name, int numTimes = 1) {
return HttpUtility.HtmlEncode("Hello " + name + ", NumTimes is: " + numTimes);
}
public ActionResult SearchIndex(string searchString)
{
var movies = from m in db.Movies
select m;
if (!String.IsNullOrEmpty(searchString))
{
movies = movies.Where(s => s.Title.Contains(searchString));
}
return View(movies);
}
@model MvcMovie.Models.Movie
@{
ViewBag.Title = "Welcome";
}
<h2>Welcome</h2>
<ul>
@for (int i=0; i < ViewBag.NumTimes; i++) {
<li>@ViewBag.Message</li>
}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment