?
Solved

Try Catch  question

Posted on 2011-09-29
2
Medium Priority
?
255 Views
Last Modified: 2012-06-21
I'm looking at this code:
    protected void Page_Load(object sender, EventArgs e)
    {
        //Session["LoggedOut"] = true;  removed trs 09/26/2011
        //Session["IsLoggedIn"] = false;  removed trs 09/26/2011
        log4net.ThreadContext.Properties["Action"] = "Logout";
        log.Info("User Logged Out");
        Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddYears(-1);
        FormsAuthentication.SignOut();
        Session.Abandon();
        //Session.Clear();// hold trs 09/26/2011'
        Response.Redirect("~/weblogin.aspx");
        //FormsAuthentication.RedirectToLoginPage();
    }
}
 Would I need a try/catch for the response.redirect to sink the theardAbortException when it calls the response.end?  What would that look like.
0
Comment
Question by:TimSweet220
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
richard_hughes earned 2000 total points
ID: 36890858
Hello TimSweet220

No, you would not need a Try/Catch block in order for this.Response.Redirect to work. Response.Redirect works in 2 different ways:

this.Response.Redirect("~/MyPage.aspx");

and

this.Response.Redirect("~/MyPage.aspx", true);

The above examples do not perform an actual redirect themselves. They return a HTTP code which tells the browser to redirect to the respective page, similar to if you typed it into the address yourself.

The difference with the 2nd example is it stops the response (and the thread eventually) there and then. The first example lets the response continue as normal.

With either example no Try/Catch block is needed.

Thanks,

Richard Hughes
0
 

Author Closing Comment

by:TimSweet220
ID: 36892241
Perfect
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month10 days, 12 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question