c# - Sequence contains no elements server side -
i developing asp.net mvc web application , have been deploying web server few months now. have experienced new error confused me. upon publishing application, , loading website, following error message:
sequence contains no elements description: unhandled exception occurred during execution of current web request. please review stack trace more information error , originated in code. exception details: system.invalidoperationexception: sequence contains no elements source error: unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using exception stack trace below. stack trace: [invalidoperationexception: sequence contains no elements] system.linq.enumerable.first(ienumerable`1 source) +514 system.linq.queryable.first(iqueryable`1 source) +330 labsys.mvcapplication.application_authorizerequest(object sender, eventargs e) +1261 system.web.synceventexecutionstep.system.web.httpapplication.iexecutionstep.execute() +92 system.web.httpapplication.executestep(iexecutionstep step, boolean&completedsynchronously) +165
i confused, because application runs on localhost, without issue or error message. checked database, , connected , validated server. there should no error.
thanks in advance!
check in code make sure firstordefault() or singleordefault() used instead of using of these: first() or single().
when thelinq error "sequence contains no elements", because using first() or single() command rather firstordefault() , singleordefault().
Comments
Post a Comment