Copied to clipboard

Flag this post as spam?

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


  • sai kiran 4 posts 93 karma points
    Feb 26, 2020 @ 01:36
    sai kiran
    0

    Url issue and model binding issue

    Hi Guys

    I have added a table to contactForm page and used @Html.ActionLink("Something", "Edit", new { Id = 1 }) which is routing to the url: localhost:50151/umbraco/Surface/ContactSurface/Edit/1 instead of locahost:50151/Contact/Edit/1 or locahost:50151/ContactSurface/Edit/1 is there any way while using umbraco to use custom route and set the Url to: locahost:50151/Contact/Edit/1 or locahost:50151/ContactSurface/Edit/1 Code snippet:

    public class ContactSurfaceController : SurfaceController
    {   public ActionResult Edit (int Id)
        {
            ContactViewModel model = new ContactViewModel();
            return View(model);
        }
    

    }

    Edit.Cshtml page looks like

    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    
    @using ClientDependency.Core.Mvc
     @{
    Layout = "master.cshtml";
     }
     @* custom stuff *@
    

    Problem/Question: If I leave my url like this ( localhost:50151/umbraco/Surface/ContactSurface/Edit/1 ) I am getting error : Cannot bind source type CleanBlog.Core.ViewModels.ContactViewModel to model type Umbraco.Core.Models.PublishedContent.IPublishedContent. as i need model to be passed to the view

    Hope my issue is clear and please do let me know if you need any further information

    Thanks in advance

  • sai kiran 4 posts 93 karma points
    Feb 27, 2020 @ 23:13
    sai kiran
    100

    I have used TempData["something"] and assigned model to this, which is passed on to partial view in return

    Helped me in solving my problem, but not sure if this is correct approach.

Please Sign in or register to post replies

Write your reply to:

Draft