Sto tentando di chiudere la risposta utilizzando Context.Response.End
ma si riceve l'errore "Thread was being aborted"
.Context.Response.End() e il thread è stato interrotto
Come chiudere correttamente la risposta senza attivare un'eccezione?
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) {
}
risolto da solo, il codice dovrebbe assomigliare
try {
Context.Response.End();
} catch (ThreadAbortException err) {
}
catch (Exception err) {
}
Avete il respose.end all'interno di un blocco try trucco? – Andrew
Ho aggiunto il mio codice. Sì, ho aggiunto Context.Response.End(); all'interno di Try/catch block e come vedi c'è il blocco Try/catch principale che è anche un errore di cattura "Thread was aborted". – Tomas
Risolto da me, il codice dovrebbe essere simile provare {} catch (err ThreadAbortException) {} catch (Exception err) {} – Tomas