c# - An exception of type 'System.InvalidOperationException' occurred in System.Web.Extensions.dll but was not handled in user code -
Why is this error in this part of the code?
this part
var data = serializer. Dairyialize & lt; Email Template & gt; (HttpRequest.Form ["data"]. ToString ()); My process
public int UpdateEmailTemplate () {HttpResponseMessage result = zero; ObjectService Upload File = New ObjectService (); & Lt; ActiveUp.Net.Mail.Attachment & gt; Attachment = new list & lt; ActiveUp.Net.Mail.Attachment & gt; (); Var httpRequest = HttpContext.Current.Request; If (httpRequest.Form ["data"] = = null) {var serializer = new javascript serializer (); Var data = serializer. Dairyialize & lt; EmailMetPlat & gt; (HttpRequest.Form ["data"]. ToString ()); If (httpRequest.Files.Count & gt; 0) {var docfiles = new list & lt; String & gt; (); Foreach (string file in httpRequest.files) {MemoryStream target = new MemoryStream (); HttpRequest.Files [file] .InputStream.CopyTo (target); UploadFile.AddObject (data.Id, "SU_ENTITY_MSG_TEMPLATE", "", target.GetBuffer (), httpRequest.Files [File] .FileName); }} AdminService list = new AdminService (); Return list Update email template (data); } My class
public class email template {public entry id; Public string typeObject; Public int? IdObject; Public string objectName; Public string idtom; Public string idtask; Public string team; Public string functions; Public string title; Public string theme; Public string data html; Public listing & lt; Object & gt; fileListRequest; }
It is very clearly saying that:
httpRequest.Form ["data"] ... adding some sort of array. Ostring () will simply return it to the type of name. Passing to Deserialize is giving you an error, because desiarialise is expecting an array and just getting a string
Try to stop toasting () - this can not work. If you do not get it, you'll have to change the httpRequest.Form ["data"] to any type of data that you put it in (you can not say).
Comments
Post a Comment