Html.BeginForm() with an absolute URL?

Viewed 24879

I need to have the POST action be to an absolute URL (e.g., http://www.cnn.com). Is there a way to use Html.BeginForm() helper and pass it the url?

3 Answers

All that the HtmlHelper.BeginForm method does is help you to create a <form> tag that targets a local controller. If you're posting to an external site, just write out the actual <form> tag, i.e.

<form action="http://www.example.com/someaction" method="post">
    Actual form content in here
</form>

That's all there is to it. MVC forms are not like the forms in ASP.NET WebForms where you have a bunch of ViewState and event fields and other magical elements. They're just regular old HTML forms.

Related