Friday, 20 January 2017

Error Page in MVC

1/20/2017 - By Pranav Singh 0




This article will show you how you can manage a common error page in asp.net MVC. In this i will show you how you can show the technical error when some error occur in your mvc website user will be redirected to the error page directly to the error page where he will be able to get all the error detail, What the the error why the error have been occur in the application. in which line error have been occur.

Some of my previous articles are as follows: Passing Controller Action Error to View In MVC, The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at, Error In Visual Studio 2013: WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery', Error Handling in Windows Application Using C#.Net, Multiple controls with the same ID '_header' were found. FindControl requires that controls have unique IDs. in Asp.net.

So for this just create a asp.net mvc application and go to View folder and then open the shared folder.



Now lets check the error.cshtml file code.

@model System.Web.Mvc.HandleErrorInfo
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Error</title>
</head>
<body>
    <hgroup>
        @{
            ViewBag.Title = "Uh-oh, an error occurred/";
        }

        <h2>One of us broke the site!</h2>

        @if (Model != null)
        {
            <h3>@Model.Exception.GetType().Name</h3>
            <pre>
        @Model.Exception.ToString()
    </pre>
            <p>
                thrown in @Model.ControllerName @Model.ActionName
            </p>
        } 

    </hgroup>
</body>
</html>


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top