public IActionResult PostBonjourForm(string language = "English", string name = "Anonymous") { //get the greeting cookie and increment string cookieName = "greetings"; int greetingCount = 0; string cookieCount; if (Request.Cookies.TryGetValue(cookieName, out cookieCount)) { greetingCount = int.Parse(cookieCount); } greetingCount += 1; // build the html response StringBuilder html = new StringBuilder(); html.Append("<h1 style ='color:red;font-family:Arial;' />") .Append(HelloMessage.CreateMessage(language, name)) .Append(string.Format("<h2>{0} total greetings have been generated!</h2>", greetingCount)) .Append("</h1>"); // set the greetings cookie Response.Cookies.Append(cookieName, greetingCount.ToString()); return(Content(html.ToString(), "text/html")); }
public IActionResult PostBonjourForm2(string language = "English", string name = "Anonymous") { return(Content(HelloMessage.CreateMessage(language, name), "text/html")); }