Solved

How to code a try catch?

Posted on 2008-10-01
3
442 Views
Last Modified: 2012-06-27
I am new to programming. I am writing a web site for my fantasy football league using VS 2005 in C#. The website does not display correctly in firefox. IE works great. SO my thought was to use a try catch statement to check the web browser if IE continue on if any other browser then catch and reload website in IE. I am correct in my thinking. If so how would I go about coding this.
Thanks in advance for any help. DL
0
Comment
Question by:dxladner
3 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 50 total points
ID: 22621189
the try/catch approach is not the right way. First, it is slow, when an exception is produced the program slowly processes the exception.
So, you just have to store the browser type in a session variable and put some IF statements to handle them properly.
0
 
LVL 15

Assisted Solution

by:angus_young_acdc
angus_young_acdc earned 50 total points
ID: 22622154
As stated a try catch may not be the best method, however I would put it in your backend code to handle any "gotchas"

To create a try catch its simply:

try
{
      // Your code would go here you wish to use.
}
catch(Exception ex)
{
      throw ex;
      // You would have your own exception handling here that would be far better
      // than a rather poor throw
}

Have the try be the first thing in your method.  You can also add a "finally{}" to the try catch.
0
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 25 total points
ID: 22628076
a website in ASP.NET always works fine with IE, but there are certian things which if corrected will make it work with all other browsers
I will recommend that you should not force the users to only view your website using IE - it might turn away a few users because they dont like using IE for browsing purposes

Just make your site compatiable with all the browsers that will be the ideal solution
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

803 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