Click here to Skip to main content
15,668,691 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
on mvc paging sorting locally works fine but on server getting error like below

Attempt by method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure)' to access type 'System.Linq.OrderedEnumerable`2<Solution.Areas.Admin.Models.ServiceModel,System.Int32>' failed.

Controller code

public ActionResult Index(string Search_name, int? page, string sortOrder)
ViewBag.orderbySortParm = sortOrder == "orderby" ? "orderby_desc" : "orderby";
switch (sortOrder)
                case "orderby":
                    var sorted = model.serviceList.OrderBy(a => a.DisplayOrder);
                    model.pageServiceList = sorted.ToPagedList(currentPageIndex, pageSize);
                case "orderby_desc":
                    var sortedesc = model.serviceList.OrderByDescending(a => a.DisplayOrder);
                    model.pageServiceList = sortedesc.ToPagedList(currentPageIndex, pageSize);

View Page

                    <a href="@Url.Action("Index", "Service", new { sortOrder = ViewBag.orderbySortParm })">Display Order</a>
Updated 26-Jul-18 6:27am

1 solution

I am also facing same issue do you get any solution for it :-)

I am not able to figure out the issue.
Share this answer
Richard Deeming 26-Jul-18 13:10pm    
If you want to ask a question, then ASK A QUESTION[^].

DO NOT post your question as a "solution" to someone else's question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900