简体   繁体   中英

ASP.NET MVC - How can I pass FormCollection data in a post to another Action?

I have a page "Results" with a form and when "submit" is clicked, the form is submmited to another Action. So far, so good...

But, this works fine just if user is logged in. If not, he will be redirected to "Login" page and my FormCollection loses its data.

Is there a way to persist this data without using TempData??

Thanks!!

I don't think that's possible. The only thing the system remembers during the redirect to the login page is the 'return url'. No post data is saved (this could be megabytes of data...)

You can use the Session object as alternative, or make sure that the user is logged in before you post.

Or, if it's just a search result, try to live without the POST, and use a GET (which also has other advantages)

我宁愿不允许未经授权的用户访问“结果”页面或至少向他显示消息“请先登录”而不是表格。

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