<%@ WebHandler Language="c#" Class="FormProxy" Debug="true" %>
using System;
using System.Web;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Configuration;


using System.Data;

using System.Text;

using System.Web.Security;

using System.Web.UI;

using System.Net;

public class FormProxy : IHttpHandler  //实现这个接口，意味着要实现该接口的两个方法： ProcessRequest和 IsReusable
{


    public void ProcessRequest(HttpContext context)
    {

       context.Response.ContentType = "text/plain";

       // String callbackFunName = context.Request["callbackparam"];


       // string sdf = HttpUtility.UrlDecode(context.Request["plshObj"]);
       //string  sdfsdf = HttpUtility.UrlDecode(sdf);
       //string sdfaasasas = HttpUtility.UrlDecode(context.Request.Form["ffff"]);
       //string sdasasasf = HttpUtility.UrlDecode(context.Request["Publish_ModuleTypeId"]);
       //string ssssdf = HttpUtility.UrlDecode(context.Request.Form["Publish_RunObj"]);
       //string saaadf = HttpUtility.UrlDecode(context.Request.Form["Publish_ModuleTypeId"]);
       //  context.Response.Write(callbackFunName + "([ { name:\"John\"}])");
       //  context.Response.End();

         //url = context.Request.Params["URL"].ToString();

         string url = context.Request.Params["myURL"].ToString();

        string clientversion = context.Request["ClientVersion"].ToString();

        string customservice = string.Empty;

        string URL = string.Empty;

        //if (context.Request["CustomService"] != null)//注意不能要form的参数
        //{

        //    customservice = context.Request["CustomService"].ToString();

        //    URL = url + "&CustomService=" + customservice + "&ClientVersion=" + clientversion;

        //}
        //else
        //{

        //    URL = url + "&ClientVersion=" + clientversion;

        //}
        URL = url;
        //string arcxml = HttpUtility.UrlDecode(context.Request["Publish_RunObj"].ToString());
        string arcxml = context.Request["Publish_RunObj"].ToString();

        byte[] postBytes =  Encoding.UTF8.GetBytes(arcxml);



        string result = string.Empty;

        HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create(URL);

        HttpWReq.Method = "Post";

        HttpWReq.ContentType = "application/x-www-form-urlencoded";

        HttpWReq.ContentLength = postBytes.Length;

        using (Stream reqStream = HttpWReq.GetRequestStream())
        {

            reqStream.Write(postBytes, 0, postBytes.Length);

        }



        HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();

        StreamReader reader = new StreamReader(HttpWResp.GetResponseStream(), Encoding.UTF8);

        result = reader.ReadToEnd();

        //HttpWResp.Close();
        context.Response.Write(result);
        context.Response.Flush();

        context.Response.End();

    }

    public bool IsReusable
    {
        get
        {
            return true ;
        }
    }

}
