asp.net Web ハンドラーを変更し、サーバーにデプロイしました。
ハンドラーは、静的 XML ファイルを使用してローカル コンピューターでうまく動作しますが、展開すると 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();