的Page

编程入门 行业动态 更新时间:2024-10-28 12:18:20
本文介绍了的Page_Load被多次调用,如果有在Page_Load中异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我写了下面code

protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { string data = Request.Form["postedData"]; if(someFunc(data)) Response.Redirect(SuccessURL, false); else Response.Redirect(FailureURL, false); } catch (Exception ex) { Response.Redirect(FailureURL, false); } } }

它工作正常,除非在Page_Load异常。从我的理解code应的页面,FailureURL重定向在异常情况下。但在我的情况下,当有Page_Load中获取与发布的数据为NULL连连称为异常。任何线索?

It works fine unless there is an exception in the Page_Load. From my understanding the code should redirect the page to FailureURL in case of an exception. But in my case when there is an exception Page_Load gets called again and again with posted data as NULL. Any clue?

推荐答案

试着改变你的重定向code这样:

Try changing your redirect code to this:

修改:新增code,以避免ThreadAbortException

EDIT: Added code to avoid ThreadAbortException

Response.Redirect(FailureURL, false); HttpContext.Current.ApplicationInstance.CompleteRequest();

更多推荐

的Page

本文发布于:2023-11-10 15:31:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575761.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Page

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!