views:

650

answers:

2

Hi everyone!

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!!

+2  A: 

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)

chris166
Thanks Chris! Is there a way to save this FormCollection to a cookie?
AndreMiranda
Not easy. Only if your POST action doesn't require a user login, instead saves the FormCollection to a cookie, then redirects to another action which requires login. But I wouldn't recommend doing it that way...
chris166
+1  A: 

I would prefer to disallow unauthorized user to visit "Results" page or at least to show him message "Please login first" instead of the form.

Alexander Prokofyev