开发者

Error handling in ASHX code

I created an ASHX file and use it to handle async file uploads. Since the site might not be hosted on our servers, I want to check for write permissions and delete permissions and supply the end use开发者_开发知识库r (site content editor in this case) with an error they can deal with.

I'm using uploadify for the upload, I'm not sure, but I`m guessing this complicates the return of a message that can be shown on the page, but maybe not.


I ended up using the c# code in ashx file to check for permissions on the directory and returned different status codes as JSON objects.

context.response.write("{success: 'false', message: '" + ex + "'}")

And in the client side JS I just access response.message if response.success = false. Everything works well.

Thank you!


Before the user is able to attempt an upload, trying writing and reading a small file to the destination on the server (on the server side), if this fails then you can supply them with an appropriate message.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