I am new to web applications and to be hones I am trying to update an old web-application, trying to speed it up. I analyze the application and see what's the reason of the slow in loading pages.. Of course it's the http-requests and I tried to read how can I speed up the requests and I found that I should serialize the data but I don't know how to do that in my application. So I need someone to tell me how to use serialization or how can I speed up the request please: first it uses angular-js so the request is like that:
viewModelHelper.apiPost('Book/book_getList', null,
function (result) {
$scope.gridOptions.data = result.data;
});
and I use simillar methods to have the data...
The viewModelHelper.apiPost in the app.js:
self.apiPost = function (uri, data, success, failure, always) {
self.modelIsValid = true;
$http.post(MyApp.rootPath + uri, data)
.then(function (result) {
success(result);
if (always != null)
always();
}, function (result) {
if (failure != null) {
failure(result);
}
else {
var errorMessage = result.status + ':' + result.statusText;
if (result.data != null) {
if (result.data.Message != null)
errorMessage += ' - ' + result.data.Message;
if (result.data.ExceptionMessage != null)
errorMessage += ' - ' + result.data.ExceptionMessage;
}
}
if (always != null)
always();
});
}
And then let's say in the bookController there is book_getList method:
public JsonResult book_getList()
{
List<BookModels> List = obj.book_getList();
return Json(List, JsonRequestBehavior.AllowGet);
}
And the bookModels have properties like this:
public Guid guid_book_id { get; set; }
public string code { get; set; }
public string closet { get; set; }
public string shelf { get; set; }
public string title { get; set; }
And the method get_list:
public List<BookModels> book_getList()
{
try
{
OpenCon();
List<BookModels> List = con.Query<BookModels>("book_getList", param: null, commandType: CommandType.StoredProcedure).ToList();
return List.ToList();
}
catch (Exception)
{
throw;
}
finally
{
CloseCon();
}
}
Thanks