I'm using ASP.NET MVC 3 w/Razor. On one of my pages I am using a WebGrid to display data. If the WebGrid is instantiated as shown below, everything works fine.
var grid = new WebGrid( Model, defaultSort: "StartDate", rowsPerPage: 20 );
Unfortunately, I want the page to come up with the contents initially sorted in descending order on StartDate,so I used the following:
var grid = new WebGrid( Model.OrderByDescending( e => e.StartDate ), rowsPerPage: 20 );
This works fine on both my machine and when I upload the application to the host (GoDaddy). However, when I click on the column heading to sort it works great locally, but the remote version of the application aborts with the following stack trace:
System.TypeAccessException: Attempt by method 'DynamicClass.lambda_method(System.Runtime.CompilerServices.Closure)' to access type 'System.Linq.OrderedEnumerable`2' failed.
at lambda_method(Closure )
at System.Linq.EnumerableQuery`1.GetEnumerator()
at System.Linq.EnumerableQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
at System.Linq.Enumerable.d__4d`1.MoveNext()
at System.Linq.Enumerable.d__3a`1.MoveNext()
...
In my searching I found one reference that looked similar. The answer there postulated that it had something to do with medium trust but it wasn't really definitive nor did it include any suggestion as to how to address the trust issue.
I can w开发者_如何学Goork around this by making every link to this page look like the following, but I'd rather not have to if possible.
/Event/List?sort=StartDate&sortdir=DESC
精彩评论