I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
If the error isn't properly handled anywhere ,it generates an ugly error message that your visitor will see -- you don't want this to happen
So add a custom error page to your site that your visitor will see in case an unhandled error happens. That page will politely ask the visitor to come back later.
Report the error once again , so the Administrator knows that this serious error gets to the visitor and needs to be taken care of as soon as possible.
Steps to follow for add custom error page:
So add a custom error page to your site that your visitor will see in case an unhandled error happens. That page will politely ask the visitor to come back later.
Report the error once again , so the Administrator knows that this serious error gets to the visitor and needs to be taken care of as soon as possible.
Steps to follow for add custom error page:
- In Solution Explorer , Double-click web.config and add the following element as a child of the
<system.web>
<customErrors mode ="RemoteOnly" defaultRedirect ="errorpage.aspx" />
Note : If you want to handle errors using status code then specifies status code in <error> tag. Like
<customErrors mode ="On" defaultRedirect ="http://www.google.com">
<error statusCode ="404" redirect ="errorpage.aspx"/>
</customErrors>
Note : If you want to handle errors using status code then specifies status code in <error> tag. Like
<customErrors mode ="On" defaultRedirect ="http://www.google.com">
<error statusCode ="404" redirect ="errorpage.aspx"/>
</customErrors>
2. Add a new web form to your application's root , named errorpage.aspx . This form should not use a Master page , to make sure nothing gets in the way of displaying out simple error . The page also doesn't need a code-behind file
Note: After this change , remote clients will be forwarded to errorpage.aspx when unhandled exceptions are thrown ; however on the local machine you will still receive detailed error information . if you want to see the same error message as your visitors , set mode to On instead of RemoteOnly
3. Write some message into your errorpage.aspx like
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Your requested generated an error message
we apolgize for the inconvenience.
</div>
</form>
</body>
</html>
3. Write some message into your errorpage.aspx like
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Your requested generated an error message
we apolgize for the inconvenience.
</div>
</form>
</body>
</html>
4. Test your application by generating error
Comments
Post a Comment