将HTML字符串作为参数发布到ASP.NET webservice

问题描述:

我有一个问题,从我的角度应用程序发布html标记到我的ASP.NET Webservice。我想通了,我可能不得不编码它。但即使与编码我得到一个内部服务器错误500. 如果我只是给postcontent变量赋值像postcontent =“test”它完全发布到web服务。将HTML字符串作为参数发布到ASP.NET webservice

我已经记录并提醒postcontent变量,看它是否得到编码,它确实。

很明显,web服务不接受我的html字符串,我想知道为什么。下面是我的代码 $ scope.CreatePost =函数(){

 var graveId = $location.search()['gravid']; 

     // get CKEDITOR value is structured like <p>placeholder</p> 
     var getcontent = CKEDITOR.instances['postEditor'].getData(); 
     var postcontent = escape(getcontent); 

     $http({ 
      method: 'POST', 
      url: 'http://localhost:51113/WebService.asmx/OpretPost', 
      data: "username=" + userName + "&password=" + passWord + "&graveId=" + graveId + "&content=" + postcontent, 
      headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8' } 
     }).then(function (response) { 
      console.log(response.data); 

     }); 
    } 

[的WebMethod]

public void OpretPost(string username, string password, string graveId, string content) 
{ 
    /*Context.Response.Write(content); 
    var Customer = (from x in db._Users where x.UserPassword == password && x.UserName == username select x); 
    if (Customer.Count() > 0) 
    { 
     _Post nypost = new _Post 
     { 
      FK_GraveId = int.Parse(graveId), 
      FK_UserId = Customer.Single().UserId, 
      PostContent = content, 
      PostDate = DateTime.Now 


     }; 
     db._Posts.InsertOnSubmit(nypost); 
     db.SubmitChanges(); 

    }*/ 


} 

的WebMethod有,如果你想.then在POST请求返回一个值。尝试将void更改为字符串,然后返回一个有效的字符串,例如:“OK”。

+0

Nope没有解决问题。该函数工作正常,如果postcontent变量不包含HTML,但无论如何尝试没有运气。谢谢你的提示 –