How many ways do you know to send data between ASP.NET Pages? In this article I'm going to list 5 ways. The first 2 or 3 ways are very well-known and the last 2 or 3 ways are not well-known. You will find here mostly inline methods to receive the data in various pages.

So, let's start with the most well-known one.
Using Session State
Using this technique I will store the data in a session variable on the client machine and on the next page, grab it; see:
ASPX Page:
<asp:TextBox ID="txtData" runat="server"></asp:TextBox>
<br /><br />
<asp:Button ID="btnSessionState" runat="server" Text="Session State" OnClick="btnSessionState_Click" />
Code-Behind:
protected void btnSessionState_Click(object sender, EventArgs e)
{
Session["Data"] = txtData.Text;
Response.Redirect("SessionState.aspx");
}
Receiver ASPX Page:
<div>
<h1>Session State</h1>
Data is: <%=Session["Data"] %>
And you are all set, run it and test it.
Using Query String
Using this technique I will add my data with an URL and on the next page grab it; see:
ASPX Page:
<asp:TextBox ID="txtData" runat="server"></asp:TextBox>
<br /><br />
<asp:Button ID="btnQueryString" runat="server" Text="Query String" OnClick="btnQueryString_Click" />
Code-Behind:
protected void btnQueryString_Click(object sender, EventArgs e)
{
Response.Redirect("QueryString.aspx?Data=" + Server.UrlEncode(txtData.Text));
}
Receiver ASPX Page:
<h1>Query String</h1>
Data is: <%=Server.UrlDecode(Request.QueryString["Data"]) %>
And you are all set, run it and test it.
Using HpptPost
Using this technique I will call a post back URL and the on next page using Request.From I will grab it; see:
ASPX Page:
<asp:TextBox ID="txtData" runat="server"></asp:TextBox>
<br /><br />
<asp:Button ID="btnHttpPost" runat="server" Text="HTTPPost" PostBackUrl="~/HttpPost.aspx" />

tom hinesPosted May 9, 2019, 3:11 PM
Thanks, how do I run those in a project. When I add them to a project I get these errors? Severity Code Description Project File Line Suppression StateError CS0103 The name 'Label1' does not exist in the current context WebApplication1 C:\Users\THines\source\repos\new\5WaystosenddatabetweenASP.NETPages\WebApplication1\WebApplication1\Control.aspx.cs 15 Active Error CS0103 The name 'txtData' does not exist in the current context WebApplication1 C:\Users\THines\source\repos\new\5WaystosenddatabetweenASP.NETPages\WebApplication1\WebApplication1\Default.aspx.cs 13 Active Error CS0103 The name 'txtData' does not exist in the current context WebApplication1 C:\Users\THines\source\repos\new\5WaystosenddatabetweenASP.NETPages\WebApplication1\WebApplication1\Default.aspx.cs 20 Active Error CS0103 The name 'txtData' does not exist in the current context WebApplication1 C:\Users\THines\source\repos\new\5WaystosenddatabetweenASP.NETPages\WebApplication1\WebApplication1\Default.aspx.cs 32 Active Warning CS0436 The type 'Control' in 'C:\Users\THines\source\repos\new\5WaystosenddatabetweenASP.NETPages\WebApplication1\WebApplication1\Control.aspx.cs' conflicts with the imported type 'Control' in 'WebApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\THines\source\repos\new\5WaystosenddatabetweenASP.NETPages\WebApplication1\WebApplication1\Control.aspx.cs'. WebApplication1 C:\Users\THines\source\repos\new\5WaystosenddatabetweenASP.NETPages\WebApplication1\WebApplication1\Control.aspx 1 Active Warning CS0436 The type '_Default' in 'C:\Users\THines\source\repos\new\5WaystosenddatabetweenASP.NETPages\WebApplication1\WebApplication1\Default.aspx' conflicts with the imported type '_Default' in 'WebApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\THines\source\repos\new\5WaystosenddatabetweenASP.NETPages\WebApplication1\WebApplication1\Default.aspx'. WebApplication1 C:\Users\THines\source\repos\new\5WaystosenddatabetweenASP.NETPages\WebApplication1\WebApplication1\Default.aspx 1 Active
tom hinesPosted May 9, 2019, 3:11 PM
Thanks, how do I run those in a project? I get these errors
jay patelPosted May 19, 2018, 12:13 AM
How to pass large amount of data between two pages.can you give one example of it.thank you
Nimit JoshiPosted Jun 23, 2014, 10:39 PM
Its Great... Thanks