1

I'm very much a web forms man and am coming over to mvc using mvc 4.

Am I missing something or is the norm with a thank you or response page to create a separate view and direct off to that.

So for instance if a user fills in a contact us form, clicks submit, the user then needs to see a thank you message on the page.

This would be done using the same web form but am i right in thinking i should create a new view?

If this is the case doesn't a site soon fill up with a LOT of very simple views?

tereško
  • 58,060
  • 25
  • 98
  • 150
Simon
  • 1,966
  • 5
  • 21
  • 35

1 Answers1

2

If you are referring to PRG pattern, then the answer is yes, preferred way is to redirect user to the separate action which will in turn return a "Thank you" view.

However, nothing stops you from creating such an action that will for example bind to your specific model and according to that decide in your view what to render.

That way, you shouldn't and up with many "Thank you" views.

EDIT:

ASP.NET MVC technology itself is a set of best practices and conventions. There is nothing to stop you to use it the 'wrong' way.

But what exactly would be wrong way here?

  • using a lot of small views could reduce the mess and give you some flexibility; imagine the situation where suddenly you have to change each of "Thank you" views in the way to tell the user something about the action completed and to point him toward the next one
  • using some view-related logic in template can in extreme cases reduce all of those "Thank you" views to few or just one; in the other hand you could end up with a big and ugly Razor template
  • using partial view could help you with the first problem, but then you have to be careful where you put your partals - you want to reduce mess, not generate more
  • using helpers in views could be helpful to encapsulate a small parts of the view that repeats throughout multiple views
Community
  • 1
  • 1
OzrenTkalcecKrznaric
  • 5,535
  • 4
  • 34
  • 57