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 @ 14:48
    Haansi
    0

    SurfaceController generate incorrect URL ?

    Form is posted to 'Submit' (which is SurfaceController action). After saving data in DB it Redirect execution to another action 'LeadContact' in same controller using MVC RedirectToAction and pass Id as a paramter to it. In 'LeadContact' model is populated and passed to 'LeadContact' view.

    Not sure if I m doing correct or incorrect but when 'LeadContact' renders in browser it has incorrect URL. It 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

    In short it adds /umbraco/SurfaceContact' into url.

     

    Can you please guide I can correct it and what I m doing wrong ?

     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.

     

  • Yakov Lebski 591 posts 2346 karma points
    Dec 08, 2014 @ 23:33
    Yakov Lebski
    1

    In CMS it's works little different, in pure MVC you manage urls by route tables, in CMS url managed by CMS

    you can see umbraco reference http://our.umbraco.org/documentation/Reference/Templating/Mvc/forms

  • Haansi 51 posts 150 karma points
    Dec 08, 2014 @ 23:39
    Haansi
    0

    ohhh I spent last complete day on this :(

    Thanks @YakovLebski for clarifying.

    Does it mean existing MVC views cannot be used ?

    Please also guide how MVC URL will work for example http://localhost:50656/HealthInsurance/LeadContact?leadOptionId=70 how I can pass query string before in MVC I used to do return RedirectToAction("LeadContact", new { leadOptionId = _id});

    Thank you so much for this help.

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

    Yakov Lebski thanks for referenced link. I have gone through it. Just a small question please. Will I need to create Template for every View to render and then put my view logic inside that Template wrapping into a PartialView ?

  • Yakov Lebski 591 posts 2346 karma points
    Dec 08, 2014 @ 23:55
    Yakov Lebski
    1

    You can create template for every view, I prefer use partial macro to render different action on the same template (by using macro container or embed macro in RTE)

  • Haansi 51 posts 150 karma points
    Dec 09, 2014 @ 00:23
    Haansi
    0

    I m sorry for asking many things, kindly tolerate I m new to Umbraco.

    Just want to clear:

    "You can create template for every view"

    Does it means create tempalte for every view and then create a content and that content will be basically view and later to hijack routing in Surface Controller ?

    I prefer use partial macro to render different action on the same template (by using macro container or embed macro in RTE)

    Is it something you can guide and I can do please ? Can you share a little detail on steps please

    I highly appreciate your help

  • Yakov Lebski 591 posts 2346 karma points
    Dec 09, 2014 @ 22:49
    Yakov Lebski
    0

    option 1: Create template for each action, put hard coded @Html.Action("Action","Controller")

    option 2:

    1. Create one document type with template add macro container field
    2. create partial macro
    3. In new partial macro put hard coded @Html.Action("Action","Controller")
    4. Add macro to macro container field

    .... something like this

Please Sign in or register to post replies

Write your reply to:

Draft