Wednesday, 15 June 2011

c# - asp.net mvc: Error1: Value cannot be null -



c# - asp.net mvc: Error1: Value cannot be null -

i have signup page. works in local computer, after deployed production. kept getting next error message

server error in '/' application. error1: value cannot null. parameter name: view description: unhandled exception occurred during execution of current web request. please review stack trace more info error , originated in code. exception details: system.exception: error1: value cannot null. parameter name: view source error: unhandled exception generated during execution of current web request. info regarding origin , location of exception can identified using exception stack trace below. stack trace: [exception: error1: value cannot null. parameter name: view] smoothie.web.controllers.accountcontroller.signup(userregisterviewmodel user, string returnurl) +662 lambda_method(closure , controllerbase , object[] ) +149 system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters) +14 system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) +181 system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) +27 system.web.mvc.<>c__displayclass15.<invokeactionmethodwithfilters>b__12() +56 system.web.mvc.controlleractioninvoker.invokeactionmethodfilter(iactionfilter filter, actionexecutingcontext precontext, func`1 continuation) +256 system.web.mvc.<>c__displayclass17.<invokeactionmethodwithfilters>b__14() +22 system.web.mvc.controlleractioninvoker.invokeactionmethodwithfilters(controllercontext controllercontext, ilist`1 filters, actiondescriptor actiondescriptor, idictionary`2 parameters) +190 system.web.mvc.controlleractioninvoker.invokeaction(controllercontext controllercontext, string actionname) +311 system.web.mvc.controller.executecore() +105 system.web.mvc.controllerbase.execute(requestcontext requestcontext) +88 system.web.mvc.controllerbase.system.web.mvc.icontroller.execute(requestcontext requestcontext) +10 system.web.mvc.<>c__displayclassb.<beginprocessrequest>b__5() +34 system.web.mvc.async.<>c__displayclass1.<makevoiddelegate>b__0() +19 system.web.mvc.async.<>c__displayclass8`1.<beginsynchronous>b__7(iasyncresult _) +10 system.web.mvc.async.wrappedasyncresult`1.end() +55 system.web.mvc.<>c__displayclasse.<endprocessrequest>b__d() +31 system.web.mvc.securityutil.<getcallinapptrustthunk>b__0(action f) +7 system.web.mvc.securityutil.processinapplicationtrust(action action) +23 system.web.mvc.mvchandler.endprocessrequest(iasyncresult asyncresult) +59 system.web.mvc.mvchandler.system.web.ihttpasynchandler.endprocessrequest(iasyncresult result) +9 system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +9690172 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +155

here's code, spent whole day debug it, still no luck.

//[childactiononly] public virtual actionresult signup(string returnurl) { homecoming partialview(mvc.account.views._register, new userregisterviewmodel()); //return partialview("_register", new userregisterviewmodel()); } [httppost] [validateantiforgerytoken] public virtual actionresult signup(userregisterviewmodel user, string returnurl) { seek { if (modelstate.isvalid) { var newuser = _mappingservice.map<userregisterviewmodel, user>(user); if (newuser == null) { throw new exception("newuser cannot null"); } var confirmation = _userservice.adduser(newuser, accounttype.smoothie); if (confirmation.wassuccessful) { var userdata = _mappingservice.map<user, userdatadto>(confirmation.value); if (userdata == null) { throw new exception("userdata cannot null"); } _authenticationservice.setauthcookie(response, userdata.displayname, false, userdata); utilities.sendemail(configurationmanager.appsettings["emailreply"], new list<string> {userdata.email}, "welcome putastrawinit.com", getwelcomeemail()); var redirecturl = "/home"; if (returnurl != null && url.islocalurl(returnurl)) { redirecturl = returnurl; } homecoming json(new {success = true, redirecturl = redirecturl}); //return redirecttoaction("index", "home", null); } modelstate.addmodelerror("", confirmation.message); } } grab (exception e) { throw new exception("error1: " + e.message); } var errors = value in modelstate.values error in value.errors select new { error.errormessage }; //throw new exception("errors: " + errors.tostring()); homecoming json(new { success = false, errormessages = errors }); }

sign view page.

@model smoothie.domain.viewmodels.userregisterviewmodel @using (ajax.beginform("signup", "account", new ajaxoptions { onsuccess = "onsignupsuccess", onfailure = "onsignupfailure" })) { @html.antiforgerytoken() @html.hidden("returnurl", null, new { value = @request.querystring["returnurl"] }) <div class="signupform"> <div>@html.validationsummary("", new { @id = "signupsummary" })</div> <div class="row"> <label for="email"> display name:</label> @html.editorfor(m => m.displayname) </div> <div class="row"> <label for="email"> email address:</label> @html.textboxfor(m => m.email, new {@class = "text-box", autocomplete = "off" }) </div> <div class="row"> <label for="password"> password:</label> @html.textbox("password", null, new { @class = "registerpassword text-box", type = "password", autocomplete = "off" }) </div> <div class="row"> <label> &nbsp;</label> <div class="registerchecker"> </div> </div> <div class="row"> <label> &nbsp;</label> <input type="image" src="@links.content.images.btn_sign_up_png" style="width: 91px; height: 33px;" value="create" /> </div> </div> }

this viewmodel.

using system.componentmodel.dataannotations; namespace smoothie.domain.viewmodels { public class userregisterviewmodel { [required(errormessage = "email required")] [stringlength(255, errormessage = "email must 50 characters or fewer")] [regularexpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", errormessage = "your email address invalid")] public string email { get; set; } [required(errormessage = "display name required")] [stringlength(25, minimumlength = 2, errormessage = "display name must between 2 , 25 characters")] public string displayname { get; set; } [datatype(datatype.password)] [required(errormessage = "password required")] [stringlength(25, minimumlength = 8, errormessage = "password must between 8 , 25 characters")] public string password { get; set; } } }

this new stack trace after removed seek grab code.

value cannot null. parameter name: view description: unhandled exception occurred during execution of current web request. please review stack trace more info error , originated in code. exception details: system.argumentnullexception: value cannot null. parameter name: view source error: unhandled exception generated during execution of current web request. info regarding origin , location of exception can identified using exception stack trace below. stack trace: [argumentnullexception: value cannot null. parameter name: view] system.web.mvc.viewcontext..ctor(controllercontext controllercontext, iview view, viewdatadictionary viewdata, tempdatadictionary tempdata, textwriter writer) +205 smoothie.web.controllers.accountcontroller.getwelcomeemail() +178 smoothie.web.controllers.accountcontroller.signup(userregisterviewmodel user) +288 lambda_method(closure , controllerbase , object[] ) +106 system.web.mvc.actionmethoddispatcher.execute(controllerbase controller, object[] parameters) +14 system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) +181 system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) +27 system.web.mvc.<>c__displayclass15.<invokeactionmethodwithfilters>b__12() +56 system.web.mvc.controlleractioninvoker.invokeactionmethodfilter(iactionfilter filter, actionexecutingcontext precontext, func`1 continuation) +256 system.web.mvc.<>c__displayclass17.<invokeactionmethodwithfilters>b__14() +22 system.web.mvc.controlleractioninvoker.invokeactionmethodwithfilters(controllercontext controllercontext, ilist`1 filters, actiondescriptor actiondescriptor, idictionary`2 parameters) +190 system.web.mvc.controlleractioninvoker.invokeaction(controllercontext controllercontext, string actionname) +311 system.web.mvc.controller.executecore() +105 system.web.mvc.controllerbase.execute(requestcontext requestcontext) +88 system.web.mvc.controllerbase.system.web.mvc.icontroller.execute(requestcontext requestcontext) +10 system.web.mvc.<>c__displayclassb.<beginprocessrequest>b__5() +34 system.web.mvc.async.<>c__displayclass1.<makevoiddelegate>b__0() +19 system.web.mvc.async.<>c__displayclass8`1.<beginsynchronous>b__7(iasyncresult _) +10 system.web.mvc.async.wrappedasyncresult`1.end() +55 system.web.mvc.<>c__displayclasse.<endprocessrequest>b__d() +31 system.web.mvc.securityutil.<getcallinapptrustthunk>b__0(action f) +7 system.web.mvc.securityutil.processinapplicationtrust(action action) +23 system.web.mvc.mvchandler.endprocessrequest(iasyncresult asyncresult) +59 system.web.mvc.mvchandler.system.web.ihttpasynchandler.endprocessrequest(iasyncresult result) +9 system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +9690172 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +155

based on latest phone call stack, looks view missing getwelcomeemail() causing view null in viewcontexts constructor.

c# asp.net-mvc asp.net-mvc-3

No comments:

Post a Comment