How to Programmatically & Automatically submit MVC form, ideally from Controller RRS feed

  • Question

  • User-1224781418 posted

    Hi all,

    I have a fairly normal MVC "Shipping" Controller and View. As normal that view has a form with a button that submits the form. When you press the button you trigger a "Payment" Controller and Form.

    The purpose of the Shipping form is to select which form of Shipping you wish to select. But most cases there will be only one Shipping method to select, so the form is redundent. In that case I would like to bypass that form all together so the user never sees it.

    So, if I check the number of Shipping options and find that it is only one, how can I programmatically and automatically Submit the form so that the user imidiately is taken to the "Payment" Controller/Form. Ideally I would like to do this in the "Shipping" Controller to avoid a round trip, but if that can not be done that I would also be interested in a Browser Based solution.

    Thanks a lot

    Terry Clancy


    Thursday, October 10, 2019 7:09 AM

All replies

  • User1120430333 posted


    Maybe, it will help you or give you some insight. 

    Thursday, October 10, 2019 10:06 AM
  • User475983607 posted

    The design is unclear without the source code.  I assume that you know if there is one shipping option before the View is returned.  So why not just redirect rather than returning a View?

    Thursday, October 10, 2019 10:08 AM
  • User1034446946 posted

    one options would be, before the shipping controller returns the view, check if there is only one method if so process it there and then and redirect to the payment controller.

    another option would be to have the full process in one view,so theres no redirecting

    another is not to worry about it, some people might still like the consistancy of having to click through the shipping option

    Thursday, October 10, 2019 12:11 PM
  • User753101303 posted


    You could redirect the user directly to the next page if you don't need a particular step (rarther than to show the page and try to programmatically submit it because you don't really want to show this anyway).

    As pointed already beyond the technical need, see what is better for the user (will he saw that somewhere, is it better to skip that or to offer them always the same steps even if in some case you just inform them).

    Thursday, October 10, 2019 12:34 PM