<%@ WebHandler Language="C#" Class="MESCommonBase" %>

using System;
using System.Web;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Web.Script.Serialization;
using System.Data;
//using BizDataAccess;
using System.Data.SqlClient;
//using DbCallData;
//using BasicData;
using System.Net.Mail;
using System.Net.Mime;
using System.Timers;
using System.Xml;
using System.Net;

public class MESCommonBase : IHttpHandler
{
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
    public int message;
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string Uid = HttpContext.Current.Request["Uid"];
        string Key = HttpContext.Current.Request["Key"];
        string smsMob = HttpContext.Current.Request["smsMob"];
        string smsText = HttpContext.Current.Request["smsText"];
        try
        {
            string url = "http://utf8.api.smschinese.cn/?Uid=" + Uid + "&Key=" + Key + "&smsMob=" + smsMob + "&smsText=" + smsText;
            string relust = GetHtmlFromUrl(url);
            context.Response.Write(Convert.ToInt16(relust));

        }
        catch (Exception ex)
        {
            return;
        }
    }
    public string GetHtmlFromUrl(string url)
    {
        string strRet = null;
        if(url==null || url.Trim().ToString()=="")
        {
            return strRet;
        }
        string targeturl = url.Trim().ToString();
        try
        {
            HttpWebRequest hr = (HttpWebRequest)WebRequest.Create(targeturl);
            hr.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
            hr.Method = "GET";
            hr.Timeout = 30 * 60 * 1000;
            WebResponse hs = hr.GetResponse();
            Stream sr = hs.GetResponseStream();
            StreamReader ser = new StreamReader(sr, Encoding.Default);
            strRet = ser.ReadToEnd();
        }
        catch (Exception ex)
        {
            strRet = null;
        }
        return strRet;
    }
}
   