How do I implement the Post/Redirect/Get pattern in asp.net WebForms?

后端 未结 2 639
闹比i
闹比i 2020-12-10 08:52

So I understand the basics of the prg pattern. But I haven\'t come across a technique for making arbitrary data available to the \"get\" instance of a page.

For exa

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 09:26

    If the fields POSTed are being persisted before the Redirect and you need to access that data after the Redirect, I would append the identifier for the data record(s) on the query string as you mention. You could also specify a status for the request (for displaying messages etc). Then on the GET page you can read out the data and do whatever with it.

    I don't see any other way to get around this as each page obtained by GET will not have access to the previous page's ViewState etc.

    Using Server.Transfer will have the same effect as handling the POST on the original page.

    You could use Session variables to store the POST data, but that stinks.

提交回复
热议问题