How to pass a List from one page to another.
up vote
1
down vote
favorite
I'm having this issue and i'm stumped. I'm able to pass and received single object but If I try to pass a list, the data is not going to the second page.
Here is my OrderList Page
[BindProperty]
public IList<Orders> Orders get; set;
public ActionResult OnPost()
//get modified data.
var orderList = Orders
return RedirectToPage("/ConvertToCsv", orderList );
on my ConvertToCsv page.
public void OnGet(IList<Orders> orderList )
//do something with list.
But the orderlist on OnGet is null.
I tested by passing a single record like
public ActionResult OnPost()
return RedirectToPage("/ConvertToCsv", neworderId= "test");
public void OnGet(string orderId )
//This works.
What am I doing wrong?
asp.net-core razor-pages
add a comment |
up vote
1
down vote
favorite
I'm having this issue and i'm stumped. I'm able to pass and received single object but If I try to pass a list, the data is not going to the second page.
Here is my OrderList Page
[BindProperty]
public IList<Orders> Orders get; set;
public ActionResult OnPost()
//get modified data.
var orderList = Orders
return RedirectToPage("/ConvertToCsv", orderList );
on my ConvertToCsv page.
public void OnGet(IList<Orders> orderList )
//do something with list.
But the orderlist on OnGet is null.
I tested by passing a single record like
public ActionResult OnPost()
return RedirectToPage("/ConvertToCsv", neworderId= "test");
public void OnGet(string orderId )
//This works.
What am I doing wrong?
asp.net-core razor-pages
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm having this issue and i'm stumped. I'm able to pass and received single object but If I try to pass a list, the data is not going to the second page.
Here is my OrderList Page
[BindProperty]
public IList<Orders> Orders get; set;
public ActionResult OnPost()
//get modified data.
var orderList = Orders
return RedirectToPage("/ConvertToCsv", orderList );
on my ConvertToCsv page.
public void OnGet(IList<Orders> orderList )
//do something with list.
But the orderlist on OnGet is null.
I tested by passing a single record like
public ActionResult OnPost()
return RedirectToPage("/ConvertToCsv", neworderId= "test");
public void OnGet(string orderId )
//This works.
What am I doing wrong?
asp.net-core razor-pages
I'm having this issue and i'm stumped. I'm able to pass and received single object but If I try to pass a list, the data is not going to the second page.
Here is my OrderList Page
[BindProperty]
public IList<Orders> Orders get; set;
public ActionResult OnPost()
//get modified data.
var orderList = Orders
return RedirectToPage("/ConvertToCsv", orderList );
on my ConvertToCsv page.
public void OnGet(IList<Orders> orderList )
//do something with list.
But the orderlist on OnGet is null.
I tested by passing a single record like
public ActionResult OnPost()
return RedirectToPage("/ConvertToCsv", neworderId= "test");
public void OnGet(string orderId )
//This works.
What am I doing wrong?
asp.net-core razor-pages
asp.net-core razor-pages
asked Nov 9 at 18:50
causita
849817
849817
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You can't pass complex objects as route data. The route data feature only supports simple objects like int
and string
. If you want to retain more complex objects across requests, you need to use Sessions or TempData (backed by session state).
TempData is probably the better option in this case because the item is removed from memory once you access it.
Further reading:
TempData: https://www.learnrazorpages.com/razor-pages/tempdata
Sessions: https://www.learnrazorpages.com/razor-pages/session-state
State Management in Razor Pages: https://www.learnrazorpages.com/razor-pages/state-management
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You can't pass complex objects as route data. The route data feature only supports simple objects like int
and string
. If you want to retain more complex objects across requests, you need to use Sessions or TempData (backed by session state).
TempData is probably the better option in this case because the item is removed from memory once you access it.
Further reading:
TempData: https://www.learnrazorpages.com/razor-pages/tempdata
Sessions: https://www.learnrazorpages.com/razor-pages/session-state
State Management in Razor Pages: https://www.learnrazorpages.com/razor-pages/state-management
add a comment |
up vote
0
down vote
accepted
You can't pass complex objects as route data. The route data feature only supports simple objects like int
and string
. If you want to retain more complex objects across requests, you need to use Sessions or TempData (backed by session state).
TempData is probably the better option in this case because the item is removed from memory once you access it.
Further reading:
TempData: https://www.learnrazorpages.com/razor-pages/tempdata
Sessions: https://www.learnrazorpages.com/razor-pages/session-state
State Management in Razor Pages: https://www.learnrazorpages.com/razor-pages/state-management
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You can't pass complex objects as route data. The route data feature only supports simple objects like int
and string
. If you want to retain more complex objects across requests, you need to use Sessions or TempData (backed by session state).
TempData is probably the better option in this case because the item is removed from memory once you access it.
Further reading:
TempData: https://www.learnrazorpages.com/razor-pages/tempdata
Sessions: https://www.learnrazorpages.com/razor-pages/session-state
State Management in Razor Pages: https://www.learnrazorpages.com/razor-pages/state-management
You can't pass complex objects as route data. The route data feature only supports simple objects like int
and string
. If you want to retain more complex objects across requests, you need to use Sessions or TempData (backed by session state).
TempData is probably the better option in this case because the item is removed from memory once you access it.
Further reading:
TempData: https://www.learnrazorpages.com/razor-pages/tempdata
Sessions: https://www.learnrazorpages.com/razor-pages/session-state
State Management in Razor Pages: https://www.learnrazorpages.com/razor-pages/state-management
answered Nov 9 at 19:36
Mike Brind
16.8k53768
16.8k53768
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53231714%2fhow-to-pass-a-list-from-one-page-to-another%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown