How Can a Stack Trace Point to the Wrong Line (the “return” Statement) – 40 Lines Off

I have twice now seen a NullReferenceException logged from a Production ASP.NET MVC 4 web application – and logged on the wrong line. Not wrong by a line or two (like you would get with a PDB mismatch), but wrong by the length of the entire controller action. Example:

Mvc Asp Sorting items

I’ve used PagedList.MVC for pagination in my application. This is working fine. Pagination is working fine and also the OrderBy dropdownlist is working fine. When i select value from dropdownlist it gives the desired sorted result. I mean if i select A-Z then it sorts the items fine in ascending order but when i click 2nd page or next page it doesn’t sort any item and the url is become like this