GetServerAddress.aspx.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using LYFZ.Weixin.SDK;
  2. using LYFZ.WXLibrary;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. namespace LYFZ.WeixinServers.WeiXinAPP
  10. {
  11. public partial class GetServerAddress : System.Web.UI.Page
  12. {
  13. LYFZ.WeixinServiceDate.DAL.DAL_CustomerInterfaces cusDal = new WeixinServiceDate.DAL.DAL_CustomerInterfaces();
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. string signature = Request["signature"];
  17. string timestamp = Request["timestamp"];// yyyyMMddhhmmss
  18. string nonce = Request["nonce"];
  19. if (Request.HttpMethod == "GET")
  20. {
  21. string JMGDomainName = "";
  22. if (Request.QueryString["JMGD"] == null)
  23. {
  24. Response.Write("如果你在浏览器中看到这句话,说明此地址可以接口的Url,请注意保持Token一致。" + LYFZ.Weixin.SDK.BasicAPI.GetSignature(timestamp, nonce, Global.lyfzToken));
  25. }
  26. else {
  27. JMGDomainName = LYFZ.WinAPI.SDKSecurity.Decode(Request.QueryString["JMGD"].ToString());
  28. var ent = "";
  29. if (!BasicAPI.CheckSignature(signature, timestamp, nonce, Global.lyfzToken, out ent))
  30. {
  31. CommonHandleClass.WriteLog("POST:验证失败,非法提交");
  32. WriteContent("验证失败,非法提交!");
  33. return;
  34. }
  35. else
  36. {
  37. string retValue = "127.0.0.1:8082";
  38. try
  39. {
  40. LYFZ.WeixinServiceDate.Model.Model_CustomerInterfaces cusModel = Global.GetCustomerModel(JMGDomainName);
  41. if (cusModel != null && cusModel.ID > 0)
  42. {
  43. if (cusModel.ShellDomainName.Trim().Length > 2)
  44. {
  45. if (cusModel.ShellDomainName.Trim().Contains(":"))
  46. {
  47. retValue = cusModel.ShellDomainName.Trim();
  48. }
  49. else
  50. {
  51. retValue = LYFZ.WXLibrary.CommonHandleClass.GetNetUrl(cusModel.ShellDomainName.Trim(), cusModel.PortNumber);
  52. }
  53. }
  54. else
  55. {
  56. retValue = LYFZ.WXLibrary.CommonHandleClass.GetNetUrl(cusModel.IPAddress.Trim(), cusModel.PortNumber);
  57. }
  58. }
  59. }
  60. catch { }
  61. WriteContent(retValue);
  62. }
  63. }
  64. }
  65. }
  66. private void WriteContent(string str)
  67. {
  68. Response.Output.Write(str);
  69. }
  70. }
  71. }