?
Solved

How to code a try catch?

Posted on 2008-10-01
3
Medium Priority
?
446 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
[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
3 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 150 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 150 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 75 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This article will show, step by step, how to integrate R code into a R Sweave document
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

752 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