Give coding for Exception Handling Techniques in ASP.NET?

Answers were Sorted based on User's Feedback



Give coding for Exception Handling Techniques in ASP.NET? ..

Answer / senthil kumar

The exception handling techniques very use full to display
the errors in meaningfull way.

The syntax of exception handling as follows.

try
{

}
catch(Exception )
{

}
catch(Exception )
{

}
finally
{

}
Here the set of codes executed if any error found in try
block the catch block will be executed.We may have any
number of exception in catch but it will only one executed
according to the type of error.But the finally block must
executed automatically whether error found or not.

try
{
SqlConnection con = new SqlConnection();
con.ConnectionString =" ----";
String sql;
sql = "---";
SqlCommand cmd = new SqlCommand(sql,con);
cmd.CommandType = CommandType.Text;
cmd.ExectuteNonQuery();
}
catch(FileNotFoundException e)
{
Console.WriteLine("Error:"+e.Message);
}
catch(SqlException ee)
{
Console.WriteLine("Error:"+ee.Message);
}
finally
{
Console.WriteLine("This program written by S.Senthil
umar");
}

if this is correct ok.otherwise correct me.

Is This Answer Correct ?    12 Yes 1 No

Give coding for Exception Handling Techniques in ASP.NET? ..

Answer / ramakrishna

Sorry, i think th above answer is not clear.

In ASP.Net Exception Handling is an one of an excellent
concept given by Microsoft.

Now, let me explain you how to handle exceptions in ASP.Net?

If any exceptiuons get raised in ASP.Net it will effect to
the whole project i mean to say , if we get exception we get
a error page in the browser while loading..and that is
viewable
for the client and the user. when it is like that what is
the use of using ASP.Net.

so, to avoid this problem we have to create an Customized
Error Page and then goto web.config and write a parameter in
CustomErrors tag as

defaultRedirect = "CustomErrorPage.aspx"

and according to the security change the

mode="On/Off/RemoteOnly"

Is This Answer Correct ?    6 Yes 3 No

Give coding for Exception Handling Techniques in ASP.NET? ..

Answer / ravi

Sorry Ramakrishna , the above answer is not complete.
Can u please specify which mode to be selected & when?

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More ASP.NET Code Interview Questions

Code for Presenting Parent/Child Data in a Data Grid Row?

0 Answers   TCS,


How we implement the paypal in my website and how we make a payment through Credit Card.

2 Answers  


i have a gird with columns all are coming from database,this will bind in item templete in gridview as textboxex.and i have button below named Update.i want to update all the records in the grid,but if user change the value of one textbox,what is the easy way 2 do this

0 Answers   Crompton Greaves,


Coding for .NET Delegates?

0 Answers  


how can we close a web page in asp.net without using jscript?

4 Answers  






hold checkbox values

4 Answers  


Code for Communicating over Sockets?

0 Answers  


Coding for Synchronizing Cache Access in ASP.NET?

0 Answers  


what is the value that reside in a hidden field when no value is assigned to it?how it can be used in a if statement??

1 Answers  


Listview design in .net

1 Answers  


How to add checkbox to datagrid?

5 Answers  


How to Export Data to Excel?

4 Answers   Eastcom Systems,


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)