Copied to clipboard

Flag this post as spam?

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


  • stephen 83 posts 124 karma points
    Mar 01, 2017 @ 16:49
    stephen
    0

    RenderMvcController Fails

    View

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<Namespace.Models.SAMLSSOService_IDENTITY>
    
    @{ Layout = "SingleSignOnMaster.cshtml";}
    
    <p>@Model.MyNewProperty is my new property</p>
    

    Controller

    public class SAMLSSOService_IDENTITYController : RenderMvcController{
    
    public ActionResult SingleSignOn(RenderModel model)
        {
    
           var beedle = new SAMLSSOService_IDENTITY(model.Content);
           beedle.MyNewProperty = "HOORAY2";
    
            SAMLSSOService_IDENTITY model1 = new SAMLSSOService_IDENTITY(model.Content);
            model1.MyNewProperty = "HOORAY1";
    
    //trying a few options
            //return View(beedle);
            return CurrentTemplate(model1);
        }
    

    }

    Model

    public class SAMLSSOService_IDENTITY : RenderModel
    {
        public string MyNewProperty;
    
        public SAMLSSOService_IDENTITY(IPublishedContent content)
        :  base(content)
      {
      }
    

    }

    DocumentType is SAMLSSOService_IDENTITY Template is SingleSignOn

    ERROR: The model item passed into the dictionary is of type 'Umbraco.Web.Models.RenderModel', but this dictionary requires a model item of type 'Namespace.Models.SAMLSSOService_IDENTITY'.

  • Mark Bowser 273 posts 860 karma points c-trib
    Mar 01, 2017 @ 17:40
    Mark Bowser
    0

    Try this

    MODEL

    public class SAMLSSOService_IDENTITY : RenderModel
    {
        public string MyNewProperty;
    
        public SAMLSSOService_IDENTITY(IPublishedContent content) :  base(content)
        {
            MyNewProperty = "HOORAY2";
        }
    }
    

    CONTROLLER

    public class SAMLSSOService_IDENTITYController : RenderMvcController
    {
        public ActionResult SingleSignOn(RenderModel model)
        {
            var beedle = new SAMLSSOService_IDENTITY(model.Content);
            return CurrentTemplate(beedle);
        }
    }
    

    Does this help at all? If this doesn't help, the next thing I'd try is to make 100% sure that we are hitting your SingleSignOn action in your RenderMvcController. You could try hitting breakpoints or taking the above logic and putting it in the Index method like the following.

    public class SAMLSSOService_IDENTITYController : RenderMvcController
    {
        public ActionResult Index(RenderModel model)
        {
            var beedle = new SAMLSSOService_IDENTITY(model.Content);
            return CurrentTemplate(beedle);
        }
    }
    

    I also wonder if the problem has to do with the underscore in your controller name. Can you check on the document type alias of your document type? If the doc type alias doesn't have an underscore, the controller shouldn't either. If using the Index action doesn't help, try removing the underscore from the controller name.

  • stephen 83 posts 124 karma points
    Mar 02, 2017 @ 08:57
    stephen
    0

    Thanks Mark, I'll try this out and get back

  • stephen 83 posts 124 karma points
    Mar 02, 2017 @ 09:21
    stephen
    0

    Got it working (not quite sure but I removed underscore) I created a new DocType, Controller, Model and Template. For anyone else, here it is below.

    DocType = SSO Template = SSOPage

    Model

    public class SSO : RenderModel
    {
        public string MyNewProperty;
    
        public SSO(IPublishedContent content)
        :  base(content)
        {
            MyNewProperty = "HOORAY2";
        }
    }
    

    Controller

    public class SSOController : RenderMvcController
    {
        public ActionResult SSOPage(RenderModel model)
        {
            var beedle = new SSO(model.Content);
            return CurrentTemplate(beedle);
        }
    }
    

    Template

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<Namespace.Models.SSO>
    @{
    Layout = "SingleSignOnMaster.cshtml";
    }
    
    <p>@Model.MyNewProperty is my new property</p>
    
Please Sign in or register to post replies

Write your reply to:

Draft