Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Haansi 51 posts 150 karma points
    Dec 08, 2014 @ 12:36
    Haansi
    0

    how to use RedirectToAction correctly in SurfaceController ?

    I m submiting a form to SurfaceController's action 'Submit'. Where after saving data it Redirect to another action 'LeadContact' using MVC RedirectToAction and pass Id as a paramter to it. In 'LeadContact' model is being populating and passed to 'LeadContact' view.

    Not sure if I m doing correctly or not but when 'LeadContact' renders in browser it amends URL. Browser shows URL like http://localhost:50656/umbraco/Surface/HealthInsurance/LeadContact?leadOptionId=70 while I m expecting it should be http://localhost:50656/HealthInsurance/LeadContact?leadOptionId=70

    Can you please guide I can correct it ? Below is my code:

     public ActionResult Submit(FormCollection form)
            {

                //Some logic and later redirect to another action 'LeadContact'             

    return RedirectToAction("LeadContact", new { leadOptionId = _id}); 
             }

     

           public ActionResult LeadContact(int leadOptionId)

            {
               MyViewModel model = new MyViewModel();         

               //Lines of code to populate data into model   

                return View("LeadContact", model);
            }

     

    Thanks for your help and sharing.

     

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Dec 09, 2014 @ 09:26
    Dave Woestenborghs
    0

    Have a look at the documentation for surface controllers. The routing is explained there :

    http://our.umbraco.org/documentation/Reference/Templating/Mvc/surface-controllers

    But you can have your own custom routes. have a look at the documentation here :

    http://our.umbraco.org/documentation/Reference/Templating/Mvc/custom-routes

    Dave

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies