0

I have an error like

Ex :– Sending malicious characters in the GET request Like ' : In asp .NET MVC

I am getting this error

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /Sonar'

I need a solution like

create a custom error page for all exception conditions. So for any HTTP error codes that are not 200 OK, the custom page should be returned to the user rather than showing exception conditions.

I was adding code in web.config file and create one error controller and add one view. how to redirect to all modules into one custom error page when I have enter malicious character.

customErrors mode="On" defaultRedirect="~/ErrorController/ErrorView"

<error redirect="~/ErrorController/ErrorView/400" statusCode="404" 
<error redirect="~/ErrorController/ErrorView/500" statusCode="500"     

customErrors

 public class ErrorController : Controller  
 {  
     public ActionResult ErrorView(int id)  
     {  
          Viewbag.StatusCode=id;  
  
         return View();  
     }  
 } 
JMP
  • 4,417
  • 17
  • 30
  • 41

0 Answers0