无法在C#中使用WebRequest发送GET参数

时间:2013-06-26 13:47:10

标签: c# webrequest

这简直就是死的。我有一个处理服务器上文件的网页。我试图调用它,只是在URL上发送文件名以启动它,但它只调用notificatin URL而不调用我的参数。我究竟做错了什么?

    private void Notify(IDictionary config, String fn)
    {

        //check to see if a notification url was specified
        if (string.IsNullOrEmpty((String)config["notificationUrl"]))
        {
            log.Warn("No 'notificationUrl' specified. No notification generated.");
        }
        else
        {

            WebRequest wr = WebRequest.Create(string.Format(config["notificationUrl"].ToString() + "?file=" + fn));
            wr.Method="GET";

            HttpWebResponse hwr = (HttpWebResponse)wr.GetResponse();
            if (hwr.StatusCode != HttpStatusCode.OK)
                throw new Exception("Upload File created, but HTTP notification url returned status code: " + hwr.StatusCode.ToString());
        }
    }

0 个答案:

没有答案