public void ProcessRequest(HttpContext context) { string result = string.Empty; if (context.Request.HttpMethod.ToUpper().Equals(GET)) { //PostHtml(); context.Response.Headers.Add("Access-Control-Allow-Methods", "GET"); context.Response.Headers.Add("Access-Control-Allow-Origin", "http://www.rrbay.xyz"); userIP = GetWebClientIp(context); context.Response.ContentType = "text/plain"; TimeSpan dspNow = DateTime.Now.TimeOfDay; string urlCheck = string.Empty; string callBack = string.Empty; if (IsInTimeInterval(dspNow, _strWorkingDayAM, _strWorkingDayPM)) { // string referrer = context.Request.UrlReferrer != null ? context.Request.UrlReferrer.Host.ToLower() : ""; callBack = string.IsNullOrEmpty(context.Request.QueryString["callback"]) ? "" : context.Request.QueryString["callback"].ToString(); //回调 if (!string.IsNullOrEmpty(context.Request["url"]) && !string.IsNullOrEmpty(callBack)) { if (!IsRedis(context)) { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + userIP + "\",\"Msg\":\"当天请求上限,请明天再试,需要讨论技术,联系管理员qq:391502069!\"}"; } else { if (!string.IsNullOrEmpty(context.Request["key"]) && context.Request["key"].Length == 32) { wxCheckApiKey = context.Request["key"]; //key ,md5值 } ServiceApiClient SpVoiceObj2 = null; // ServiceApiClient SpVoiceObj = null; try { //需要检测的网址 urlCheck = context.Request["url"]; //检测的值 bool isTrue = urlCheck.StartsWith("http"); if (!isTrue) { urlCheck = "http://" + urlCheck; } urlCheck = System.Web.HttpUtility.UrlEncode(urlCheck); string json2 = "{\"Mode\":\"AuthKey\",\"Param\":\"{\'CheckUrl\':\'" + urlCheck + "\',\'UserKey\':\'" + wxCheckApiKey + "\'}\"}"; SpVoiceObj2 = new ServiceApiClient("NetTcpBinding_IServiceApi"); SpVoiceObj2.Open(); result = SpVoiceObj2.Api(json2); SpVoiceObj2.Close(); //JsonObject.Results aup = JsonConvert.DeserializeObject<JsonObject.Results>(result); //if (aup.State == true) //{ // string json = "{\"Mode\":\"WXCheckUrl\",\"Param\":\"{\'CheckUrl\':\'" + urlCheck + "\',\'UserKey\':\'" + wxCheckApiKey + "\'}\"}"; // SpVoiceObj = new ServiceApiClient("NetTcpBinding_IServiceApi"); // SpVoiceObj.Open(); // result = SpVoiceObj.Api(json); // SpVoiceObj.Close(); //} Logger.WriteLogggerTest("#################################################"); Logger.WriteLogggerTest(userIP + ":" + wxCheckApiKey + ":" + result); Logger.WriteLogggerTest(urlCheck + ":HTTP_CDN_SRC_IP--" + context.Request.ServerVariables["HTTP_CDN_SRC_IP"]); Logger.WriteLogggerTest(urlCheck + ":HTTP_Cdn-Src-Ip--" + context.Request.ServerVariables["HTTP_Cdn-Src-Ip"]); Logger.WriteLogggerTest(urlCheck + ":Cdn-Src-Ip--" + context.Request.ServerVariables["Cdn-Src-Ip"]); Logger.WriteLogggerTest(urlCheck + ":HTTP_X_FORWARDED_FOR--" + context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]); Logger.WriteLogggerTest(urlCheck + ":Proxy-Client-IP--" + context.Request.ServerVariables["Proxy-Client-IP"]); Logger.WriteLogggerTest(urlCheck + ":WL-Proxy-Client-IP--" + context.Request.ServerVariables["WL-Proxy-Client-IP"]); Logger.WriteLogggerTest(urlCheck + ":HTTP_CLIENT_IP--" + context.Request.ServerVariables["HTTP_CLIENT_IP"]); Logger.WriteLogggerTest(urlCheck + ":HTTP_VIA--" + context.Request.ServerVariables["HTTP_VIA"]); Logger.WriteLogggerTest(urlCheck + ":REMOTE_ADDR--" + context.Request.ServerVariables["REMOTE_ADDR"]); Logger.WriteLogggerTest("=================================================="); } catch (System.ServiceModel.CommunicationException) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } } catch (TimeoutException) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } } catch (Exception ex) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + urlCheck + "\",\"Msg\":\"请求操作在配置的超时,请联系管理员!\"}"; LogTools.WriteLine(userIP + ":" + wxCheckApiKey + ":" + ex.Message); } } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + userIP + "\",\"Msg\":\"参数错误,联系管理员qq:391502069!\"}"; } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + userIP + "\",\"Msg\":\"测试接口,请在每天(08:00-21:00)时间段进行测试,需要讨论技术,联系管理员qq:391502069.\"}"; } if (!string.IsNullOrEmpty(callBack)) { result = callBack + "(" + result + ")"; } } else { result = "{\"State\":false,\"Code\",\"003\",\"Data\":\"QQ:391502069 \",\"Msg\":\"参数错误,联系管理员qq:391502069!\"}"; } context.Response.Write(result); context.Response.End(); }
public void ProcessRequest(HttpContext context) { string result = string.Empty; if (context.Request.HttpMethod.ToUpper().Equals(GET)) { userIP = GetWebClientIp(context); context.Response.ContentType = "text/plain"; TimeSpan dspNow = DateTime.Now.TimeOfDay; string urlCheck = string.Empty; if (IsInTimeInterval(dspNow, _strWorkingDayAM, _strWorkingDayPM)) { if (!string.IsNullOrEmpty(context.Request["url"])) { //需要检测的网址 urlCheck = context.Request["url"]; //检测的值 ServiceApiClient SpVoiceObj2 = null; // ServiceApiClient SpVoiceObj = null; try { bool isTrue = urlCheck.StartsWith("http"); if (!isTrue) { urlCheck = "http://" + urlCheck; } if (urlCheck.StartsWith("http://") || urlCheck.StartsWith("https://")) { urlCheck = System.Web.HttpUtility.UrlEncode(urlCheck); } string json2 = "{\"Mode\":\"AuthQQKey\",\"Param\":\"{\'CheckUrl\':\'" + urlCheck + "\',\'UserKey\':\'" + wxCheckApiKey + "\',\'UserIP\':\'" + userIP + "\',\'IsFreeKey\':1}\"}"; SpVoiceObj2 = new ServiceApiClient("NetTcpBinding_IServiceApi"); SpVoiceObj2.Open(); result = SpVoiceObj2.Api(json2); SpVoiceObj2.Close(); Logger.WriteLogggerTest("#################################################"); Logger.WriteLogggerTest(userIP + ":" + result); Logger.WriteLogggerTest(context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]); } catch (System.ServiceModel.CommunicationException) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } } catch (TimeoutException) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } } catch (Exception ex) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + urlCheck + "\",\"Msg\":\"请求操作在配置的超时,请联系管理员!\"}"; LogTools.WriteLine(userIP + ":" + wxCheckApiKey + ":" + ex.Message); } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + userIP + "\",\"Msg\":\"参数错误,联系管理员!\"}"; } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + userIP + "\",\"Msg\":\"测试接口,请在每天(08:00-21:00)时间段进行测试,需要讨论技术,联系管理员.\"}"; } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\" \",\"Msg\":\"参数错误,联系管理员!\"}"; } context.Response.Write(result); context.Response.End(); }
public void ProcessRequest(HttpContext context) { string result = string.Empty; if (context.Request.HttpMethod.ToUpper().Equals(GET)) { string urlCheck = string.Empty; context.Response.ContentType = "text/plain"; if (!string.IsNullOrEmpty(context.Request["url"]) && !string.IsNullOrEmpty(context.Request["key"]) && context.Request["key"].Length == 32) { string userKey = context.Request["key"]; //key ,md5值 if (userKey.Trim() == wxCheckApiKey) { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + urlCheck + "\",\"Msg\":\"参数错误,联系管理员qq:391502069!\"}"; } else { ServiceApiClient SpVoiceObj2 = null; // ServiceApiClient SpVoiceObj = null; try { //需要检测的网址 urlCheck = context.Request["url"]; //检测的值 bool isTrue = urlCheck.StartsWith("http"); if (!isTrue) { urlCheck = "http://" + urlCheck; } if (urlCheck.StartsWith("http://") || urlCheck.StartsWith("https://")) { urlCheck = System.Web.HttpUtility.UrlEncode(urlCheck); } string json2 = "{\"Mode\":\"AuthQQKey\",\"Param\":\"{\'CheckUrl\':\'" + urlCheck + "\',\'UserKey\':\'" + userKey + "\'}\"}"; SpVoiceObj2 = new ServiceApiClient("NetTcpBinding_IServiceApi"); SpVoiceObj2.Open(); result = SpVoiceObj2.Api(json2); SpVoiceObj2.Close(); ////JsonObject.Results aup = JsonConvert.DeserializeObject<JsonObject.Results>(result); ////if (aup.State == true) ////{ //// string json = "{\"Mode\":\"WXCheckUrl\",\"Param\":\"{\'CheckUrl\':\'" + urlCheck + "\',\'UserKey\':\'" + userKey + "\'}\"}"; //// SpVoiceObj = new ServiceApiClient("NetTcpBinding_IServiceApi"); //// SpVoiceObj.Open(); //// result = SpVoiceObj.Api(json); //// SpVoiceObj.Close(); ////} if (!string.IsNullOrEmpty(context.Request.QueryString["callback"])) { string callBack = context.Request.QueryString["callback"].ToString(); //回调 result = callBack + "(" + result + ")"; } } catch (System.ServiceModel.CommunicationException) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } } catch (TimeoutException) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } } catch (Exception ex) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + urlCheck + "\",\"Msg\":\"请求操作在配置的超时,请联系管理员!\"}"; //正式用 userIP = GetWebClientIp(context); LogTools.WriteLine(userIP + ":" + userKey + ":" + ex.Message); } } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + urlCheck + "\",\"Msg\":\"参数错误,联系管理员qq:391502069!\"}"; } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"QQ:391502069 \",\"Msg\":\"参数错误,联系管理员qq:391502069!\"}"; } context.Response.Write(result); context.Response.End(); }
public void ProcessRequest(HttpContext context) { string result = string.Empty; if (context.Request.HttpMethod.ToUpper().Equals(GET)) { string url = context.Request["url"]; string key = context.Request["key"]; //key ,md5值 string type = context.Request["type"]; //key ,md5值 context.Response.ContentType = "text/plain"; if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(key) && key.Length == 32) { ServiceApiClient SpVoiceObj = null; try { if (type.ToUpper() != "DWZCN") { if (url.StartsWith("http://") || url.StartsWith("https://")) { url = System.Web.HttpUtility.UrlEncode(url); } } string json2 = "{\"Mode\":\"ShortUrl\",\"Param\":\"{\'CheckUrl\':\'" + url + "\',\'type\':\'" + type + "\',\'UserKey\':\'" + key + "\'}\"}"; SpVoiceObj = new ServiceApiClient("NetTcpBinding_IServiceApi"); SpVoiceObj.Open(); result = SpVoiceObj.Api(json2); SpVoiceObj.Close(); if (!string.IsNullOrEmpty(context.Request.QueryString["callback"])) { string callBack = context.Request.QueryString["callback"].ToString(); //回调 result = callBack + "(" + result + ")"; } } catch (System.ServiceModel.CommunicationException) { if (SpVoiceObj != null) { SpVoiceObj.Abort(); } } catch (TimeoutException) { if (SpVoiceObj != null) { SpVoiceObj.Abort(); } } catch (Exception ex) { if (SpVoiceObj != null) { SpVoiceObj.Abort(); } result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + url + "\",\"Msg\":\"请求操作在配置的超时,请联系管理员!\"}"; LogTools.WriteLine(key + ":" + ex.Message); } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + url + "\",\"Msg\":\"参数错误,联系管理员qq:391502069!\"}"; } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"QQ:391502069 \",\"Msg\":\"参数错误,联系管理员qq:391502069!\"}"; } context.Response.Write(result); context.Response.End(); }
public void ProcessRequest(HttpContext context) { string result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"QQ:391502069 \",\"Msg\":\"参数错误,联系管理员qq:391502069!\"}"; string wxKey = wxCheckApiKey; //key ,md5值 if (context.Request.HttpMethod.ToUpper().Equals(POST)) { context.Response.ContentType = "text/plain"; string urlCheck = context.Request["url"]; string model = context.Request["model"]; if (!string.IsNullOrEmpty(urlCheck) && !string.IsNullOrEmpty(model)) { if (!string.IsNullOrEmpty(context.Request["key"]) && context.Request["key"].Length == 32) { wxKey = context.Request["key"]; //key ,md5值 } if (!wxKey.ToLower().Equals(wxCheckApiKey)) { IsFreeKey = 0; } else { IsFreeKey = 1; userIP = GetWebClientIp(context); } TimeSpan dspNow = DateTime.Now.TimeOfDay; if ((IsFreeKey == 1 && IsInTimeInterval(dspNow, _strWorkingDayAM, _strWorkingDayPM)) || IsFreeKey == 0) { // if (!urlCheck.ToLower().Contains(".casa") && !urlCheck.ToLower().Contains(".kuaizhan.com")) // { ServiceApiClient SpVoiceObj2 = null; // ServiceApiClient SpVoiceObj = null; try { //需要检测的网址 bool isTrue = urlCheck.StartsWith("http"); if (!isTrue) { urlCheck = "http://" + urlCheck; } urlCheck = System.Web.HttpUtility.UrlEncode(urlCheck); string json2 = "{\"Mode\":\"" + model + "\",\"Param\":\"{\'CheckUrl\':\'" + urlCheck + "\',\'UserKey\':\'" + wxKey + "\',\'UserIP\':\'" + userIP + "\',\'IsFreeKey\':'" + IsFreeKey + "'}\"}"; SpVoiceObj2 = new ServiceApiClient("NetTcpBinding_IServiceApi"); SpVoiceObj2.Open(); result = SpVoiceObj2.Api(json2); SpVoiceObj2.Close(); Logger.WriteLogggerTest("#################################################"); Logger.WriteLogggerTest(wxKey + ":" + userIP + ":" + result); Logger.WriteLogggerTest(wxKey + ":" + context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]); } catch (System.ServiceModel.CommunicationException) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } } catch (TimeoutException) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } } catch (Exception ex) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + urlCheck + "\",\"Msg\":\"请求操作在配置的超时,请联系管理员!\"}"; LogTools.WriteLine(userIP + ":" + wxKey + ":" + ex.Message); } // } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + userIP + "\",\"Msg\":\"测试接口,请在每天(08:00-21:00)时间段进行测试,需要讨论技术,联系管理员qq:391502069.\"}"; } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + userIP + "\",\"Msg\":\"参数错误,联系管理员qq:391502069!\"}"; } } context.Response.Headers.Add("Access-Control-Allow-Origin", "http://www.rrbay.xyz"); context.Response.Headers.Add("Access-Control-Allow-Methods", "POST"); context.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); context.Response.Write(result); context.Response.End(); }
public void ProcessRequest(HttpContext context) { string result = "{\"State\":false,\"Code\":\"003\",\"Data\":\" \",\"Msg\":\"参数错误,联系管理员!\"}"; string wxKey = wxCheckApiKey; //key ,md5值 string allowOrigin = "https://www.rrbay.com,http://www.wxcheckurl.com,http://www.engcloud.cn,https://gemgin.github.io,https://qqwebchat.gitee.io"; string origin = context.Request.Headers.Get("Origin"); string referer = context.Request.Headers.Get("Referer"); if (origin != null && referer != null && (allowOrigin.Contains(origin) || origin.Contains("http://localhost:")) && referer.Length > origin.Length && context.Request.HttpMethod.ToUpper().Equals(POST)) { context.Response.ContentType = "text/plain"; string urlCheck = context.Request["url"]; string model = context.Request["model"]; if (!string.IsNullOrEmpty(urlCheck) && !string.IsNullOrEmpty(model)) { if (!string.IsNullOrEmpty(context.Request["key"]) && context.Request["key"].Length == 32) { wxKey = context.Request["key"]; //key ,md5值 } if (!wxKey.ToLower().Equals(wxCheckApiKey)) { IsFreeKey = 0; } else { IsFreeKey = 1; userIP = LogTools.GetWebClientIp(context); } TimeSpan dspNow = DateTime.Now.TimeOfDay; if ((IsFreeKey == 1 && LogTools.IsInTimeInterval(dspNow, _strWorkingDayAM, _strWorkingDayPM)) || IsFreeKey == 0) { if (!urlCheck.ToLower().Contains(".kuaizhan.com") && !urlCheck.ToLower().Contains(".luckhl8.com") && !urlCheck.ToLower().Contains(".kennethhwong.cn") && !urlCheck.ToLower().Contains(".hatai678.top") && !urlCheck.ToLower().Contains(".jszkgs.top")) { ServiceApiClient SpVoiceObj2 = null; // ServiceApiClient SpVoiceObj = null; try { //需要检测的网址 bool isTrue = urlCheck.StartsWith("http"); if (!isTrue && !model.Equals("AuthQQGJICPKey")) { urlCheck = "http://" + urlCheck; } if (urlCheck.StartsWith("http://") || urlCheck.StartsWith("https://")) { urlCheck = System.Web.HttpUtility.UrlEncode(urlCheck); } string json2 = "{\"Mode\":\"" + model + "\",\"Param\":\"{\'CheckUrl\':\'" + urlCheck + "\',\'UserKey\':\'" + wxKey + "\',\'UserIP\':\'" + userIP + "\',\'IsFreeKey\':'" + IsFreeKey + "'}\"}"; SpVoiceObj2 = new ServiceApiClient("NetTcpBinding_IServiceApi"); SpVoiceObj2.Open(); result = SpVoiceObj2.Api(json2); SpVoiceObj2.Close(); } catch (System.ServiceModel.CommunicationException) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } } catch (TimeoutException) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } } catch (Exception ex) { // if (SpVoiceObj != null) SpVoiceObj.Abort(); if (SpVoiceObj2 != null) { SpVoiceObj2.Abort(); } result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + urlCheck + "\",\"Msg\":\"请求操作在配置的超时,请联系管理员!\"}"; LogTools.WriteLine(userIP + ":" + wxKey + ":" + ex.Message); } } else { result = "{\"State\":false,\"Code\":\"002\",\"Data\":\"" + urlCheck + " \",\"Msg\":\"歇一歇,访问太快了,联系管理员!\"}"; } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + userIP + "\",\"Msg\":\"测试接口,请在每天(08:00-21:00)时间段进行测试,需要讨论技术,联系管理员.\"}"; } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"" + userIP + "\",\"Msg\":\"参数错误,联系管理员!\"}"; } } if (origin != null && (allowOrigin.Contains(origin) || origin.Contains("http://localhost:"))) { context.Response.Headers.Add("Access-Control-Allow-Origin", origin); } else { context.Response.Headers.Add("Access-Control-Allow-Origin", "https://www.rrbay.com"); } context.Response.Headers.Add("Access-Control-Allow-Methods", "POST"); context.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); context.Response.Write(result); context.Response.End(); }
public void ProcessRequest(HttpContext context) { string result = string.Empty; if (context.Request.HttpMethod.ToUpper().Equals(POST)) { string url = context.Request["url"]; string type = context.Request["type"]; //key ,md5值 string model = context.Request["model"]; //a,还原;b.生成 context.Response.ContentType = "text/plain"; TimeSpan dspNow = DateTime.Now.TimeOfDay; if (!string.IsNullOrEmpty(model) && model.Equals("b")) { //生成短链接 if (IsInTimeInterval(dspNow, _strWorkingDayAM, _strWorkingDayPM) && !string.IsNullOrEmpty(url)) { userIP = GetWebClientIp(context); ServiceApiClient SpVoiceObj = null; try { if (type.ToUpper() != "URLCN" && type.ToUpper() != "WURLCN") { type = "URLCN"; } url = System.Web.HttpUtility.UrlEncode(url); string json2 = "{\"Mode\":\"ShortUrl\",\"Param\":\"{\'CheckUrl\':\'" + url + "\',\'type\':\'" + type + "\',\'UserKey\':\'" + shorturlkey + "\',\'UserIP\':\'" + userIP + "\',\'IsFreeKey\':1}\"}"; SpVoiceObj = new ServiceApiClient("NetTcpBinding_IServiceApi"); SpVoiceObj.Open(); result = SpVoiceObj.Api(json2); SpVoiceObj.Close(); if (!string.IsNullOrEmpty(context.Request.QueryString["callback"])) { string callBack = context.Request.QueryString["callback"].ToString(); //回调 result = callBack + "(" + result + ")"; } } catch (System.ServiceModel.CommunicationException) { if (SpVoiceObj != null) { SpVoiceObj.Abort(); } } catch (TimeoutException) { if (SpVoiceObj != null) { SpVoiceObj.Abort(); } } catch (Exception ex) { if (SpVoiceObj != null) { SpVoiceObj.Abort(); } result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"https://url.cn/5mfnDv7\",\"Msg\":\"请求操作在配置的超时,请联系管理员!\"}"; LogTools.WriteLine(shorturlkey + ":" + ex.Message); } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"https://url.cn/5mfnDv7\",\"Msg\":\"测试接口,请在每天(08:00-21:00)时间段进行测试,需要讨论技术,联系管理员qq:391502069.\"}"; } } else { //短链接还原 result = HttpHelper.GetLocation(url); } } else { result = "{\"State\":false,\"Code\":\"003\",\"Data\":\"https://url.cn/5mfnDv7\",\"Msg\":\"参数错误,联系管理员qq:391502069!\"}"; } context.Response.Headers.Add("Access-Control-Allow-Origin", "http://www.rrbay.com"); context.Response.Headers.Add("Access-Control-Allow-Methods", "POST"); context.Response.Headers.Add("Access-Control-Allow-Credentials", "true"); context.Response.Write(result); context.Response.End(); }
public void ProcessRequest(HttpContext context) { string urlCheck = string.Empty; context.Response.ContentType = "text/plain"; string result = string.Empty; if (!string.IsNullOrEmpty(context.Request["url"]) && !string.IsNullOrEmpty(context.Request["key"]) && context.Request["key"].Length == 32) { string userKey = context.Request["key"]; //key ,md5值 ServiceApiClient SpVoiceObj = null; try { SpVoiceObj = new ServiceApiClient("NetTcpBinding_IServiceApi"); //需要检测的网址 urlCheck = context.Request["url"]; //检测的值 bool isTrue = urlCheck.StartsWith("http"); if (!isTrue) { urlCheck = "http://" + urlCheck; } urlCheck = System.Web.HttpUtility.UrlEncode(urlCheck); string json = "{\"Mode\":\"WXCheckUrl\",\"Param\":\"{\'CheckUrl\':\'" + urlCheck + "\',\'UserKey\':\'" + userKey + "\'}\"}"; SpVoiceObj.Open(); result = SpVoiceObj.Api(json); SpVoiceObj.Close(); } catch (System.ServiceModel.CommunicationException) { if (SpVoiceObj != null) { SpVoiceObj.Abort(); } } catch (TimeoutException) { if (SpVoiceObj != null) { SpVoiceObj.Abort(); } } catch (Exception ex) { if (SpVoiceObj != null) { SpVoiceObj.Abort(); } result = "{\"State\":false,\"Code\",\"003\",\"Data\":\"" + urlCheck + "\",\"Msg\":\"请求操作在配置的超时,请联系管理员!\"}"; LogTools.WriteLine(ex.Message); } } else { result = "{\"State\":false,\"Code\",\"003\",\"Data\":\"" + urlCheck + "\",\"Msg\":\"参数错误,进qq群交流:41977413!\"}"; } context.Response.Write(result); context.Response.End(); }