【发布时间】:2016-07-23 12:06:58
【问题描述】:
我在将 html 标记从我的 Angular 应用程序发布到我的 ASP.NET Web 服务时遇到问题。我发现我可能不得不对其进行编码。但即使使用编码,我也会收到内部服务器错误 500。 如果我只是为 postcontent 变量分配一个值,例如 postcontent="test" 它会完美地发布到 web 服务。
我已经记录并提醒 postcontent 变量,看看它是否被编码并且确实如此。
很明显,网络服务没有收到我的 html 字符串,我想知道为什么。下面是我的代码 $scope.CreatePost = function () {
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);
});
}
[网络方法]
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();
}*/
}
【问题讨论】:
标签: c# asp.net angularjs web-services post