Error executing template "/Designs/Rapido/Paragraph/AddOtherAddress.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_6f920f3a8f364a98a32cadba67fb4f0b.Execute() in C:\Website\Solutions\Files\Templates\Designs\Rapido\Paragraph\AddOtherAddress.cshtml:line 18
   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 @{ 2 string outlet_name = System.Web.HttpContext.Current.Request["outlet_name"]; 3 string outlet_address = System.Web.HttpContext.Current.Request["outlet_address"]; 4 string countryCode = System.Web.HttpContext.Current.Request["country"]; 5 string city = System.Web.HttpContext.Current.Request["City"]; 6 string postal_code = System.Web.HttpContext.Current.Request["postal_code"]; 7 string firstname = System.Web.HttpContext.Current.Request["firstname"]; 8 string lastname = System.Web.HttpContext.Current.Request["lastname"]; 9 string phone_number = System.Web.HttpContext.Current.Request["phone_number"]; 10 string userID = System.Web.HttpContext.Current.Request["userId"]; 11 string state = System.Web.HttpContext.Current.Request["state"]; 12 13 14 15 16 17 Dynamicweb.Security.UserManagement.User userById = Dynamicweb.Security.UserManagement.User.GetUserByID(Convert.ToInt32(userID)); 18 if(string.IsNullOrEmpty(userById.Address)) 19 { 20 21 userById.Zip = postal_code; 22 userById.City = city; 23 userById.Country = countryCode; 24 userById.CountryCode = countryCode; 25 userById.Address = outlet_address; 26 userById.Phone = phone_number; 27 userById.State = state; 28 userById.Save(); 29 /*Dynamicweb.Security.UserManagement.UserAddress userAddress = new Dynamicweb.Security.UserManagement.UserAddress(); 30 userAddress.Name = outlet_name; 31 userAddress.UserID = Convert.ToInt32(userID); 32 userAddress.Zip = postal_code; 33 userAddress.City = city; 34 userAddress.Country = countryCode; 35 userAddress.CountryCode = countryCode; 36 userAddress.Address = outlet_address; 37 userAddress.Phone = phone_number; 38 userAddress.CallName = outlet_name; 39 userAddress.State=state; 40 userAddress.Save();*/ 41 } 42 else 43 { 44 Dynamicweb.Security.UserManagement.UserAddress userAddress = new Dynamicweb.Security.UserManagement.UserAddress(); 45 userAddress.Name = outlet_name; 46 userAddress.UserID = Convert.ToInt32(userID); 47 userAddress.Zip = postal_code; 48 userAddress.City = city; 49 userAddress.Country = countryCode; 50 userAddress.CountryCode = countryCode; 51 userAddress.Address = outlet_address; 52 userAddress.Phone = phone_number; 53 54 userAddress.State= state; 55 userAddress.Save(); 56 } 57 58 } 59 <div> Success @userID</div>