简体   繁体   中英

Strange exception when using Async in .net application

I created an asp.net application that asks users to add titles to a set of videos on a web page, and after it's submitted, begins writing manifest files and uploading the videos on a separate thread, using .net async. Most of the time it works well, however every once in a while I get the following exception:

System.Threading.ThreadAbortException: Thread was being aborted.     
    at System.Net.UnsafeNclNativeMethods.OSSOCK.send(IntPtr socketHandle, Byte* pinnedBuffer, Int32 len, SocketFlags socketFlags)     
    at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)

If anyone can let me know what this exception means, and what could be triggering it.

This is usually a timeout error.

Have you set a timeout or MaxLength for the file being uploaded? It could be exceeding the default values.

You can set them in your web.config

<system.web>
    <httpRuntime executionTimeout="9999999" maxRequestLength="2048000" />
</system.web>

Is it possible that your background thread is trying to write to the network after the initial web page request has completed? If so, the net connection will be gone, and you'll get an Exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM