Ajax MVC4 Form URL

Is there a way to set the url for form of AJAX? I am looking for an answer using Ajax.BeginForm() syntax so that I can use the magic of building a Microsoft model without having to re-parse the url string.

There is a partial view that lives on foo.com.au/getFoo , which has an ajax form. the ajax form will be sent to the controller Foo (by default), getFoo .

When I call this from an external site ( bar.com.au ), I want it to return to foo.com.au/getFoo . Instead, it goes to bar.com.au/getFoo . Is there a way to tell the Ajax form to publish the full URL, not just the relative path?

Motive
For those of you who suspect hax0rz or other dishonest game, I created a widget that integrates on several client sites. Now I am creating an authentication plugin for this widget. The widget does not redirect them to my site for authentication, so I want it to send back to my domain with the results of entering the username / password.

+6
source share
1 answer

You need to pass it through the Ajax options instead of delivering it to the overloaad BeginForm:

 @using (Ajax.BeginForm( new AjaxOptions { Url = Url.Action("getFoo", "Foo", null, Request.Url.Scheme) })) { ... } 
+2
source

Source: https://habr.com/ru/post/951992/


All Articles