• Chrome 31版本导出Excel问题


    环境:本地测试用的http协议,部署到生产环境的协议是https

    用Response.Redirt跳转页面的时候会发生两种协议之间跳转的问题。

    为了解决这个问题我想到首先获得访问页面是使用上面两个协议的哪一种

    获取协议方法

      protected string CheckHttps()
        {
            int loop1;
            string result = "";
            NameValueCollection coll = Request.ServerVariables;
            string[] arr1 = coll.AllKeys;
            for (loop1 = 0; loop1 < arr1.Length; loop1++)
            {
                if (arr1[loop1] == "HTTPS") { string[] arr2 = coll.GetValues(arr1[loop1]); result = Server.HtmlEncode(arr2[0]); return result; }
            }
            return result;
        }
    

    获取网站的域名的方法

    protected string GeHTTP_HOST()
        {
            int loop1;
            string result = "";
            NameValueCollection coll = Request.ServerVariables;
            string[] arr1 = coll.AllKeys;
            for (loop1 = 0; loop1 < arr1.Length; loop1++)
            {
                if (arr1[loop1] == "HTTP_HOST") { string[] arr2 = coll.GetValues(arr1[loop1]); result = Server.HtmlEncode(arr2[0]); return result; }
            }
            return result;
        }
    

     最后在在跳转的时候进行判断

      string url = string.Empty;
            if (CheckHttps() == "on" || CheckHttps() == "")
            {
                url = "http://" + GeHTTP_HOST() + "/b2badmin/Export2010.aspx?op=SR";
            }
           if (CheckHttps() == "off" )
            {
                url = "https://" + GeHTTP_HOST() + "/b2badmin/Export2010.aspx?op=SR";
            }
            Response.Redirect(url);
    
  • 相关阅读:
    oss blob上传
    app中画一条细线
    antd和原生交互,原生掉前端的方法
    -webkit-touch-callout 图片下载
    ifram嵌入网址 有跨域问题
    ...state
    数组对象的复制
    在vue中使用tinymce组件
    autofs自动挂载服务
    podmen
  • 原文地址:https://www.cnblogs.com/youhaoxinqin/p/3483913.html
Copyright © 2020-2023  润新知