![](/img/trans.png)
[英]The remote server returned an error: (500) Internal Server Error Web service
[英]Error While posting Data to a web application from a windows service.“The remote server returned an error: (500) Internal Server Error.”
嘗試從Windows服務將數據發布到托管的Web應用程序時出現此錯誤。
PostSubmitter post = new PostSubmitter();
post.Url = "http://192.168.0.1/Invoice/Invoice1.aspx";
post.PostItems.Add("subscriberid", subscriberid.ToString());
post.PostItems.Add("StartDate", StartDate);
post.PostItems.Add("EndDate", EndDate);
post.PostItems.Add("AdvanceBillDate", AdvanceBillDate);
post.Type = PostSubmitter.PostTypeEnum.Post;
try
{
string res = post.Post();
}
catch (Exception exp)
{
}
這是我的Windows服務的代碼片段,該片段將數據發布到Web應用程序。 有人知道原因嗎?我正在使用ASP .Net C#
將您在C#中的請求與在瀏覽器中完成的請求進行比較。
使用提琴手來做到這一點。
您應該能夠比較所有內容,包括標頭值,完整的帖子數據等,並能夠找出丟失的內容。 我懷疑您遺漏了必需的值,並且服務器應用程序拋出了(可能是意外的)異常。
最終我不見了wat。實際上我是在將數據發布到Web應用程序中並使用Request.QueryString讀取它......實際上是讀取Get Method的方式,因此將我的代碼修改為
PostSubmitter post = new PostSubmitter();
post.Url = "http://192.168.0.1/Invoice/Invoice1.aspx";
post.PostItems.Add("subscriberid", subscriberid.ToString());
post.PostItems.Add("StartDate", StartDate);
post.PostItems.Add("EndDate", EndDate);
post.PostItems.Add("AdvanceBillDate", AdvanceBillDate);
post.Type = PostSubmitter.PostTypeEnum.Get;
try
{
string res = post.Post();
}
catch (Exception exp)
{
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.