c# - How can I use this stack trace to tell what is causing my controller's action to break? -


in asp.net mvc app, have view that's calling html.action("myaction", this.model) - have similar scenario in different controller , works fine, in case, breaks. set breakpoint on first line of myaction, it's not breaking, error must occur before point in code.

system.web.httpexception: error executing child request handler 'system.web.mvc.httphandlerutil+serverexecutehttphandlerwrapper'. ---&gt; system.web.httpunhandledexception: exception of type 'system.web.httpunhandledexception' thrown. ---&gt; system.web.httpexception: error executing child request handler 'system.web.mvc.httphandlerutil+serverexecutehttphandlerasyncwrapper'. ---&gt; system.web.httpexception: server cannot set status after http headers have been sent.    @ system.web.httpresponse.set_statuscode(int32 value)    @ system.web.httpresponsewrapper.set_statuscode(int32 value)    @ cobalt.website.platform.web.controllers.controller.onexception(exceptioncontext filtercontext) in d:\data\website\app\website\controllers\controller.cs:line 920    @ system.web.mvc.controller.system.web.mvc.iexceptionfilter.onexception(exceptioncontext filtercontext)    @ system.web.mvc.controlleractioninvoker.invokeexceptionfilters(controllercontext controllercontext, ilist`1 filters, exception exception)    @ system.web.mvc.controlleractioninvoker.invokeaction(controllercontext controllercontext, string actionname)    @ system.web.mvc.controller.executecore()    @ system.web.mvc.controllerbase.execute(requestcontext requestcontext)    @ system.web.mvc.controllerbase.system.web.mvc.icontroller.execute(requestcontext requestcontext)    @ system.web.mvc.mvchandler.&lt;&gt;c__displayclass8.&lt;beginprocessrequest&gt;b__4()    @ system.web.mvc.async.asyncresultwrapper.&lt;&gt;c__displayclass1.&lt;makevoiddelegate&gt;b__0()    @ system.web.mvc.async.asyncresultwrapper.&lt;&gt;c__displayclass8`1.&lt;beginsynchronous&gt;b__7(iasyncresult _)    @ system.web.mvc.async.asyncresultwrapper.wrappedasyncresult`1.end()    @ system.web.mvc.mvchandler.endprocessrequest(iasyncresult asyncresult)    @ system.web.mvc.mvchandler.system.web.ihttpasynchandler.endprocessrequest(iasyncresult result)    @ system.web.mvc.httphandlerutil.serverexecutehttphandlerasyncwrapper.&lt;&gt;c__displayclassa.&lt;endprocessrequest&gt;b__9()    @ system.web.mvc.httphandlerutil.serverexecutehttphandlerwrapper.&lt;&gt;c__displayclass4.&lt;wrap&gt;b__3()    @ system.web.mvc.httphandlerutil.serverexecutehttphandlerwrapper.wrap[tresult](func`1 func)    @ system.web.mvc.httphandlerutil.serverexecutehttphandlerwrapper.wrap(action action)    @ system.web.mvc.httphandlerutil.serverexecutehttphandlerasyncwrapper.endprocessrequest(iasyncresult result)    @ system.web.httpserverutility.executeinternal(ihttphandler handler, textwriter writer, boolean preserveform, boolean setpreviouspage, virtualpath path, virtualpath filepath, string physpath, exception error, string querystringoverride)    --- end of inner exception stack trace ---    @ system.web.httpserverutility.executeinternal(ihttphandler handler, textwriter writer, boolean preserveform, boolean setpreviouspage, virtualpath path, virtualpath filepath, string physpath, exception error, string querystringoverride)    @ system.web.httpserverutility.execute(ihttphandler handler, textwriter writer, boolean preserveform, boolean setpreviouspage)    @ system.web.httpserverutility.execute(ihttphandler handler, textwriter writer, boolean preserveform)    @ system.web.httpserverutilitywrapper.execute(ihttphandler handler, textwriter writer, boolean preserveform)    @ system.web.mvc.html.childactionextensions.actionhelper(htmlhelper htmlhelper, string actionname, string controllername, routevaluedictionary routevalues, textwriter textwriter)    @ system.web.mvc.html.childactionextensions.action(htmlhelper htmlhelper, string actionname, string controllername, routevaluedictionary routevalues)    @ system.web.mvc.html.childactionextensions.action(htmlhelper htmlhelper, string actionname, object routevalues)    @ asp.search_views_searchresults_aspx.__rendercontent7(htmltextwriter __w, control parametercontainer) in d:\data\website\app\website\search\views\searchresults.aspx:line 39    @ system.web.ui.control.renderchildreninternal(htmltextwriter writer, icollection children)    @ system.web.ui.control.renderchildren(htmltextwriter writer)    @ system.web.ui.control.render(htmltextwriter writer)    @ system.web.ui.control.rendercontrolinternal(htmltextwriter writer, controladapter adapter)    @ system.web.ui.control.rendercontrol(htmltextwriter writer, controladapter adapter)    @ system.web.ui.control.rendercontrol(htmltextwriter writer)    @ asp.views_shared_masters_cobaltpage_master.__rendercoid_website_pagecontent(htmltextwriter __w, control parametercontainer) in d:\data\website\app\website\views\shared\masters\cobaltpage.master:line 50    @ system.web.ui.control.renderchildreninternal(htmltextwriter writer, icollection children)    @ system.web.ui.control.renderchildren(htmltextwriter writer)    @ system.web.ui.control.render(htmltextwriter writer)    @ system.web.ui.control.rendercontrolinternal(htmltextwriter writer, controladapter adapter)    @ system.web.ui.control.rendercontrol(htmltextwriter writer, controladapter adapter)    @ system.web.ui.control.rendercontrol(htmltextwriter writer)    @ asp.views_shared_masters_cobaltstatic_master.__render__control1(htmltextwriter __w, control parametercontainer) in d:\data\website\app\website\views\shared\masters\cobaltstatic.master:line 78    @ system.web.ui.control.renderchildreninternal(htmltextwriter writer, icollection children)    @ system.web.ui.control.renderchildren(htmltextwriter writer)    @ system.web.ui.control.render(htmltextwriter writer)    @ system.web.ui.control.rendercontrolinternal(htmltextwriter writer, controladapter adapter)    @ system.web.ui.control.rendercontrol(htmltextwriter writer, controladapter adapter)    @ system.web.ui.control.rendercontrol(htmltextwriter writer)    @ system.web.ui.control.renderchildreninternal(htmltextwriter writer, icollection children)    @ system.web.ui.control.renderchildren(htmltextwriter writer)    @ system.web.ui.control.render(htmltextwriter writer)    @ system.web.ui.control.rendercontrolinternal(htmltextwriter writer, controladapter adapter)    @ system.web.ui.control.rendercontrol(htmltextwriter writer, controladapter adapter)    @ system.web.ui.control.rendercontrol(htmltextwriter writer)    @ system.web.ui.control.renderchildreninternal(htmltextwriter writer, icollection children)    @ system.web.ui.control.renderchildren(htmltextwriter writer)    @ system.web.ui.page.render(htmltextwriter writer)    @ system.web.mvc.viewpage.render(htmltextwriter writer)    @ system.web.ui.control.rendercontrolinternal(htmltextwriter writer, controladapter adapter)    @ system.web.ui.control.rendercontrol(htmltextwriter writer, controladapter adapter)    @ system.web.ui.control.rendercontrol(htmltextwriter writer)    @ system.web.ui.page.processrequestmain(boolean includestagesbeforeasyncpoint, boolean includestagesafterasyncpoint)    --- end of inner exception stack trace ---    @ system.web.ui.page.handleerror(exception e)    @ system.web.ui.page.processrequestmain(boolean includestagesbeforeasyncpoint, boolean includestagesafterasyncpoint)    @ system.web.ui.page.processrequest(boolean includestagesbeforeasyncpoint, boolean includestagesafterasyncpoint)    @ system.web.ui.page.processrequest()    @ system.web.ui.page.processrequestwithnoassert(httpcontext context)    @ system.web.ui.page.processrequest(httpcontext context)    @ system.web.mvc.viewpage.processrequest(httpcontext context)    @ asp.search_views_searchresults_aspx.processrequest(httpcontext context) in c:\windows\microsoft.net\framework\v2.0.50727\temporary asp.net files\root\4bd59adb\8512bc8c\app_web_creqrbqh.4.cs:line 0    @ system.web.mvc.httphandlerutil.serverexecutehttphandlerwrapper.&lt;&gt;c__displayclass1.&lt;processrequest&gt;b__0()    @ system.web.mvc.httphandlerutil.serverexecutehttphandlerwrapper.&lt;&gt;c__displayclass4.&lt;wrap&gt;b__3()    @ system.web.mvc.httphandlerutil.serverexecutehttphandlerwrapper.wrap[tresult](func`1 func)    @ system.web.mvc.httphandlerutil.serverexecutehttphandlerwrapper.wrap(action action)    @ system.web.mvc.httphandlerutil.serverexecutehttphandlerwrapper.processrequest(httpcontext context)    @ system.web.httpserverutility.executeinternal(ihttphandler handler, textwriter writer, boolean preserveform, boolean setpreviouspage, virtualpath path, virtualpath filepath, string physpath, exception error, string querystringoverride)    --- end of inner exception stack trace ---    @ system.web.httpserverutility.executeinternal(ihttphandler handler, textwriter writer, boolean preserveform, boolean setpreviouspage, virtualpath path, virtualpath filepath, string physpath, exception error, string querystringoverride)    @ system.web.httpserverutility.execute(ihttphandler handler, textwriter writer, boolean preserveform, boolean setpreviouspage)    @ system.web.httpserverutility.execute(ihttphandler handler, textwriter writer, boolean preserveform)    @ system.web.httpserverutilitywrapper.execute(ihttphandler handler, textwriter writer, boolean preserveform)    @ system.web.mvc.viewpage.renderview(viewcontext viewcontext)    @ system.web.mvc.webformview.renderviewpage(viewcontext context, viewpage page)    @ system.web.mvc.webformview.render(viewcontext viewcontext, textwriter writer)    @ system.web.mvc.viewresultbase.executeresult(controllercontext context)    @ system.web.mvc.controlleractioninvoker.invokeactionresult(controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.&lt;&gt;c__displayclass14.&lt;invokeactionresultwithfilters&gt;b__11()    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilter(iresultfilter filter, resultexecutingcontext precontext, func`1 continuation)    @ system.web.mvc.controlleractioninvoker.&lt;&gt;c__displayclass14.&lt;&gt;c__displayclass16.&lt;invokeactionresultwithfilters&gt;b__13()    @ system.web.mvc.controlleractioninvoker.invokeactionresultwithfilters(controllercontext controllercontext, ilist`1 filters, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeaction(controllercontext controllercontext, string actionname)--> </div> 

how can stack trace figuring out code in application causes exception?

this particular problem is:

system.web.httpexception: server cannot set status after http headers have been sent.
@ system.web.httpresponse.set_statuscode(int32 value)
@ system.web.httpresponsewrapper.set_statuscode(int32 value)
@ cobalt.website.platform.web.controllers.controller.onexception(exceptioncontext filtercontext) in d:\data\website\app\website\controllers\controller.cs:line 920

your exception handler trying set response status code after server has started outputting page content. should try/catch statuscode set guess, , put breakpoint in onexception code see real exception is, although appears from

d:\data\website\app\website\search\views\searchresults.aspx:line 39

incidentally html.action generates url triggers particular action, , doesn't call action itself. did mean html.renderaction? i'm not sure passing model in correct, though - it's unlikely have route values as-is?


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -