简体   繁体   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.”

I'm getting this error while trying to post data to a hosted web application from a windows service. 尝试从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)
            {

            }

This is code snippet of my windows service which posts data to web application. 这是我的Windows服务的代码片段,该片段将数据发布到Web应用程序。 Does any one know the reason.I'm using asp .Net C# 有人知道原因吗?我正在使用ASP .Net C#

Compare your request from C# with one done in a browser. 将您在C#中的请求与在浏览器中完成的请求进行比较。

Use fiddler to do this. 使用提琴手来做到这一点。

You should be able to compare everything from header values, to complete post data, etc. and be able to figure out what you have missing. 您应该能够比较所有内容,包括标头值,完整的帖子数据等,并能够找出丢失的内容。 I would suspect you are leaving out required a value and the server application is throwing a (likely unexpected) exception. 我怀疑您遗漏了必需的值,并且服务器应用程序抛出了(可能是意外的)异常。

Finally i got wat was missing.Actually i was posting data to the web application and reading it using Request.QueryString......Which is actually how Get Method is read.So modified my code as 最终我不见了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.

相关问题 远程服务器返回错误:(500)内部服务器错误Web服务 - The remote server returned an error: (500) Internal Server Error Web service 远程服务器返回错误:(500)Internal Server Error。 - The remote server returned an error: (500) Internal Server Error. Web API:远程服务器返回错误。 (500内部服务器错误。 仅在联机时,不在本地计算机中 - Web API : The remote server returned an error. (500) Internal Server Error. Only when online and not in Local Machine ASMX Web服务和远程服务器返回错误:(500)内部服务器错误问题 - ASMX web service and The remote server returned an error: (500) Internal Server Error issue 远程服务器返回错误:(500)Internal Server Error。 GetRequest()C# - The remote server returned an error: (500) Internal Server Error. GetRequest() C# System.Net.WebException:远程服务器返回错误:(500)内部服务器错误。 - System.Net.WebException: The remote server returned an error: (500) Internal Server Error. Mandrill : 远程服务器返回错误:(500) 内部服务器错误 - Mandrill : The remote server returned an error: (500) internal server error 远程服务器返回错误:(500)网站上的内部服务器错误 - The remote server returned an error: (500) Internal Server Error on website 处理远程服务器返回错误:(500)内部服务器错误 - Handling The remote server returned an error: (500) Internal Server Error 未处理WEBException:远程服务器返回错误:(500)内部服务器错误 - WEBException was unhandled: The remote server returned an error: (500) Internal Server Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM