if there is some error with db should user get redirected to a general error page?

 Hi All.

Lets say there is an error with inserting data to db, some server error or whatever should the user get redirected to an error page? 

The page i am working on is activate account so if whilst checking data with db there is a problem should the user get redirected or should the error come up on the page in question?

Help please.

0
aspd
7/9/2008 6:52:52 PM
asp.net.web-forms 93655 articles. 5 followers. Follow

6 Replies
919 Views

Similar Articles

[PageSpeed] 40

aspd:
Lets say there is an error with inserting data to db, some server error or whatever should the user get redirected to an error page? 
. If some insert/ update errors happen, then it is best to provide some feedback to the user on the page itself. However this is totally your call.


Jeev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you get the answer to your question, please mark it as the answer.
0
Jeev
7/9/2008 8:01:08 PM

 Hi, heres another one, im pretty confused on this. Lets say the user activates their account and they click on the link again, what should it do? go to an error page, do nothing? because they have already activated, this could be someone else too who is not the correct user. What is the best way?

0
aspd
7/9/2008 8:14:20 PM

 I would certainly provide some feedback. saying that the account is already activated.

Overall it depends on the way your app is structured. Eg there are certain kinds of errors / exceptions that you anticipate that  the business  layer would throw. You should ideally handle them and provide feedback to the user .Other un anticipated errors could result in a redirect to the general error page

Hope this clears things up a bit


Jeev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you get the answer to your question, please mark it as the answer.
0
Jeev
7/9/2008 8:19:12 PM

 You need to determine the difference between a logical error, and a "true error" for lack of a better term.  You can check for logical errors, and a lot of times do something about them, or provide the user information to do something about them.  The true errors, are when something fatal happens that can't be predicted and means the user can't continue, and there is nothing the user can do to solve the problem.

A logical error would be the case where a user tries to activate an account that is already activated.   Sometimes these generate a .NET exception, sometimes they don't.

A "true error" would be the database server crashed.  These pretty much always generate a .NET exception

In the case of a true error, I would redirect the user to a friendly looking error page telling the user something along the lines of "sorry, something went wrong".  Use the custom errors feature in web.config to do this.  Also, you should log these is some way, so you can see if there is something you can do to make sure this doesnt happen.

In the case of logical errors, you have to think ahead of time what about what are the possible reasons something might fail.  In this case, a user tries to activate an account that doesnt exist, a user tries to activate an account that doesnt belong to them, a user tries to activate an account that is already activated.   Depending on how your application is setup, any of those above cases might cause an .net exception to be  thrown.  You can handle this in two different ways.  Catch the exceptions, and then show the user a friendly error message (probably on the same page, saying that the account is already activated), or you can avoid the exception all together by checking to see if the account is already activated before you try and activate it. 

As a general rule of thumb, try to avoid code that can throw exceptions.  Exceptions are expensive from a perfomance standpoint, if there is a way to avoid throwing them do it.  For instance, if you are trying to convert a string to an integer use Int32.TryParse, instead of Int32.Parse.  There are some situation where this rule might not apply.  For instance if you try to insert a record in a database that already exists  you will get a Unique key violiation exception.  You could check to see if the record exists before you try to insert, or you could try the insert and catch the exception if it fails.  In this case, querying the database before the insert might be more of a performance killer than just catching the exception.

0
viscious
7/9/2008 9:40:08 PM

 cool. I am thinking of using log4net to log everything. Also, use custom errors to redirect to the relevant pages etc. I wanted to ask do i need to put a log
message in every method? even if it is not an error? Also, should i be logging to db as well as text file?

0
aspd
7/10/2008 12:22:52 PM

aspd:
I wanted to ask do i need to put a log
message in every method
  -- depends .. I would put it mostly in db access methods to log issues

aspd:
Also, should i be logging to db as well as text file
- I would pick one of the 2


Jeev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you get the answer to your question, please mark it as the answer.
0
Jeev
7/10/2008 12:35:06 PM
Reply:

Similar Artilces:

