Can not render new view on action link of UmbracoViewPage
Hi,
I am getting following error while clicking on ModifyComponent action link.
No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[MissingMethodException: No parameterless constructor defined for this object. Object type 'Umbraco.Web.Models.RenderModel'.]
Below are the controller and models which I am using for this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Umbraco.Core.Models;
using Umbraco.Web;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
namespace LMS.Controllers
{
public class ClassType : RenderModel
{
public ClassType() : this(new UmbracoHelper(UmbracoContext.Current).TypedContent(UmbracoContext.Current.PageId)) { }
public ClassType(IPublishedContent content) : base(content) { }
public int Id { get; set; }
public string Name { get; set; }
}
public class ViewAllClassTypes: RenderModel
{
public ViewAllClassTypes() : this(new UmbracoHelper(UmbracoContext.Current).TypedContent(UmbracoContext.Current.PageId)) { }
public ViewAllClassTypes(IPublishedContent content) : base(content) { }
public List<ClassType> ClassTypes { get; set; }
}
public class ClassTypesController : SurfaceController, IRenderMvcController
{
public ActionResult Index(RenderModel model)
{
var classTypes = new List<ClassType>
{
new ClassType(model.Content) {Id = 1, Name = "Class A" },
new ClassType(model.Content) {Id = 1, Name = "Class B" }
};
var viewModel = new ViewAllClassTypes(model.Content) { ClassTypes = classTypes };
return View(viewModel);
}
[HttpGet]
[ActionName("ModifyClassType")]
public ActionResult ModifyClassType(RenderModel model, int Id)
{
var viewModel = new ClassType(model.Content){ Id = 1, Name = "Class C" };
return View(viewModel);
}
}
}
Below is the main view page:
@@inherits Umbraco.Web.Mvc.UmbracoTemplatePage@
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@* the fun starts here *@
@{
@foreach (var item in Model.ClassTypes)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
<div class="tableLinks">
@Html.ActionLink("ModifyClassType", "modifyClassType", "ClassTypes", new { Id = item.Id }, new { @class = "updateImage" }))
</div>
</td>
</tr>
}
</table>
}
And the last is ModifyClassType view:
@@inherits Umbraco.Web.Mvc.UmbracoTemplatePage@
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@* the fun starts here *@
@{
Id
Component Name
Actions
@foreach (var item in Model.ClassTypes)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
<div class="tableLinks">
@Html.ActionLink("ModifyClassType", "modifyClassType", "ClassTypes", new { Id = item.Id }, new { @class = "updateImage" }))
</div>
</td>
</tr>
}
</table>
}
Please let me know how to resolve this error and proceed further.
Can not render new view on action link of UmbracoViewPage
Hi, I am getting following error while clicking on ModifyComponent action link.
No parameterless constructor defined for this object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[MissingMethodException: No parameterless constructor defined for this object.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +114 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +232 System.Activator.CreateInstance(Type type, Boolean nonPublic) +83 System.Activator.CreateInstance(Type type) +11 System.Web.Mvc.DefaultModelBinder.CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) +197
[MissingMethodException: No parameterless constructor defined for this object. Object type 'Umbraco.Web.Models.RenderModel'.]
Below are the controller and models which I am using for this using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Umbraco.Core.Models; using Umbraco.Web; using Umbraco.Web.Models; using Umbraco.Web.Mvc;
namespace LMS.Controllers { public class ClassType : RenderModel { public ClassType() : this(new UmbracoHelper(UmbracoContext.Current).TypedContent(UmbracoContext.Current.PageId)) { } public ClassType(IPublishedContent content) : base(content) { } public int Id { get; set; } public string Name { get; set; } }
}
Below is the main view page: @@inherits Umbraco.Web.Mvc.UmbracoTemplatePage@
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@* the fun starts here *@
@{
}
And the last is ModifyClassType view: @@inherits Umbraco.Web.Mvc.UmbracoTemplatePage@
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@* the fun starts here *@
@{
}
Please let me know how to resolve this error and proceed further.
I have the same problem
is working on a reply...