zoukankan      html  css  js  c++  java
  • aspx.cs方法设置webmenthod特性接收ajax请求

    cs代码:

    public partial class TelerikWebMethod : BasePage//System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                TelerikWebMethod.username = this.UserInfo.UserName;
                TelerikWebMethod.domainname = this.UserInfo.DomainName;
            }

          /// <summary>
          /// 加密跳转页面链接
          /// </summary>
          private static readonly byte[] key = System.Text.Encoding.Default.GetBytes("abcd12");

            [WebMethod]
            public static string ReturnEncryptionPageUrl(string UserName, string DomainName)
            {
                string Email = string.Empty;
                //string Url = "http://10.76.1.25//login.do";
                string Url = "http://ia.cnpc/login.do";
                string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
    
                if (DomainName.ToUpper().Contains("PTR"))
                {
                    Email = UserName + "@petrochina.com.cn";
                }
                else if (DomainName.ToUpper().Contains("CNPC"))
                {
                    Email = UserName + "@cnpc.com.cn";
                }
                AESDecrypt ad = new AESDecrypt();
                string user = ad.Encrypt(Email + "," + time, key);
                user = HttpUtility.UrlEncode(user, Encoding.UTF8);
                //user = user.Replace("+", "%20");
                user = user.Replace("+", "%2B");
                user = user.Replace("/", "%2F");
                return Url;
            }
    }
    

      前端页面:

    $.            ajax(
                               {
                                   async: false,
                                   type: "POST",
                                   contentType: "application/json",
                                   url: "TelerikWebMethod.aspx/ReturnEncryptionPageUrl",
                                   data: "{'UserName':'" + UserName + "','DomainName':'" + DomainName + "'}",
                                   dataType: "json",
                                   success: function (msg) {
                                       //window.open(msg.d, "newwindow", "height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no")
    
                                       window.open(msg.d, "newwindow");
                                   },
                                   error: function (err) {
                                       alert(err.responseText);
                                   }
                               });
    

      

  • 相关阅读:
    在IE浏览器中url传参长度问题
    Linq语句的认识
    关于选择表达式以及判断语句的书写,可以让代码更加的清晰。
    C#/对线程的认识
    Js/如何修改easyui修饰的input的val值
    Java Lambda表达式中的this
    MySQL USING关键词/USING()函数的使用
    复杂SQL查询
    Java 修饰符
    Git:idea中将当前分支修改的内容提交到其他分支上
  • 原文地址:https://www.cnblogs.com/liuqiyun/p/8184638.html
Copyright © 2011-2022 走看看