zoukankan      html  css  js  c++  java
  • http put,delete请求


            /// <summary>
            /// PUT 方法只要IIS开启写入就可以上传文件txt/html/gif 等图片(不能asp/aspx/shtm/cer/asa/stm/
            /// 因此当网站提供IIS写入功能可以上传gif等文件然后替换原来的图片达到修改页面的目的
            /// </summary>
            /// <param name="url"></param>
            /// <param name="local"></param>
            /// <returns></returns>
            public static bool UpLoadFile(String url, String local)
            {
                try
                {
                    System.Net.WebClient myWebClient = new System.Net.WebClient();
                    byte[] ret = myWebClient.UploadFile(url, "DELETE", local);
                    String strMessage = Encoding.ASCII.GetString(ret, 0, ret.Length);
                }
                catch (Exception exp)
                {
                    throw exp;
                }
                return true;

            }
            /// <summary>
            /// DELETE 方法只要IIS开启写入就可以删除文件txt/html/gif  等图片(不能asp/aspx/shtm/cer/asa/stm/
            /// </summary>
            /// <param name="url"></param>
            /// <param name="local"></param>
            /// <returns></returns>

            public static bool DeleteFile()
            {
                try
                {
                    System.Net.WebClient myWebClient = new System.Net.WebClient();

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/1.txt");
                    request.Method = "DELETE";
                    request.ContentType = "application/x-www-form-urlencoded";
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                    if (response.StatusCode == HttpStatusCode.OK)
                    {         // some code   
                    }
                }
                catch (Exception exp)
                {
                    throw exp;
                }
                return true;

            }

  • 相关阅读:
    jquery 代码搜集
    Windows Server 2008中安装IIS7.0
    javascript 判断两个日期之间的天数 兼容ie,firefox
    jquery选择器大全
    原始ajax方式调用asp.net后台方法
    JavaScript及C# URI编码详解
    利用JQuery直接调用asp.net后台方法
    C#操作XML小结_转载
    从bnbt tracker源码分析bt客户端与traker的通信
    传说中的神器: shared_ptr/weak_ptr/scoped_ptr
  • 原文地址:https://www.cnblogs.com/059212315/p/2295876.html
Copyright © 2011-2022 走看看