I am getting given below error in MVC 4

Error.
An error occurred while processing your request.

Can anybody suggest me how to resolve this issue.

I have added below method in routeconfig

protected void Application_Start()
    {
        RegisterRoutes(RouteTable.Routes);
    }


    protected void Application_Error()
    {
        HttpContext ctx = HttpContext.Current;
        KeyValuePair<string, object> error = new KeyValuePair<string, object>("ErrorMessage", ctx.Server.GetLastError().ToString());
        ctx.Response.Clear();
        RequestContext rc = ((MvcHandler)ctx.CurrentHandler).RequestContext;
        string controllerName = rc.RouteData.GetRequiredString("controller");
        IControllerFactory factory = ControllerBuilder.Current.GetControllerFactory();
        IController controller = factory.CreateController(rc, controllerName);
        ControllerContext cc = new ControllerContext(rc, (ControllerBase)controller);


        ViewResult viewResult = new ViewResult { ViewName = "Error" };
        viewResult.ViewData.Add(error);
        viewResult.ExecuteResult(cc);
        ctx.Response.End();
    }

Then it changed error as below:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

Internal Service error was due to below tag in config

<sessionState mode="InProc" timeout="60"/>

I removed it from web.config then appear again same error

Error.
An error occurred while processing your request.

thanks,

Related posts

Recent Viewed