我修改了asp.net web处理程序并将其部署在服务器上。
处理程序使用静态XML文件在本地计算机上运行greate但是 部署时会出现IIS 500错误。
是否有可用于修改我的代码以运行的示例 实时数据源?
这是我用于静态文件的内容:
WebRequest req = null; WebResponse rsp = null; 尝试 { string uri =“https://mytestSite.com/Test_Handler.ashx”;
req = WebRequest.Create(uri);
req.Method = "POST"; // Post method
req.ContentType = "text/xml"; // content type
// Wrap the request stream with a text-based writer
StreamWriter writer = new StreamWriter(req.GetRequestStream());
// Write the XML text into the stream
//StreamReader reader = new StreamReader(Server.MapPath("~/20121129-0121-1.xml"));
-- Would this line capture the stream ????????
StreamReader reader = new StreamReader(req.GetRequestStream());
string ret = reader.ReadToEnd();
reader.Close();
writer.WriteLine(ret);
writer.Close();
// Send the data to the webserver
rsp = req.GetResponse(); //Calls the handler code
StreamReader sr = new StreamReader(rsp.GetResponseStream());
string responseString = sr.ReadToEnd();
sr.Close();