web.config error page. Page that had the error?
 I know I can set my web.config to redirect to an error page when there is an error. Is there any way to report what page had the error in the that error page? Will that always be the referring page name? Thanks for any help or information. i think you can try Server.GetLastError().InnerException I have to factor in that sometimes this will produce:   System.NullReferenceException: Object reference not set to an instance of an object. at ErrorPage.OnLoad(EventArgs e) in Any way to do that without try catch? Actually in the Error's page I never  get anything...

Users get redirected to login page over and over with no error...
We've got a web application that we launched about two months ago.  It uses Forms authentication with a sqlRoleProvider and a couple membership providers (ldap and a db).  Sessions are set to timieout after 60 minutes of inactivity.  99% of the time logging in after session times out works fine.  But we have a lot of users, and about 1% of the time (at least that's been reported) a user will timeout, get redirected to the login page, and when they attempt to login they just get redirected back to the login page with no error message.  I've actually...

Error, Error and more errors
Okay, all I wanted to do was test this app out and it has been a nightmare. 1.) Didn't install the sql database. I had to manually install it. 2.) I get errors when trying to add a picture to an album. "Procedure or function ngUpdatePicture has too many arguments specified" Any ideas? I've gotten more errors than this, but there is no use in bitchin. Are you using the v1.6.1 installer? Also, did you select to install the SQL Server db and give it a valid admin login? What were some of the error messages? Did you have an existing DB from a previous install? ...

error error error
These are the 2 new errors i am getting now:   1).  Server Error in '/' Application. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.Source Error: Line 53: ...

errors errors errors..
Name: harun Email: harunbjk1903hrnatgmaildotcom Product: Firefox Summary: errors errors errors.. Comments: first of all when i launch firefox (3) i cant enter websites via writing.. for example when I type "google" and then press ctrl and enter, it crashes.. and i take lots of error reports. firefox 2 was better.. see you again , harun Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9) Gecko/2008052906 Firefox/3.0 From URL: http://hendrix.mozilla.org/ ...

Error Handling
Help!  I don't get the redirected error page.  I've been staring at this simple case for a long time now.  Could someone help me?  What am I missing? Web.config says: <compilation debug="false" strict="false" explicit="true"> <customErrors mode="On" defaultRedirect="~/errors/ErrorPage.htm"/>   My exception-creating page comes up, but I get no redirect: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load      Dim StrError As String ...

issue logging error in DB & writing returning specific error message to error page
Gang:   Any ideal why I can’t return a specific error message to a label on defaultRedirect error.aspx page?   I can either write the error to the database; or if I comment that out, send a test message to the label & redirect to another page after error.aspx. The objective is to have both.   Here’s the scenario:   I test the error page by misspelling the stored procedure. This causes an error. The error bounces the user to clsError.vb. clsError logs the error & is supposed to redirect the specific error message back to the label on error.aspx. This is whe...

I cant get a blank form to show all I get is an error page
Hi  I tried all ways to get aspx page to work, it only works on my local machine, It wont work on a web site   Thanks in advance what version of IIS and .Net does the server have installed? It is a Windows server right? There are MANY possible problems... what is the error that's displaying? I had a similar problem where my pages were working locally but once uploaded to another server they didn't work. I just changed the root folder of the website to an Application in the IIS management console and it worked.www.LinkToIslam.net...

How to redirect to Error page when user try to view a page which is not authorize for him
 I have a membership provider, and it's working okey I just need to know how can I redirect a user to an error page if he try to access a page which is not allowed for his status.Example : Normal user tries to enter Url page for CreateUserAccounts which is for admins only.  what about Server.transfer? u can create a 2 class that inherits from Page: "PageForAdmin" and "PageForLogged". override oninit method and if user haven't credential to access perform a server.redirect whereever you wont. If your page inherits form PageForAdimin or PageForLog...

