使用 c# 代码从一个页面通过 Javascript 传递数据并在另一页面上捕获数据

Pass data through Javascript from one page and catch data on another page using c# code

我尝试过使用几种方法,其中之一是 QueryString。 这是我的代码:

function () { var tid = $(this).text(); 
  var url = "SearchResult.aspx?about=" + encodeURIComponent(tid) + ""; 
  window.location = url; 
}

protected void Page_Load(object sender, EventArgs e)
{
    string arg = Request.QueryString["about"];
}

但问题是我们只知道数据可以在 url 中看到并且可以被任何用户修改。

现在该怎么做才能传递我的数据,并且它不会对任何用户可见。

有什么方法可以使用 __doPostBack() 或不使用吗?

好吧,你可以 post 这样的数据

$.post('SearchResult.aspx', {about : encodeURIComponent(tid)});

在服务器端:

   string arg = Request.Form["about"];

但这也不安全。任何人都可以 post 任何事情。除非有访问令牌。