return RedirectToAction("deshboardportal", "Portal",new { User_Id = Session["USER_ID"], RoleId = Session["ROLE_ID"]});
在上面的代码中,我只想加密下面写的url参数: -
new { User_Id = Session["USER_ID"], RoleId = Session["ROLE_ID"]}
答案 0 :(得分:0)
你可以尝试
return RedirectToAction("deshboardportal", "Portal", new { User_Id = Encode(Session["USER_ID"].ToString()), RoleId = Encode(Session["ROLE_ID"].ToString()) });
public string Encode(string encodeMe)
{
byte[] encoded = System.Text.Encoding.UTF8.GetBytes(encodeMe);
return Convert.ToBase64String(encoded);
}
public static string Decode(string decodeMe)
{
byte[] encoded = Convert.FromBase64String(decodeMe);
return System.Text.Encoding.UTF8.GetString(encoded);
}