Unexpected results with paging after application deployment in IIS (MVC3, EF 4.3)

I am currently hosted on the MVC 3 website, which uses Entity Framework 4.3 to access the database.

The application works as expected on the Visual Studio development server, but after it is deployed to a remote server, the request unexpectedly responds to

It should display a sorted list and pages through this sorted data

I tried restarting the web server and the physical server to make sure the cache was gone and even tried to use a clean IIS site on the remote server with the same result.

[Edit]: I also did a complete removal and republish to a clean site as well

In the development of the machine

development machine

On a remote server

enter image description here

The code I use to generate the tables is:

controller

[HttpGet] public virtual ActionResult Index(string filter = "", int? page = null) { page = page ?? 1; filter = filter.Trim().ToLower(); int pageSize = Properties.Settings.Default.DefaultSPPageSize; int skipNum = (page.Value - 1) * pageSize; IQueryable<SamplePoint> spList; var points = new HashSet<string>(Settings.Default.SamplePointFilter.Split(',')); if (filter != "") spList = db.SamplePoints.Where(e=> points.Any(p=> e.Id.StartsWith(p)) && e.Id.ToLower().Trim().StartsWith(filter.ToLower())) .OrderBy(o => o.Id); else spList = db.SamplePoints.Where(e => points.Any(p => e.Id.StartsWith(p)) && e.Id.Trim().StartsWith(filter)).OrderBy(o => o.Id); List<SamplePoint> pageItems; if (page != 0) { pageItems = spList.Skip(skipNum).Take(pageSize).ToList(); } else { pageItems = spList.OrderBy(o=> o.Id).ToList(); } int _totPages = Convert.ToInt32(pageSize > 0 ? Math.Ceiling(((double)spList.Count() / (double)pageSize)) : 0); var vModel = new SamplePointListViewModel(pageItems, filter) { LocationList = FilterListItems, TotalPages = _totPages, CurrentPage = page.Value }; return View(this.IsExcelRequest() ? MVC.Reports.Views.Excel.SamplePointList : MVC.Reports.Views.SamplePointList, vModel); } 
+6
source share
4 answers

Make sure that the version of ASP.NET MVC on both machines is the same (dev / prod). Other people got problems because of this.

Basically, it happened that the newer version was on a working GAC server.

0
source

A simple solution implements some kind of log and writes the result obtained at intermediate levels into a log file.

If you are using the VS Ultimate version, you can take a picture using IntelliTrace . (I did not use this tool, although I heard about it)

0
source
 spList = db.SamplePoints.Where(e=> points.Any(p=> e.Id.StartsWith(p)) && e.Id.ToLower().Trim().StartsWith(filter.ToLower())) .OrderBy(o => o.Id); 

From your code above,

Is e.ID the first column in your image above? if not, e.Id is the primary key, and IdentitySeed is true? If so, this is your problem, as it is generated automatically, this identifier will differ in the production database and the development database, which causes the display in different ways.

0
source

Do both servers have the same regional settings?

You use string.ToLover and StartsWith , which will perform the conversion based on the current culture.

You must use overloaded versions of these methods with invariant culture.

0
source

Source: https://habr.com/ru/post/916597/


All Articles