开发者

redirect to POST with javascript in asp.net mvc

I have 2 controller methods:

[HttpGet]
public ActionResul开发者_StackOverflowt SomeAction(SomeModel model, string someString)
{
//..
return View()

and

[HttpPost]
public ActionResult SomeAction(SomeModel model)

I'm trying to find a way what would allow me to navigate directly to Post method from a controller (some other controller). I've heard the is a way to do it in javascript, but I can't find it anywhere. The idea would be to set a filed in model, and check it at beginning of a view - if it's set, do the javascript thing to redirect immediatly to Post action in controller. If anyone knows how to do it, I would aprreciate it


It sounds to me like you want to check, on page load, if the form has been filled out and if so immediately post it to the appropriate action?

If so

$(function() {
    if () { // determine here if the form has been filled out and completed
        $('#theform').submit(); // this posts the form, which will hit the post action
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