locked
Problem to error 500 RRS feed

  • Question

  • User364663285 posted

    Hi,

    How to resolve?

    Server Error
    
    500 - Internal server error.
    There is a problem with the resource you are looking for, and it cannot be displayed.

    while here is part of my current Web.config

        <system.web>
          <customErrors mode="Off" />
          <compilation debug="true" targetFramework="4.5" />
          <httpRuntime targetFramework="4.5" />

    Tuesday, August 14, 2018 3:07 AM

All replies

  • User-369506445 posted

    hi

    First, you need to enable and see detailed errors of your web messages, because this is a general message without giving information on what's really happening for security reasons.

    With the detailed error, you can locate the real issue here.

    Also, if you can run the browser on the server, you get details on the error, because the server recognizes that you are local and shows it to you. Or if you can read the log of the server using the Event Viewer, you also see the details of your error.

    On IIS 6

    <configuration>
        <system.web>
            <customErrors mode="Off"/>
            <compilation debug="true"/>
        </system.web>
    </configuration>

    On IIS 7

    <configuration>
        <system.webServer>
            <httpErrors errorMode="Detailed" />
            <asp scriptErrorSentToBrowser="true"/>
        </system.webServer>
        <system.web>
            <customErrors mode="Off"/>
            <compilation debug="true"/>
        </system.web>
    </configuration>

    Note: You can avoid the Debug=true. You only need to close the custom errors for a while and get the detailed error page.

    Reference: Enabling Windows custom error messaging in Go Daddy's help articles.

    Also, this can help: How to enable the detailed error messages (from IIS).

    Tuesday, August 14, 2018 5:05 AM
  • User364663285 posted

    Can you please point out what problem I have, with the project?

    Tuesday, August 14, 2018 9:28 AM
  • User-369506445 posted

    this is a general message without giving information on what's really happening for security reasons. you have to enable to see details errors 

    in the last post, I described how do you do it

    Tuesday, August 14, 2018 9:38 AM
  • User-1320437544 posted

    Remote login to the server (RDP) and use its browser to open the application's URL then you can view  what the reason is (from localhost which is basicaly the deployment server). I think it would be a good starting point.

    Let us know if it helped.

    Tuesday, August 14, 2018 3:58 PM
  • User1724605321 posted

    Hi wmec,

    The 500 Internal Server Error is a very general HTTP status code. It means something has gone wrong on the website and webserver is unable to specify what exactly, thus failing in fulfilling the request made by the client. This is not related to client and the fault is in the webpage/website requested that resides on server.

    Generally, it is logged into Windows Event Logs on the server. Thus, first thing while troubleshooting the error is to see Windows Event Logs on the server to find what went wrong.

    Other useful thing to troubleshoot it would be to disable friendly HTTP error messages to see if the raw content can provide a direction to look more. Steps:

    • Go to menu Tools/Internet Options in your IE.
    • Click on the Advanced tab & then uncheck “Show friendly HTTP error messages” option and then click OK.
    • Now, when on accessing the same web page, much more developer meaningful error message will be shown.

    Reference : https://www.codeproject.com/articles/545054/http-500-internal-server-error 

    Best Regards,

    Nan Yu

    Wednesday, August 15, 2018 2:09 AM
  • User364663285 posted

    Thanks to all.
    Nan,
    Sorry, where is “Show friendly HTTP error messages” option below?

    https://1drv.ms/u/s!Ai8CrEskdewXmm87smbewZea5IGB

    Wednesday, August 15, 2018 6:58 AM
  • User409696431 posted

     "Show friendly HTTP error message" is under the Browsing section in Advanced. 

    Wednesday, August 15, 2018 2:06 PM
  • User364663285 posted

    Sorry, did you see my screenshot in above? Could you please point out the option mentioned by you in the screenshot?

    Thursday, August 16, 2018 3:47 AM
  • User-1320437544 posted

    Error 500 is internal server error you will NOT be able to see it on client side. Thats logical for security reasons imagine is each server shows to everyone in Internet debugging or log info.

    Did you tried what I mensioned earlier in my previous replay?

    Best regards

    Thursday, August 16, 2018 4:07 AM
  • User364663285 posted

    Yes, within the server, I also cannot go to the web page (via IE) but I've deployed the project successfully.

    Thursday, August 16, 2018 4:13 AM
  • User-1320437544 posted

    Let me recap just to make sure I undertood the steps you did so far.

    1. You've deployed the web application on the server and had set IIS.
    2. You are getting HTTP response code 500 which is Internal Server Error.
    3. You've logged on on the server via RDP or another remote access tool.
    4. You've set debuge="true" in your web.config.
    5. You've tried to open the web application in Internet Explorer ON THE SERVER.

    My question here is what you mean by saying I cannot go to the web page via IE!? It must be there if deployed correctly within IIS. Whether or not correctly functional app you must receive at least HTTP status code if all 5 steps are done.

    Please shed some light.

    Thanks

    Thursday, August 16, 2018 4:23 AM
  • User364663285 posted

    I mean the web page (within the server) is also not being displayed.

    Thursday, August 16, 2018 6:46 AM
  • User-1320437544 posted

    Do you have other pages hosted on this server? Does they work properly?

    What I am thinking is maybe you are having problems with IIS not with the application.

    Thursday, August 16, 2018 2:43 PM
  • User364663285 posted

    IIS was set up properly and I also deployed project without issue.

    Friday, August 17, 2018 1:44 AM
  • User364663285 posted

    KathyW

     "Show friendly HTTP error message" is under the Browsing section in Advanced. 

    Kathy,
    Such option is always on but I still get the below error, in IE.
    https://1drv.ms/u/s!Ai8CrEskdewXmnKX7D2ZPQlWXqH1

    Friday, August 17, 2018 6:56 AM
  • User409696431 posted

    Your statement is a bit confusing.  You say "Such option is always on", but you want it turned off - unclick it.

    The linked image in your message is has nothing to do with the friendly url errors option.

    Friday, August 17, 2018 7:17 AM
  • User364663285 posted

    I un-click this option in IE (and then re-opened IE) but I still have got this error below

    Server Error

    500 - Internal server error.

    There is a problem with the resource you are looking for, and it cannot be displayed.

     

     

    Friday, August 17, 2018 10:25 AM
  • User1120430333 posted

    wmec

    I un-click this option in IE (and then re-opened IE) but I still have got this error below

    Server Error

    500 - Internal server error.

    There is a problem with the resource you are looking for, and it cannot be displayed.

     

    Look, the program running on the Web server through an unhandled .NET exception. There is no try/catch in the code where the exception occurred to handle the exception. Since the exception was unhandled, the Web server swallowed the exception and then through the HTTP 500 error response code.

    You are never going to address the issue until you discover what the .NET exception is about. Most would have some kind of global exception handling  logic that catches unhandled exceptions that shows the exception message, the inner.exception.message if there one and the stack trace.

    I get HTTP 500 responses all the time when developing ASP.NET Web code, but I have global exception handling in the solution to catch and log the exception to a log file so that I can see what the exception is about as I use notepad to look at the content of the log file.  The below is the unhandled exception that was caught by the exception logging logic when all I got back visibly was an HTTP 500 error . With the log, I was able to track down what was wrong.

    ======================================================================================================

    ERROR 2018-08-12 08:27:28,675 21299ms BaseController LogError - System.ArgumentException: The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Index(Int32)' in 'ProgMgmntVB.Controllers.TaskController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
    Parameter name: parameters
    at System.Web.Mvc.ActionDescriptor.ExtractParameterFromDictionary(ParameterInfo parameterInfo, IDictionary`2 parameters, MethodInfo methodInfo)
    at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c.<BeginInvokeSynchronousActionMethod>b__9_0(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__11_0()
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass11_1.<InvokeActionMethodFilterAsynchronouslyRecursive>b__2()
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass7_0.<BeginInvokeActionMethodWithFilters>b__1(IAsyncResult asyncResult)
    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_6.<BeginInvokeAction>b__3()
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult)
    ERROR 2018-08-12 10:36:36,334 39834ms BaseController LogError - System.Web.HttpCompileException (0x80004005): C:\Projects\ProgMgmntVB\ProgMgmntVB\Views\Home\Index.vbhtml(25): error BC30201: Expression expected.
    at System.Web.Compilation.AssemblyBuilder.Compile()
    at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
    at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
    at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
    at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
    at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
    at System.Web.Compilation.BuildManager.GetCompiledType(VirtualPath virtualPath)
    at System.Web.Compilation.BuildManager.GetCompiledType(String virtualPath)
    at System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.GetCompiledType(String virtualPath)
    at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
    at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_6.<BeginInvokeAction>b__3()

    Friday, August 17, 2018 11:10 AM
  • User364663285 posted

    Where can I get root reason to this error?

    Friday, August 17, 2018 1:18 PM
  • User1120430333 posted

    You are going to need to put some logic in your program that is a global exception handler that is going to catch the unhandled exception that was thrown and log the error to a log file. I don't knw what kind of Web program you are writing to catch the error and log it. It could be kind of what I am doing in an MVC program where the controller inherits the logic of a BaseContoller so that if any exception is thrown in the controller, the Basecontroller will catch it and log it. 

    Imports System.Web.Mvc
    Imports log4net
    
    Namespace Controllers
        Public MustInherit Class BaseController
            Inherits Controller
    
            private ReadOnly _logger As ILog
    
            public sub New()
                _logger = LogManager.GetLogger(GetType(BaseController))
            End sub
    
            Protected Overrides Sub OnException(filterContext As ExceptionContext)
                MyBase.OnException(filterContext)
    
                dim appexception as AppException = New AppException(CStr(filterContext.Exception.ToString()), _logger) 
    
                Server.ClearError()
    
                RedirectToControllers("Home", "TheError")
    
            End Sub
    
            private sub RedirectToControllers(control As string, action As string)
    
                dim routeData = new RouteData()
    
                routeData.Values("controller") = control
                routeData.Values("action") = action
    
                Dim controller As IController = new HomeController(nothing) 
                controller.Execute(New RequestContext(new HttpContextWrapper(system.Web.HttpContext.Current), routeData))
    
            End sub
            
        End Class
    End Namespace
    
    ==========================================================
    
    Imports log4net
    
    Public Class AppException
        Inherits Exception
    
        private ReadOnly _logger As ILog
    
        Public Sub New(ByVal logger As ILog)
    
            _logger = logger
            LogError("An unexpected error occurred.", _logger)
    
        End Sub
    
        public sub New (byval message as String, logger As ILog) 
    
            _logger = logger
    
            LogError(message, _logger)
    
        End sub
    
        Public Sub New( ByVal message As String, ByVal innerException As Exception, ByVal logger As ILog)
    
            _logger = logger
            LogError(message, _logger)
    
            If Not (innerException Is Nothing) Then
                LogError(innerException.Message.ToString, _logger)
            End If
    
        End Sub
          
        Public Shared Sub LogError(ByVal message As String, ByVal logger As ILog)
            logger.Error(message)
        End Sub
    
      End Class
    ===========================================================
    Imports System.Web.Mvc
    Imports ProgMgmntVB.Models
    
    Namespace Controllers
        Public Class ProjectController
            Inherits BaseController
    
            private readonly _projectModel As IProjectModel 
            private readonly _modelHelper As IModelHelper 
    
            public sub New (projectModel As IProjectModel, modelHelper As IModelHelper)
                _projectModel = projectModel
                _modelHelper = modelHelper
            End sub
    
            ' GET: Project
            <Authorize>
            public Function Index() As ActionResult
                Return View(_projectModel.GetProjectsByUserId(User.Identity.Name))
            End Function
    
            <Authorize>
            public Function  Details(Optional id As Int32 = 0) As ActionResult
                return  IIf(id = 0, nothing, View(_projectModel.Edit(id)))
            End Function
           
            <Authorize>
            public Function  Edit(Optional id As Int32 = 0) As ActionResult 
                return  IIf(id = 0, nothing, View(_projectModel.Edit(id)))
            End Function
    
            <Authorize>
            public Function  Create() as ActionResult
                return View(_projectModel.Create())
            End Function
            
            <Authorize>
            <HttpPost>
            public  Function Create(project as ProjectViewModels.Project, submit As string ) As ActionResult
    
                if submit = "Cancel" Then
                    return RedirectToAction("Index")
                End If
    
                Call ValidateddlProjectTypes()
    
                project.ProjectType = Request.Form("ddlProjectTypes")
    
                If ModelState.IsValid And _modelHelper.IsEndDateLessThanStartDate(project, "Project") Then
                    ModelState.AddModelError(String.Empty, "End Date cannot be less than Start Date.")
                End If
    
                if Not ModelState.IsValid Then
                    return View(_projectModel.PopulateSelectedList(project))
                End If
    
                _projectModel.Create(project, User.Identity.Name)
                return RedirectToAction("Index")
    
            End Function
         
            <Authorize>
            <HttpPost>
            public Function  Edit(project as ProjectViewModels.Project, submit As string ) As ActionResult
    
                if submit = "Cancel" Then
                    return RedirectToAction("Index")
                End If
    
                If ModelState.IsValid And _modelHelper.IsEndDateLessThanStartDate(project, "Project") Then
                    ModelState.AddModelError(String.Empty, "End Date cannot be less than Start Date.")
                End If
    
                if Not ModelState.IsValid Then
                    return View(_projectModel.PopulateSelectedList(project))
                End If
    
                dim theproject = project
    
                theproject.ProjectType = Request.Form("ProjectType")
    
                _projectModel.Edit(theproject, User.Identity.Name)
    
                return RedirectToAction("Index")
    
            End Function
    
            public  Function Delete(Optional id As Int32 = 0) as ActionResult
    
                if id > 0 Then
                   _projectModel.Delete(id)
                end If
    
                return RedirectToAction("Index")
    
            End Function
            
            public Function  Cancel() As ActionResult
                return RedirectToAction("Index", "Home")
            End Function
            
            public function UploadFile(id As Int32) As ActionResult
                return RedirectToAction("UploadFile", "Upload", new With { .id = id, .type = "PM" })
            End function
           
            private sub ValidateddlProjectTypes()
    
                if Request.Form("ddlProjectTypes") = String.Empty Then
                    exit sub
                End If
    
                for each  key1 in ModelState.Keys.ToList().Where(Function(key) ModelState.ContainsKey(key))
    
                    if key1 <> "ProjectType" Then
                        continue for
                    End If
    
                    ModelState(key1).Errors.Clear()
                next
    
            End sub
        End Class
    End Namespace

    Friday, August 17, 2018 6:57 PM
  • User364663285 posted

    I did not have the current issue on the same server, with the same ASP project. But this issue arose after I've re-installed the server.

    Saturday, August 18, 2018 3:19 AM
  • User409696431 posted

    "I did not have the current issue on the same server, with the same ASP project. But this issue arose after I've re-installed the server."

    Then something was not set up properly when you reinstalled the server.

    We can't tell you what that is.

    You could try capturing errors as DA924 suggests, or post on an IIS forum to see if they can point you to likely culprits.

    Saturday, August 18, 2018 3:38 AM
  • User1120430333 posted

    I did not have the current issue on the same server, with the same ASP project. But this issue arose after I've re-installed the server.

    Now you do have an issue, and you don't know what the error is about. Best practice is that you always implement global exception handling in a Web solution and log the error. 

    You log the ex.message, the ex.inner.exception.messsage.  if there it could null and you need to check,  and log the stack trace.  

    https://stackify.com/csharp-catch-all-exceptions/?utm_referrer=https%3A%2F%2Fwww.google.com%2F

    You can use Log4NET to log the error

    And you don't leave home without the GEH implemented into the solution.

    Saturday, August 18, 2018 4:55 AM
  • User364663285 posted

    Hi all,

    Is there any problem below?

    https://1drv.ms/u/s!Ai8CrEskdewXmnQ8H0o3gZiP3ItN

    Saturday, August 18, 2018 11:42 AM
  • User1120430333 posted

    Hi all,

    Is there any problem below?

    https://1drv.ms/u/s!Ai8CrEskdewXmnQ8H0o3gZiP3ItN

    All you are doing is blindly stabbing in the dark. The only possible sliver bullet and the pulling of the rabbit out of the hat is global exception handling.  How many days have you been looking for a solution that no one can help you with but you in this situation?

    Saturday, August 18, 2018 1:24 PM
  • User753101303 posted

    Hi,

    http 500 means you have a server side error. By default you should find error details in the Windows event log. You could also check the IIS log to see which 500.x error you have (using the "substatus" code). 500.19 would point to a config problem for example.

    It will allow to start from the actual problem rather than trying to guess.

    Monday, August 20, 2018 1:09 PM