Error executing template "DataManagement/Forms/Form/Stemmeseddel_2018.cshtml"
Newtonsoft.Json.JsonReaderException: Error reading JObject from JsonReader. Path '', line 0, position 0.
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
   at CompiledRazorTemplates.Dynamic.RazorEngine_6a0bd09303a34fedab28592a2198e9e1.Execute() in D:\home\site\wwwroot\Files\Templates\DataManagement\Forms\Form\Stemmeseddel_2018.cshtml:line 22
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @using System.Net 2 @using System.Text 3 @using System.Web 4 @{ 5 var designBaseUrl = GetString("Template:DesignBaseUrl"); 6 7 var formId = GetString("Form.ID"); 8 var formName = GetString("Form.Name"); 9 var formCH1_h = Dynamicweb.Core.Helpers.StringHelper.Md5HashToString(Dynamicweb.Context.Current.Session.SessionID + "dwdotnetsecret"); 10 11 var voteKey = HttpContext.Current.Request["votekey"]; 12 var objJson = default(Newtonsoft.Json.Linq.JObject); 13 14 using (var wc = new WebClient()) { 15 wc.Encoding = Encoding.UTF8; 16 17 wc.Headers.Add("user-agent", "Tjlaan"); 18 19 wc.QueryString.Add("method", "list"); 20 wc.QueryString.Add("votekey", voteKey); 21 22 objJson = Newtonsoft.Json.Linq.JObject.Parse(wc.DownloadString("http://padform.dk/vote/vote.php").Trim()); 23 } 24 } 25 26 <style type="text/css"> 27 #form@(formId) .has-feedback .form-control { padding-right: 12px; } 28 #form@(formId) hr { border-top-color: #455D11; } 29 </style> 30 31 @if (!((bool)objJson["success"])) { 32 <h2>@((string)objJson["message"])</h2> 33 } else { 34 var objBestyrelse = objJson["BESTYRELSE"]; 35 var objRevisor = objJson["REVISOR"]; 36 37 var minBestyrelse = (int)objJson["MIN4BESTYRELSE"]; 38 var maxBestyrelse = (int)objJson["MAX4BESTYRELSE"]; 39 var minRevisor = (int)objJson["MIN4REVISOR"]; 40 var maxRevisor = (int)objJson["MAX4REVISOR"]; 41 42 <form id="form@(formId)" method="post" action="/Default.aspx?Id=@(Pageview.Page.ID)" enctype="multipart/form-data" class="form-horizontal"> 43 @(GetValue("Form.Hidden")) 44 45 <div class="row"> 46 <div class="col-xs-offset-1 col-xs-11"> 47 <h2>@((string)objJson["DESCRIPTION"])</h2> 48 </div> 49 </div> 50 51 <hr> 52 53 @* 54 <div class="row"> 55 <div class="col-xs-offset-1 col-xs-11"> 56 <strong>Navn:</strong> @((string)objJson["NAME"]) 57 </div> 58 </div> 59 60 <hr style="visibility: hidden;"> 61 *@ 62 63 <div class="row"> 64 <div class="col-xs-offset-1 col-xs-11"> 65 <h3 style="margin-bottom: 10px;">Til bestyrelsen</h3> 66 </div> 67 </div> 68 69 <div class="form-group"> 70 <div class="col-xs-offset-1 col-xs-11"> 71 @for (var i = 0; i < objBestyrelse.Count(); i++) { 72 var item = objBestyrelse[i]; 73 var itemValue = (int)item["CANDIDATE_ID"]; 74 var iName = (string)item["NAME"]; 75 var iOrganization = (string)item["ORGANIZATION"]; 76 var itemTexts = new List<string>(); 77 78 if (!string.IsNullOrWhiteSpace(iName)) { 79 itemTexts.Add(iName); 80 } 81 82 if (!string.IsNullOrWhiteSpace(iOrganization)) { 83 itemTexts.Add(iOrganization); 84 } 85 86 <div class="checkbox"> 87 <label> 88 <input type="checkbox" name="bestyrelse[]" value="@(itemValue)"> @(string.Join(" - ", itemTexts).Trim()) 89 </label> 90 </div> 91 } 92 </div> 93 </div> 94 95 <hr style="visibility: hidden;"> 96 97 <div class="row"> 98 <div class="col-xs-offset-1 col-xs-11"> 99 <h3 style="margin-bottom: 10px;">Til revisorer</h3> 100 </div> 101 </div> 102 103 <div class="form-group"> 104 <div class="col-xs-offset-1 col-xs-11"> 105 @for (var i = 0; i < objRevisor.Count(); i++) { 106 var item = objRevisor[i]; 107 var itemValue = (int)item["CANDIDATE_ID"]; 108 var iName = (string)item["NAME"]; 109 var iOrganization = (string)item["ORGANIZATION"]; 110 var itemTexts = new List<string>(); 111 112 if (!string.IsNullOrWhiteSpace(iName)) { 113 itemTexts.Add(iName); 114 } 115 116 if (!string.IsNullOrWhiteSpace(iOrganization)) { 117 itemTexts.Add(iOrganization); 118 } 119 120 <div class="checkbox"> 121 <label> 122 <input type="checkbox" name="revisor[]" value="@(itemValue)"> @(string.Join(" - ", itemTexts).Trim()) 123 </label> 124 </div> 125 } 126 </div> 127 </div> 128 129 <hr> 130 131 <div class="row"> 132 <div class="col-xs-offset-1 col-xs-11"> 133 <button type="submit" class="btn btn-default">Stem</button> 134 </div> 135 </div> 136 </form> 137 138 <script type="text/javascript"> 139 $(function() { 140 var $form = $('#form@(formId)'); 141 142 $form[0].addEventListener('submit', function(evt) { 143 evt.preventDefault(); 144 145 var minBestyrelse = @(minBestyrelse); 146 var maxBestyrelse = @(maxBestyrelse); 147 var minRevisor = @(minRevisor); 148 var maxRevisor = @(maxRevisor); 149 150 var $bestyrelses = $('input[type="checkbox"][name="bestyrelse[]"]:checked', $form); 151 var $revisors = $('input[type="checkbox"][name="revisor[]"]:checked', $form); 152 var selection = []; 153 var errors = []; 154 155 if (minBestyrelse && $bestyrelses.length < minBestyrelse) 156 errors.push('Fejl - Bestyrelse: Vælg venligst mindst ' + minBestyrelse + ' valgmuligheder.'); 157 158 if (maxBestyrelse && $bestyrelses.length > maxBestyrelse) 159 errors.push('Fejl - Bestyrelse: Vælg venligst højst ' + maxBestyrelse + ' valgmuligheder.'); 160 161 if (minRevisor && $revisors.length < minRevisor) 162 errors.push('Fejl - Revisor: Vælg venligst mindst ' + minRevisor + ' valgmuligheder.'); 163 164 if (maxRevisor && $revisors.length > maxRevisor) 165 errors.push('Fejl - Revisor: Vælg venligst højst ' + maxRevisor + ' valgmuligheder.'); 166 167 if (errors.length) { 168 alert(errors.join('\n')); 169 return; 170 } 171 172 $bestyrelses.each(function() { 173 var $elem = $(this); 174 var value = $elem.val(); 175 176 (value != '') && selection.push(+(value)); 177 }); 178 179 $revisors.each(function() { 180 var $elem = $(this); 181 var value = $elem.val(); 182 183 (value != '') && selection.push(+(value)); 184 }); 185 186 var o = @(Newtonsoft.Json.JsonConvert.SerializeObject(new { 187 voteKey, 188 formCH1_h, 189 title = (string)objJson["DESCRIPTION"], 190 navn = (string)objJson["NAME"], 191 ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? HttpContext.Current.Request.UserHostAddress, 192 browser = HttpContext.Current.Request.UserAgent 193 })); 194 195 $.ajax({ 196 type : 'POST', 197 url : '/Admin/Public/StemmeseddelHandler.ashx?methodName=Vote', 198 data : { voteKey: o.voteKey, selection: '[' + selection.join(',') + ']' }, 199 success : function(data) { 200 $('input[name="FormCH1_h"]', $form).val(o.formCH1_h); 201 $('input[name="_sys_to_email"]', $form).val(''); 202 203 $('input[name="Stemmeseddel_Title"]', $form).val(o.title); 204 $('input[name="Stemmeseddel_Navn"]', $form).val(o.navn); 205 206 $('input[name="Stemmeseddel__Dato"]', $form).val(data.Now); 207 $('input[name="Stemmeseddel__IP"]', $form).val(o.ip); 208 $('input[name="Stemmeseddel__Browser"]', $form).val(o.browser); 209 $('input[name="Stemmeseddel__Data"]', $form).val(JSON.stringify({ voteKey: o.voteKey, selection: selection })); 210 211 setTimeout(function() { 212 evt.target.submit(); 213 }, 100); 214 } 215 }); 216 }); 217 }); 218 </script> 219 } 220