简体   繁体   中英

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

I have tried using several things one of which was QueryString. Here is my code:

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"];
}

But the problem is all we know that data can be seen in url and can be modified by any user.

Now what to do so that i could pass my data and it won't be visible to any user.

Is there some way using __doPostBack() or Not?

Well you can post the data like

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

and in sever side:

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

but this is also not safe. anybody can post anything. unless there is a access token.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM