Wie kann ich diese Stack-Trace verwenden, um zu sagen, was dazu führt, dass die Aktion meines Controllers bricht?

StackOverflow https://stackoverflow.com/questions/5044056

  •  15-11-2019
  •  | 
  •  

Frage

In meiner ASP.NET-MVC-App habe ich einen Ansicht, dass er generationstabelletagcode ist. Ich habe ein ähnliches Szenario in einem anderen Controller und es funktioniert gut, aber in diesem Fall bricht es.Ich stellte einen Haltepunkt in der ersten Zeile des GROSSENACODICETICETAGCODE ein, aber es bricht nicht, so dass der Fehler vor diesem Zeitpunkt im Code auftreten muss. generasacodicetagpre.

Wie kann ich von diesem Stack-Trace herunterkommen, um den Code in meiner Anwendung herauszufinden, der die Ausnahme verursacht?

War es hilfreich?

Lösung

This particular problem is:

System.Web.HttpException: Server cannot set status after HTTP headers have been sent.
at System.Web.HttpResponse.set_StatusCode(Int32 value)
at System.Web.HttpResponseWrapper.set_StatusCode(Int32 value)
at Cobalt.Website.Platform.Web.Controllers.Controller.OnException(ExceptionContext filterContext) in D:\data\Website\App\Website\Controllers\Controller.cs:line 920

Your exception handler is trying to set the response status code after the server has started outputting page content. You should try/catch the StatusCode set I guess, and put a breakpoint in the OnException code to see what the real exception is, although it appears to be from

d:\data\Website\App\Website\Search\Views\SearchResults.aspx:line 39

Incidentally Html.Action generates the URL that triggers a particular action, and doesn't call the action itself. Did you mean Html.RenderAction? I'm not sure passing the model in is correct, though - it's unlikely to have the route values as-is?

Andere Tipps

I was able to get rid of this by returning a view() in the action other than retrun RedirectToAction("SomeAction");

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top