I'm hoping someone can help me here - I'm trying to set up a basic MVC widget for Sitefinity that will POST to an external URL to log the user in there. The problem is if I use regular HTML to do this, the widget will only work in pure MVC mode thanks to the way WebForms deals with forms.
I googled around a bit and found people explaining that with the regular "BeginForm" you can specify an external action URL thusly:
Html.BeginForm(null, null, FormMethod.Post, new { @action="EXTERNAL_URL" })
Which produces the following opening form tag:
<form action="EXTERNAL_URL" method="post">
This works very nicely, but still outputs a regular HTML form which doesn't work with Sitefinity, so Sitefinity has it's own method to produce forms that will work in Hybrid mode "Html.BeginFormSitefinity". This method has all of the same overrides but doesn't behave in quite the same way - when I attempt to use this code:
Html.BeginFormSitefinity(null, null, FormMethod.Post, new { @action="EXTERNAL_URL" })
This produces the following opening form tag:
<form action="/TestProject/TestPage/Index" method="POST" name="defaultForm" action="EXTERNAL_URL">
As you can see, it's popping a second action attribute in rather than overriding the action attribute as seen in the default MVC method's behaviour.
I'm hoping that someone with a better understanding of how Sitefinity works might be able to provide some advice here?
Looking at the sources of the HybridForm, it cannot be modified so it will take
action
htmlAttribute into account: http://pastebin.com/5dfQdzs8So you may create your own form based on this code. You'll need html helper:
and override
GenerateActionUrl()
in yourMyHybridForm
by using action htmlAttribute into account.