i getting glass mapper exception in project solution follow
stack trace: [mapperexception: can not convert value permanentredirect enum type ielts.web.ielts.models.redirections.statuscodes] glass.mapper.sc.datamappers.sitecorefieldenummapper.getfieldvalue(string fieldvalue, sitecorefieldconfiguration config, sitecoredatamappingcontext context) +280 glass.mapper.sc.datamappers.abstractsitecorefieldmapper.getfield(field field, sitecorefieldconfiguration config, sitecoredatamappingcontext context) +124 [mapperexception: failed map field type value permanentredirect] glass.mapper.sc.datamappers.abstractsitecorefieldmapper.getfield(field field, sitecorefieldconfiguration config, sitecoredatamappingcontext context) +326 glass.mapper.abstractdatamapper.mapcmstoproperty(abstractdatamappingcontext mappingcontext) +29 glass.mapper.configuration.abstracttypeconfiguration.mappropertiestoobject(object obj, iabstractservice service, abstracttypecreationcontext context) +158 [mapperexception: failed map property type on ielts.web.ielts.models.redirections.redirection] glass.mapper.configuration.abstracttypeconfiguration.mappropertiestoobject(object obj, iabstractservice service, abstracttypecreationcontext context) +488 glass.mapper.pipelines.objectconstruction.tasks.createconcrete.createconcretetask.createobject(objectconstructionargs args) +295 glass.mapper.pipelines.objectconstruction.tasks.createconcrete.createconcretetask.execute(objectconstructionargs args) +215 glass.mapper.pipelines.abstractpipelinerunner`2.run(t args) +225 glass.mapper.abstractservice.instantiateobject(abstracttypecreationcontext abstracttypecreationcontext) +170 glass.mapper.sc.sitecoreservice.createtype(type type, item item, boolean islazy, boolean infertype, object[] constructorparameters) +265 glass.mapper.sc.sitecoreservice.createtype(item item, boolean islazy, boolean infertype) +109 glass.mapper.sc.sitecorecontext.getcurrentitem(boolean islazy, boolean infertype) +90 ielts.web.ielts.controllers.redirectioncontroller.redirect() in c:\idpnow\trunk\src\ielts.web\ielts\controllers\redirectioncontroller.cs:15 lambda_method(closure , controllerbase , object[] ) +79 system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) +261 system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) +39 system.web.mvc.<>c__displayclass15.<invokeactionmethodwithfilters>b__12() +124 system.web.mvc.controlleractioninvoker.invokeactionmethodfilter(iactionfilter filter, actionexecutingcontext precontext, func`1 continuation) +681242 system.web.mvc.controlleractioninvoker.invokeactionmethodfilter(iactionfilter filter, actionexecutingcontext precontext, func`1 continuation) +681242 system.web.mvc.controlleractioninvoker.invokeactionmethodwithfilters(controllercontext controllercontext, ilist`1 filters, actiondescriptor actiondescriptor, idictionary`2 parameters) +307 system.web.mvc.controlleractioninvoker.invokeaction(controllercontext controllercontext, string actionname) +345 my rendering class looks below,
public class redirection : renderingmodel { [sitecorefield("destination")] public virtual glass.mapper.sc.fields.link destination { get; set; } [sitecorefield("type")] public virtual statuscodes type { get; set; } } public enum statuscodes { permanent = 301, temporary = 302 } my controller method looks like,
public actionresult redirect() { var context = new sitecorecontext(idptemplates.currentcontext); var redirection = context.getcurrentitem<redirection>(); return new redirectresult(redirection.destination.url, convert.toint32(redirection.type) == 301); } in above method getting exception @ var redirection = context.getcurrentitem(); line.
your fieldvalue contains 'permanentredirect' enum not have value. has: 'permanent' , 'temporary'.
the names must have exact match (case sensitive). maybe changed @ point in time? or maybe have wrong default value?
Comments
Post a Comment