This is my first time using MVC. I'm trying to make a search page for an MVC5 page where it'll crate a table with some basic information like name, gender, etc. This is a partial view I want to call using AJAX when someone hits the search button. So on my controler I am using linq to query a remote sql database where I can retrieve at most around 2k records if someone puts no filters. The linq to sql query is fairly fast (I tried returning just JSON instead of a view and it was practically instant), however there is a problem when I'm trying to render my view.
Right now I'm doing something like:
@foreach(var item in Model){
<tr>
<td>@item.name<td>
<td>@item.gender<td>
... etc.
<tr>
}
However, this its ridiculously slow. On chrome it could take anywhere from 30 seconds to over a minute to load. When testing IE10 it never loads, which is a problem because IE10 compatibility is required. I'm using similar syntax to dynamically load in a custom drop down lists with filters on it, which makes the home page take around two seconds to load. I believe it's an issue with the @foreach line because limiting it to 10 records makes it load in 4 seconds, which is still extremely slow, but better. I'm running this off of localhost.I have an old version of this website running off of asp webforms using the same sql query but bound to a gridview instead and it is extremely fast, it loads all records into the same table in under a second.
I really couldn't find anything online to help with speed. Is there something about razor syntax like this that I should be avoiding? Or should I stick with the webforms site since it seems to be faster?