Solved

How to code a try catch?

Posted on 2008-10-01
3
441 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Data Saving 5 56
t-sql sp_addlinkedserver possible risks 3 49
What language/protocol is the Angular Chat? 2 53
Data is not showing from images 15 37
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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 explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now