views:

42

answers:

1

We need to put a captcha image on our ASP.NET MVC 2 based website. We chose reCaptcha and built it in using the way described by Derik Whittaker. The idea there is baiscally to build some abstractions and all you need to do is decorate your Controller with a [ValidateCaptcha] attribute. This works all fine.

However, we have a lot of form-widgets in different pages and I don't want to have the captcha floating around everywhere. So I'd like to implement it the way StackOverflow does: Submit a Form -> Challenge Captcha -> Submit Captcha -> Perform Action on original form data.

Now, how do I redirect the user to the captcha page while keeping the originally submitted information?

I thought of some very ugly hacks (hidden fields w/ base64 encoded form data, etc.) but I think I'm missing something obvious. On the other hand, this sounds as if I wanted to do something in a stateful manner, and I shouldn't?

A: 

Session or persisting model state on the client comes to mind.

Darin Dimitrov
Persisting model state looks just like my hack idea, but clean, isolated and reusable. Nice. Let me check, but this looks really promising.
mnemosyn
I went for the session in the end, but that still proved to be more tricky than I thought. Thanks for the answer.
mnemosyn