• WebClient发送Post请求实例


    List<BaseModuleEntity> returnResult = new List<BaseModuleEntity>();
                try
                {
                    string url = System.Configuration.ConfigurationManager.AppSettings["LogonService"] + "/PermissionService.ashx";
                    
                    WebClient webClient = new WebClient();
                    NameValueCollection postValues = new NameValueCollection();
                    postValues.Add("Function", "GetPermissionList");
                    postValues.Add("UserInfo", userInfo.Serialize());
                    postValues.Add("SystemCode", systemCode);
                    postValues.Add("fromCache", false.ToString());
                    // 向服务器发送POST数据
                    byte[] responseArray = webClient.UploadValues(url, postValues);
                    string response = Encoding.UTF8.GetString(responseArray);
                    if (!string.IsNullOrEmpty(response))
                    {
                        JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                        returnResult = javaScriptSerializer.Deserialize<List<BaseModuleEntity>>(response);
                        returnResult = returnResult.OrderBy(t => t.SortCode).ToList();
                        HttpContext.Current.Session[permissionKey] = returnResult;
                    }
                }
                catch (Exception ex)
                {
                    Log.Write(ex.ToString());
                }
                return returnResult;
  • 相关阅读:
    【项目】项目75
    【项目】项目74
    【项目】项目73
    【项目】项目72
    【项目】项目71
    【项目】项目70
    【项目】项目69
    【项目】项目68
    【项目】项目67
    .Net随笔:解决VS2008,重新生成解决方案,很慢
  • 原文地址:https://www.cnblogs.com/sharing1986687846/p/10307062.html
Copyright © 2020-2023  润新知