how to redirect to a error page when error 404 occurs?
Hi, I created a error page for 404.. and i want to navigate to this page when that error 404 occurs.. I wrote this code in web.config.. But its not working.. Can you help me?  <authentication mode="Windows"/> <customErrors defaultRedirect="LoginPage.aspx" mode="RemoteOnly"><error statusCode="408" redirect="~/LoginPage.aspx"/> <error statusCode="404" redirect="~/Errorpage404.aspx"/> </customErrors> HI Instead of writing directly inside web.config go to you appplication...

how to get error description from the custom error page
Hi,  i configure my web.config like that for error handling. "On" defaultRedirect="error/500.aspx"> "403" redirect="error/404.aspx"> "404" redirect="error/404.aspx"> "500" redirect="error/500.aspx">  For 500.aspx, i want to log the error message, description to the specified log file (txt). But, i don't know how to get the error message i did a lot of google. can anyone show me the way?   Hi, While using the Custom Redirect in the Web.Config, there will be less handle on logging the errors since the redirection happens as a first preference. ...

Error page .. information about page with error?
 I know I can set my web.config to redirect to an error page when there is an error. Is there any way to report what page had the error in the that error page? Will that always be the referring page name?Thanks for any help or information! jcnet: Is there any way to report what page had the error in the that error page? Will that always be the referring page name? Well you can do custom error handling like catch the error/exception that is raised in your code, and direct to users the error page where you can display the details of the exception/error that was raised. ...

Sharepoint help! Error msg : "A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe"
hihi, I have set up a testing virtual server on my local machine. I installed win server 2003, wss 2.0, sql server 2000, and visual studio .net 2003. i tried to create a project in C# but when i build it and import the web part (.dwp) into the page, there is this error msg "A Web Part or Web Form Control on this Web Part Page cannot be displayed or imported because it is not registered on this site as safe"  I seached most of the sites and they informed that the problem lies in the safe control in web.config i enter the safe control in web.config but i does not know where to put ...

Web User Controls -Error Element top_nav is not a known element. This can occur if there is a complilation error in the web site
I have created a web user control same as normal ,dragged and dropped onto the UI and built the project I get an error "Element top_nav is not a known element. This can occur if there is a complilation error in the web site" Can anyone tell me how to get around this - its doesn't stop the code working but I'd like to get rid of the error if possible. Thanks Mark...

Web resources about - if there is some error with db should user get redirected to a general error page? - asp.net.web-forms

Category:Wikipedia soft redirected project pages - Wikipedia, the free encyclopedia
Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. , a non-profit organization.

Agile Artisans: You'll be redirected in just a moment...
Agile Artisans: You'll be redirected in just a moment...

Logged-Out Users Cannot See Facebook Pages’ Content; Redirected To News Feed After Login
Web surfers who are not logged in to Facebook and try to access pages on the social network are landing on the news feed once they input their ...

Flickr: The Help Forum: [locked, redirected] flickr now censoring all moderate and restricted photos ...
Flickr is almost certainly the best online photo management and sharing application in the world. Show off your favorite photos and videos to ...

Prank of the Day: Someone Bought Anti-Gay Group’s Expired Domain Name, Redirected It to Gay Porn
Anti-gay protesters were picketing outside the Carolina Rebellion rock festival at the Charlotte Motor Speedway earlier this month, so one of ...

Smartphones redirected to Candy Crush, porn sites automatically - Technology - Tech News and Latest New ...
IT IS truly a 21st century problem, but one with potentially very serious implications. It may have even happened to you.

Smartphones redirected to Candy Crush, porn sites automatically
IT IS truly a 21st century problem, but one with potentially very serious implications. It may have even happened to you.

Large chunk of Chinese internet traffic redirected to small Wyoming building
In one of the more bizarre twists in recent Internet memory, much of the Internet traffic in China was redirected to a mysterious company in ...

Attack on Dailymotion redirected visitors to exploits
Attackers injected malicious code into Dailymotion.com, a popular video sharing website, and redirected visitors to Web-based exploits that installed ...

$200m redirected from wages to childcare training
THE Abbott government will redirect about $200 million that was meant to go to lifting childcare wages to helping long day care services with ...

Resources last updated: 12/26/2015 4:28:45 PM