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;

            }

  • 相关阅读:
    CF1051D Bicolorings dp
    loj2480 [CEOI2017]One-Way Streets 边双+树上差分
    有趣的支配树
    AtCoder Regular Contest 81
    [BZOJ5305][HAOI2018]苹果树(DP)
    [BZOJ4699]树上的最短路(最短路+线段树)
    [BZOJ3507][CQOI2014]通配符匹配(DP+Hash)
    [Luogu4724][模板]三维凸包(增量构造法)
    [BZOJ5317][JSOI2018]部落战争(闵可夫斯基和)
    [WC2014]时空穿梭(莫比乌斯反演)
  • 原文地址:https://www.cnblogs.com/059212315/p/2295876.html
Copyright © 2011-2022 走看看