ashx文件相关

来源:互联网 发布:拳皇13优化 编辑:程序博客网 时间:2024/05/17 09:26
 
 
javascript 脚本读取
 
<script type="text/javascript">
     function CreateXMLHttpRequest(){
     try {
            xmlHttp = new ActiveXObject("Microsoft.XmlHttp");
         } 
         catch (e)
         { 
             xmlHttp = new XMLHttpRequest(); 
         }
      }
      CreateXMLHttpRequest();
      xmlHttp.open("get","aHandler.ashx?MAP=123455&MAP1=yyyyyy",false);
      xmlHttp.Send(null);
      var ls=xmlHttp.responseText;
        alert(ls);
</script>
 
C#读取
 
string url = Request.Url.ToString().Substring(0,Request.Url.ToString().LastIndexOf("/")+1)  + "aHandler.ashx?MAP=cs&MAP1=sc";
        WebRequest req = WebRequest.Create(url);
        WebResponse res = req.GetResponse();    // GetResponse blocks until the response arrives
        Stream ReceiveStream = res.GetResponseStream();    // Read the stream into a string
        StreamReader sr = new StreamReader(ReceiveStream);
        string resultstring = sr.ReadToEnd();
        Response.Write(resultstring);
 
aHandler.ashx
        string a = context.Request.Params["MAP"];  //获取参数
        string b = context.Request.Params["MAP1"];
        context.Response.ContentType = "text/plain";
        context.Response.Write(a+b);
原创粉丝点击