2011-09-30 73 views
0

我在尝试从Windows服务向托管的Web应用程序发布数据时出现此错误。从Windows服务向Web应用程序发布数据时发生错误。“远程服务器返回错误:(500)内部服务器错误。”

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#知道reason.I'm

+1

这就是网络服务器。你写了那个应用程序吗? –

+0

雅我做到了,但是当我尝试加载Web应用程序直接frm浏览器它工作正常..... – iJade

+1

查看该应用程序的日志。 –

回答

0

最后我得到笏是missing.Actually我使用的Request.QueryString ......这实际上是如何获取的方法是修改read.So我的代码为

数据发布到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.Get; 
     try 
     { 
      string res = post.Post(); 
     } 
     catch (Exception exp) 
     { 

     } 
1

比较从C#您的要求与一个在浏览器中完成的。

使用fiddler来做到这一点。

您应该能够比较标题值的所有内容,完成发布数据等,并能够弄清楚您缺少的内容。我会怀疑你正在离开需要一个值,并且服务器应用程序正在抛出一个(可能意外的)异常。

+0

我试图在浏览器中的帖子url链接,它工作正常,没有任何抛出任何异常..... – iJade

+0

使用小提琴来比较工作请求与您的代码。这是一个Http“调试器”。 – jonathanpeppers

相关问题