繁体   English   中英

从Windows服务将数据发布到Web应用程序时出错。“远程服务器返回错误:(500)内部服务器错误。”

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM