Solved

How to code a try catch?

Posted on 2008-10-01
3
440 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The purpose of this article is to demonstrate how we can use conditional statements using Python.
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 video teaches viewers about errors in exception handling.
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…

743 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

13 Experts available now in Live!

Get 1:1 Help Now