Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
web.config file code

<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404" />
      <error statusCode="404" responseMode="ExecuteURL" path="/Error/PageNotFound" />    
      <remove statusCode="500" />
      <error statusCode="500" responseMode="ExecuteURL" path="/Error" /> 
      
    </httpErrors>
</system.webServer>


Controller

    public class ErrorController : Controller
    {
        //
        // GET: /Error/
        public ActionResult Index()
        {
            Response.StatusCode = 500;
            return View("Error");
        }

        public ActionResult PageNotFound()
        {
            Response.StatusCode = 404;
            return View();
        }
	}


What I have tried:

Everything is going to fine here.
But when i pass invalid parameter(localhost/home/index/55555) then it does't redirected to my custom page.(55555 is 

not a valid parameter here).
Please can anyone help regarding this
Posted
Updated 29-Jan-17 19:27pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900