Ich versuche, die Antwort mit Context.Response.End
zu schließen, aber Fehler "Thread was being aborted"
erhalten.Context.Response.End() und Thread wurde abgebrochen
Wie schließe ich die Antwort richtig, ohne eine Ausnahme auszulösen?
try {
Context.Response.Clear();
Context.Response.ContentType = "text/html";
//Context.Response.ContentType = "application/json";
JsonObjectCollection collection = new JsonObjectCollection();
collection.Add(new JsonNumericValue("resultcode", 1));
collection.Add(new JsonStringValue("sourceurl", exchangeData.cUrl));
collection.Add(new JsonStringValue("filename", fileName));
collection.Add(new JsonStringValue("filesize", fileSize));
collection.Add(new JsonStringValue("fileurl", Common.GetPDFURL + outputFileName));
JsonUtility.GenerateIndentedJsonText = true;
Context.Response.Write(collection);
try {
Context.Response.End();
} catch (ThreadAbortException exc) {
// This should be first catch block i.e. before generic Exception
// This Catch block is to absorb exception thrown by Response.End
}
} catch (Exception err) {
}
von mir gelöst, sollte der Code aussehen
try {
Context.Response.End();
} catch (ThreadAbortException err) {
}
catch (Exception err) {
}
beurteilen Sie die respose.end in einem Try-Catch-Block haben? – Andrew
Ich habe meinen Code hinzugefügt. Ja, ich habe Context.Response.End(); Innerhalb Try/catch block und wie Sie sehen, gibt es Haupt Try/catch-Block, der auch Catch-Fehler "Thread wurde abgebrochen". – Tomas
von mir gelöst, sollte der Code aussehen versuchen { } catch (Threadabort err) { } catch (Exception err) { } – Tomas