Showing posts with label mvc. Show all posts
Showing posts with label mvc. Show all posts

Friday 22 October 2021

Read INI file ASP.Net MVC C#

 Install ini reference 

> nuget install ini-parser
                or
PM> Install-Package ini-parser

Tuesday 20 April 2021

Custom Error message | Hide Yellow Screen Of Death (YSOD) page in ASP .Net

ASP.Net MVC has a default error view in the Shared folder. which shows when any unexpected error arises. By default a fixed static error message display, No details of error shows. So if you want to show error details then this post will help you.




Yellow Screen Of Death (YSOD)

When an unhandled exception arises in an ASP.NET application one of three types of error pages is displayed: By default, ASP.NET displays an error page that is affectionately referred to as the Yellow Screen of Death (YSOD). YSOD showed some Sensitive information that can be used by attackers . Show its good practice to show custom error info in front of your users.

Setting in Webconfg file

<system.web>

    <compilation debug="true" targetFramework="4.7.2" />

    <httpRuntime targetFramework="4.7.2" />

       <trust level="Full" />

      

       <customErrors mode="RemoteOnly"

                      defaultRedirect="~/Shared/Error.cshtml" />

  </system.web>


Show error in custom error file



 @model System.Web.Mvc.HandleErrorInfo 

<div class="container">       

        <h1>Error.</h1>

        <h2>An error occurred while processing your request.</h2>

        <h3 style="color:red"><p style="color:red"> @Model.Exception.Message</p></h3>

        <br /><br />

    </div>

Next Topic