亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        WEB項(xiàng)目后端跨域請(qǐng)求

        字號(hào):


            using System;
            using System.Collections.Generic;
            using System.IO;
            using System.Linq;
            using System.Net;
            using System.Text;
            using System.Web;
            using System.Web.SessionState;
            namespace GL
            {
            public class CrossDomainHandler:IHttpModule, IRequiresSessionState
            {
            ///
            /// 釋放內(nèi)存
            ///
            public void Dispose()
            {
            }
            ///
            /// 開(kāi)始請(qǐng)求
            ///
            ///
            public void Init(HttpApplication context)
            {
            //頁(yè)面開(kāi)始請(qǐng)求時(shí),綁定時(shí)間
            context.BeginRequest += new EventHandler(context_PreRequestHandlerExecute);
            }
            ///
            /// 請(qǐng)求處理
            ///
            ///
            ///
            void context_PreRequestHandlerExecute(object sender, EventArgs e)
            {
            HttpApplication app = (HttpApplication)sender;
            HttpContext context = app.Context;
            context.Response.AppendHeader("charset", "utf-8");
            context.Response.AppendHeader("defaultCharset", "utf-8");
            context.Response.AppendHeader("Content-Type", "text/html; charset=utf-8");
            var relativeAddr = context.Request.AppRelativeCurrentExecutionFilePath.Remove(0, 2);
            if (relativeAddr.StartsWith("Server"))
            {
            var url = string.Concat("", relativeAddr.Substring(relativeAddr.IndexOf('/')));
            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            var rs = request.GetRequestStream();
            var sb = new StringBuilder("a=a&");
            context.Request.Form.AllKeys.ToList().ForEach(name =>
            {
            sb.AppendFormat("{0}={1}&", name, context.Request.Form[name]);
            });
            var str = sb.ToString();
            if(str.Contains('&'))
            {
            str = str.Substring(0, str.Length - 1);
            }
            var sw = new StreamWriter(rs, Encoding.UTF8);
            sw.Write(sb.ToString());
            sw.Close();
            request.Timeout = 60 * 1000;
            var response = request.GetResponse() as HttpWebResponse;
            var ps = response.GetResponseStream();
            var reader = new StreamReader(ps, Encoding.UTF8);
            string html = reader.ReadToEnd();
            ps.Close();
            context.Response.Write(html);
            context.Response.End();
            }
            }
            }
            }