Error! The requested URL returned 500 - Internal Server Error

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 Jahre weitere
My testimonials section I have created I keep getting

Error! The requested URL returned 500 - Internal Server Error

It based on the news section with some modifications any one any ideas why I am getting this error, it only happening in the admin section I can post comments to the testimonials with out a problem.

But when I try to access the comments I keep getting this error!!!!!!
11 Jahre weitere
500 errors are mostly caused by bugs in your code. Can you post the code?
11 Jahre weitere
Here is the code:

[HttpPost, GridAction(EnableCustomBinding = true)]
        public ActionResult Comments(int? filterByNewsItemId, GridCommand command)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
                return AccessDeniedView();

            IList<TestimonialsComment> comments;
            if (filterByNewsItemId.HasValue)
            {
                //filter comments by news item
                var newsItem = _TestimonialsService.GetTestimonialsById(filterByNewsItemId.Value);
                comments = newsItem.TestimonialsComments.OrderBy(bc => bc.CreatedOnUtc).ToList();
            }
            else
            {
                //load all news comments
                comments = _customerContentService.GetAllCustomerContent<TestimonialsComment>(0, null);
            }

            var gridModel = new GridModel<TestimonialsCommentsModel>
            {
                Data = comments.PagedForCommand(command).Select(newsComment =>
                {
                    var commentModel = new TestimonialsCommentsModel();
                    commentModel.Id = newsComment.Id;
                    commentModel.TestimonialsItemId = newsComment.TestimonialsItemId;
                    commentModel.TestimonialsItemTitle = newsComment.TestimonialsItem.Title;
                    commentModel.CustomerId = newsComment.CustomerId;
                    commentModel.IpAddress = newsComment.IpAddress;
                    commentModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(newsComment.CreatedOnUtc, DateTimeKind.Utc);
                    commentModel.CommentTitle = newsComment.CommentTitle;
                    commentModel.CommentText = Core.Html.HtmlHelper.FormatText(newsComment.CommentText, false, true, false, false, false, false);
                    return commentModel;
                }),
                Total = comments.Count,
            };
            return new JsonResult
            {
                Data = gridModel
            };
        }
11 Jahre weitere
Here the other bit of code
public ActionResult Comments(int? filterByNewsItemId)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
                return AccessDeniedView();

            ViewBag.FilterByNewsItemId = filterByNewsItemId;
            var model = new GridModel<TestimonialsCommentsModel>();
            return View(model);
        }
11 Jahre weitere
Very odd I removed the following line and it now works

//commentModel.TestimonialsItemTitle = newsComment.TestimonialsItem.Title;

Odd!
11 Jahre weitere
Maybe TestimonialsItem is null?
11 Jahre weitere
Not sure but it working now and that all that matters, saying that not sure if we are going to use the comments section. It there and working if we are but other wise it not a big worry now.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.