Exon02
Exon02

Reputation: 77

ASP.NET MVC 5 app on IIS throws 500 - Internal server error

I'm getting a 550-internal server error on all pages from a specific controller. All of the other views from other controllers gives the specific view.

The controller a simple controller with CRUD functionality.

[Authorize(Roles = "Administrator, Supervisor, Ploeg")]
public class DienstbulletinController : Controller
{
    private readonly DienstbulletinAppContext _db = new DienstbulletinAppContext();

    // GET: Dienstbulletin
    public ActionResult Index()
    {
        var dienstbulletin = _db.Dienstbulletins.Where(a => a.Deleted == false).Include(d => d.Obp)
            .Include(d => d.Ogp).Include(d => d.Opsteller).Include(d => d.Ploeg).Include(d => d.Rechercheur)
            .Include(d => d.Voertuig);
        var data = dienstbulletin.ToList();
        return View(data.OrderByDescending(a => a.Datum.Date).ThenByDescending(a => a.ID).ToList());
    }

    // GET: Dienstbulletin/Details/5
    public ActionResult Details(int? id)
    {
        if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        var dienstbulletin = _db.Dienstbulletins.Find(id);
        if (dienstbulletin == null) return HttpNotFound();
        return View(dienstbulletin);
    }

    // GET: Dienstbulletin/Create
    public ActionResult Create()
    {            
       Dienstbulletin dienstbulletin = new Dienstbulletin ()

        return View(dienstbulletin);
    }
}

in the routes are following declared

 var settings = new FriendlyUrlSettings {AutoRedirectMode = RedirectMode.Permanent};
        routes.EnableFriendlyUrls(settings);

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");


        routes.MapRoute(
            "login", // Route name
            "Gebruiker/Login", // URL with parameters
            new { controller = "Gebruiker", action = "Login", id = UrlParameter.Optional }
         );

        routes.MapRoute(
                           name: "Default",
                           url: "{controller}/{action}/{id}",
                           defaults: new { action = "Index", id = UrlParameter.Optional }

Any idea on what could be wrong with this controller?

In the eventlog on the server is no message or hint found.

Upvotes: 0

Views: 2805

Answers (2)

chyonek
chyonek

Reputation: 1

If you get a 500.19 error, I recommend to check your app folder acls and web.config. I think the folder need Read & execute access rights for local IIS_IUSRS gloup to read web.config with IIS. Because 500.19 error is a config problem.

Upvotes: 0

bdongus
bdongus

Reputation: 678

500 errors are unhandled exceptions or configuration errors. I guess one of your DB queries or creating your DienstbulletinAppContext throws an exception. And there are several places you can look for it.

During development you can open the browsers debugging tools and take a look at the failed request's response. Usually the respones is a HTML page showing the execption message.

On the server you can look at the IIS logs.

enter image description here You should find your logs in folders that are named by your W3SVC site ID numbers. There you can see a subcode describing what happened. But you won't see exception details.

Exceptions leading to a 500 error are mostly warnings in the Windows Application EventLog. The first time I had a 500, I just looked for errors in the log, not for warnings. Did you check for warnings?

Upvotes: 1

Related Questions