Exception in template (Designs\SkanskaMaskin\Paragraph\apply_course_attendants.cshtml): System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Int16.Parse(String s, NumberStyles style, NumberFormatInfo info)
   at System.Convert.ToInt16(String value)
   at CompiledRazorTemplates.Dynamic.cddbcaeccceff.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
@using Newtonsoft.Json; @using Newtonsoft.Json.Linq; @using System.IO; @using System.Web; @using Softgear.SkanskaMaskin.Data.Business @{ var hbh = new HandleBarsHelper(); String input = new StreamReader(HttpContext.Current.Request.InputStream).ReadToEnd(); HttpContext.Current.Response.Cookies.Add(new HttpCookie("applyCourse", input)); JObject json = new JObject(); try { json = JObject.Parse(input); } catch (Exception e) { @e.Source <br /> @e.Message <br /> @e.StackTrace } var courseCompany = HttpContext.Current.Server.UrlDecode(Convert.ToString(json["course-company"])); var orgnrCompany = HttpContext.Current.Server.UrlDecode(Convert.ToString(json["orgnr-company"])); var courseContact = HttpContext.Current.Server.UrlDecode(Convert.ToString(json["course-contact"])); var courseEmail = HttpContext.Current.Server.UrlDecode(Convert.ToString(json["course-email"])); var coursePhone = HttpContext.Current.Server.UrlDecode(Convert.ToString(json["course-phone"])); var numOfAttendants = Convert.ToInt16(HttpContext.Current.Server.UrlDecode(Convert.ToString(json["att-num"]))); var courseMessage = HttpContext.Current.Server.UrlDecode(Convert.ToString(json["course-message"])); var courseName = HttpContext.Current.Server.UrlDecode(Convert.ToString(json["selectedCourse"])); var selectedStore = HttpContext.Current.Server.UrlDecode(Convert.ToString(json["selectedStore"])); } <form action="/form/apply_course/confirm" class="js-overlayForm" method="post"> <input type="hidden" name="course-company" value="@courseCompany"/> <input type="hidden" name="orgnr-company" value="@orgnrCompany" /> <input type="hidden" name="course-contact" value="@courseContact" /> <input type="hidden" name="course-email" value="@courseEmail" /> <input type="hidden" name="course-phone" value="@coursePhone" /> <input type="hidden" name="att-num" value="@numOfAttendants" /> <input type="hidden" name="course-message" value="@courseMessage" /> <input type="hidden" name="course-name" value="@courseName" /> <input type="hidden" name="selectedStore" value="@selectedStore" /> <div class="Grid Grid--equalPush"> <div class="Grid-cell"> <div class="Grid Grid--withGutter"> <div class="Grid-cell u-sizeFull"> <h2 class="Type-h1">Uppgifter om deltagare</h2> </div> <div class="Grid-cell u-sizeFull u-md-size1of2 u-lg-size1of2"> <p>Fyll i uppgifter om deltagarna för att snabba på anmälan.</p> </div> </div> </div> <div class="Grid-cell"> <div class="Grid Grid--withGutter"> <div class="Grid-cell u-sizeFull"> <div class="Type"> <h3 class="Type-h3">Deltagare</h3> </div> </div> @for (var i = 0; i < numOfAttendants; i++) { <div class="Grid-cell u-sizeFull u-md-size1of2 u-lg-size1of2"> @hbh.createInputHtml(string.Format("attendant-name-{0}", i + 1), "Namn", "text", false) </div> <div class="Grid-cell u-sizeFull u-md-size1of2 u-lg-size1of2"> @hbh.createInputHtml(string.Format("attendant-pnr-{0}", i + 1), "Personnummer (8-10 siffror)", "text", false) </div> } </div> </div> <div class="Grid-cell"> <div class="Grid Grid--withGutter"> <div class="Grid-cell u-sizeFull u-textRight"> <button class="Button" type="submit">Anmäl intresse</button> </div> </div> </div> </div> </form>