public void AutoPost(string url,string domain, string userName) { AlipayProxy.UserReg.UserReg userRegService = new AlipayProxy.UserReg.UserReg(); string password = userRegService.GetUserPassWord(userName); string language = "zh-cn"; string key = "VaNclddf&123";// 解密key
string decrypassword = Decrypt(password, key); StringBuilder sbForm = new StringBuilder(); sbForm.Append("<form id='postForm' method='post'> "); sbForm.Append("<input type='hidden' name='Domain' value='" + domain + "' />"); sbForm.Append("<input type='hidden' name='UserName' value='" + userName + "' />"); sbForm.Append("<input type='hidden' name='Password' value='" + decrypassword + "' />"); sbForm.Append("<input type='hidden' name='Language' value='" + language + "' />"); sbForm.Append("</form>"); sbForm.Append("<script language= 'javascript'>"); sbForm.Append("document.getElementById('postForm').method = 'post';"); sbForm.Append("document.getElementById('postForm').action = '" + url + "';"); sbForm.Append("document.getElementById('postForm').submit();"); sbForm.Append("</script>"); Response.Write(sbForm.ToString()); }
AutoPost("Login.aspx", "Vancloud-corp", username);
login 页面做如下处理
if (!IsPostBack) { if (Request.RequestType.ToUpper() == "POST") { SortedList table = Param(); if (table != null) { AlipayProxy.UserReg.UserReg userRegService = new AlipayProxy.UserReg.UserReg(); if (true == userRegService.UserLogin( table["Domain"].ToString(),table["UserName"].ToString(),table["Password"].ToString())) { int role = 0; if (!SaveLoginInfo( table["Domain"].ToString(),table["UserName"].ToString(),table["Password"].ToString(),table["Language"].ToString(),out role)) { lblErrorMessage.Text = GetLocalResourceObject("PermissionExpired").ToString(); return; } Response.Redirect("SysInit.aspx", false); } } } }