CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_web_developer_2005_express Tags:
Item Type: NewsGroup Date Entered: 7/9/2007 5:55:13 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 4 Views: 113 Favorited: 0 Favorite
5 Items, 1 Pages 1 |< << Go >> >|
Suryansu
Asp.Net User
showing Custom error message to the user7/9/2007 5:55:13 AM

0

Hi,

I am developing a project in which i have to use exception handling.......I want that wheneever as exception occurs that time i will show a custom error message to the user......some people are suggesting to use web.config file ..Below is the code i have to write in web config file..

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

<error statusCode="403" redirect="NoAccess.htm" />

<error statusCode="404" redirect="FileNotFound.htm" />

</customErrors>

But problem is that for each error i have to create a separate error file........AND i don't know at runtime which type of error will be generated...

If is there any better way to sohw the custom errror message to user.......Kindly help me.......Plz write ur opinion briefly

kipo
Asp.Net User
Re: showing Custom error message to the user7/9/2007 8:27:09 AM

0

If you remove

<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
from web.config user will be redirected to GenericErrorPage.htm every time error happens.

Suryansu
Asp.Net User
Re: showing Custom error message to the user7/9/2007 9:20:51 AM

0

But I want to which way i should go for exception handling.......for each excepiton there is error no.......so shall i use that error number to show the custom errror message......

kipo
Asp.Net User
Re: showing Custom error message to the user7/9/2007 9:52:10 AM

0

1. Remove this part from web.config:

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
2. Create Global.asax file in root folder and put this inside it:
<%@ Application Language="C#" %>

<script RunAt="server">

 void Application_Start(object sender, EventArgs e)
 {

 }

 void Application_End(object sender, EventArgs e)
 {

 }

 void Application_Error(object sender, EventArgs e)
 {
  Session["error"] = Server.GetLastError().Message.ToString();
  Server.ClearError();
  Server.Transfer("~/error.aspx");
 }

 void Session_Start(object sender, EventArgs e)
 {

 }

 void Session_End(object sender, EventArgs e)
 {

 }
      
</script>

3. Create error.aspx file like this

Page:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="error.aspx.cs" Inherits="error" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Error</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
  <asp:Label ID="Label1" runat="server"></asp:Label></div>
    </form>
</body>
</html>

Code-behind:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class error : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
  Label1.Text = Session["error"].ToString();
    }
}

Suryansu
Asp.Net User
Re: showing Custom error message to the user7/9/2007 10:06:04 AM

0

good suggestion......But how  can i give custom message so that user is able to understand what the problem is................

5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Web database applications with PHP and MySQL Authors: Hugh E. Williams, David John Lane, Pages: 563, Published: 2002
Struts 2 in Action Authors: Donald Brown, Chad Michael Davis, Scott Stanlick, Pages: 404, Published: 2008
Programming Visual Basic .NET Authors: Jesse Liberty, Dave Grundgeiger, Pages: 541, Published: 2003

Web:
Showing error message in event receiver Nov 29, 2008 ... Suppose you want to show a custom error message in your event receiver ... EAI, ETL ยท Field User Property: Required: Custom Error Message ...
Custom Validtor error message not showing up with other satndard ... However, the error message will not appear in validation summary along ... The cutom validator will not let the user know that he needs at ...
4WebHelp - Creating Custom Error Messages in Apache Feb 9, 2004 ... This page should, ideally, tell the user that something is wrong .... HTML file. ..a dynamic page will cause IE to show its own 404 no ... If I create a custom error message (like 404) , how do you display the file path? ...
Custom WordPress Database Error - Derek Punsalan - 5ThirtyOne If you're a longtime WordPress user, you're probably aware of the ... shows a custom error page and emails error instead of showing the ... Now that you have a clean canvas to work with, show me what your database error message will be. ...
SharePoint User Group UK - ItemAdding and properties.ErrorMessage ... ErrorMessage problem with custom NewForm.aspx page ... Cancel = true; I want to show message for user using properties.ErrorMessage = "My message". But I have error showing that there is problem with inserting . ...

showing Custom error message to the user - ng.asp-net-forum ... I want that wheneever as exception occurs that time i will show a custom error message to the user......some people are suggesting to use ...
HOWTO: Manual install of DotNetNuke on GoDaddy.com - ng.asp-net ... ... and you should see a new record showing your new database. ... I modified the DB settings and custom error messages in the web.config file as directed ... Details: To enable the details of this specific error message to be ..... is there a way to automate a hyperlink? direct the user's browser? ...
Difference between Request.ServerVariables["HTTP_X_FORWARDED_FOR ... I think both are used for showing the system's IP address. then ... will tell you the IP if the user is behind a proxy server. ... custom skin: attempt to access secure tab ... error with 'site settings' in dnn 2.1.2 ...

Videos:
Guitar Hero 2 Custom Song - Sonic 3D Rock Edit: MP3: http://savefile.com/files/485140 (if you know of a better place to host my music let me know) Ugh... This one wasn't so easy. I ...
#1 Website Traffic Tip - Custom Error Pages - Direct ... http://www.websitetrafficbuilders.com has a large selection of search engine optimization software, most with 30 day, 100% money back guarantees ...
How to create your own fake error message! Create your own fake error message using notepad. Code: msg = msgbox ("text" ,16, "title") Change "16" with the type of error message you ...
You Tubers Love Excel#6: VLOOKUP and Custom Data Validation See when the IF function is not efficient to use. Instead we will use the VLOOKUP function and a logical True/False Data Validation formula to ...
The Fladen Eye and Lasik Center: Custom Lasik Enhancement Dr. Todd Fladen narrates and performs Custom Lasik Enhancement Procedure at The Fladen Eye and Lasik Center using the VISX Star4 Excimer Laser ...












updating an access database

wanting to create (or find) a toolbox (ui) control for datetime label custom formatting

how can i set up my project's directory organization??

problem with installing pubs database in the guided tour

is it a bug in the personal web site starter kit?

search datagrid

how to find out the index of a column

searching in the grid view

import data to sql server express

remote debugger

key not valid for use in specified state

how to select & insert data in the same table

vwd express beta 2 - database explorer

any problem running a website on vs created in vwd

tell us your express story and win $100!

using my program on a local machine

bug in vwd 2005 express?

what two-way data bind means????

sql database connection in visual web developer

can't reference controls dropped in the designer directly in my [file].aspx.cs

changing control declaration ??

background image in vwd exp. web page

visual web developer 2005 & asp.net 2.0

css formatting is lost when master page not open

vwd: errors with range validator

asp 2 quick questions

cannot run v1.1 with it's web server with 2.0 installed

newbie - any apperance or performance issues to consider when choosing tables, layering or absolute positioning in webpage layout?

themes

vwd express compatibilty

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT