Try our conversational search powered by Generative AI!

Best practise working example when posting from inside block (MVC)?

Vote:
 

Hi!

Does anyone have a best practise working example when posting from inside a block? That is, when using Razor's "Html.BeginForm".

I must say that it's not exactly straight forward compared to how it was done in Web Forms. Can't find any examples in the Alloy test site either or maybe it's just because I have an old version installed. Also, when asking my friend Google the examples I find tend to be very verbose.

#179340
Jun 08, 2017 14:33
Vote:
 

Do I understand you correctly that you would like to have a action inside block's controller with [HttpPost] attribute that will be responsible for handling "postback" from the form rendered in block view with Html.BeginForm()?

Long story short - that's not possible out of the box. As by default post backs are going back to the server and there has to be somebody who will handle the request. Usually in EPiServer context, that's page controller. 

You can head over to Henrik's post (dated back to 2013) and see how that's achieved.

#179357
Jun 08, 2017 21:48
Vote:
 

Hi Valdis,

And thank you for the answer!

You understand me correctly and you also confirm what I suspected. Too bad there's no example in the Alloy test site...

As stated at the end of Henrik's post it could be worth trying to go with XHR/AJAX instead.

#179373
Jun 09, 2017 8:24
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.