Reputation: 47995
I'd like to do this :
is there any mechanism to doing that? without having a querystring system... I know there are many scope in .NET...
Upvotes: 0
Views: 189
Reputation: 460228
If Response.Redirect
is not set in stone, you could use Server.Transfer
instead and Page.PreviousPage
to access the first page directly.
When you use the Transfer method or use cross-page posting to transfer processing from one ASP.NET page to another, the originating page contains request information that might be required for the destination page. You can use the PreviousPage property to access that information.
If the current page is being rendered as a result of a direct request (not a transfer or cross-post from another page), the PreviousPage property contains null.
So for example in the first page(RedirectForm.aspx):
public String Value { get; set; }
protected void BtnTransfer_Click(object sender, EventArgs e)
{
Value = "Foo";
Server.Transfer("Transfer.aspx");
}
and in Transfer.aspx
:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.PreviousPage != null)
{
RedirectForm prev = (RedirectForm)Page.PreviousPage;
String prevValue = prev.Value; // "Foo"
}
}
Upvotes: 0
Reputation: 7200
Yes, it can be done.
Upvotes: 3
Reputation: 69270
If you're using ASP.NET MVC3 there is a special collection for exactly this, called TempData
. Anything you put in there is available to the next request, but no longer.
For web forms there is a duplicate question here on SO: TempData Like Object in WebForms - Session State for only 1 Additional Request
Upvotes: 3