You must Sign In to post a response.
  • Category: ASP.NET

    Loading issue in web api and angular js

    Hi,

    When I try to display records in table using webapi and angularjs , page loading is slow in first time

    my code foe webapi

    private ExerciseEntities1 db = new ExerciseEntities1();

    // GET api/Employee
    public IQueryable<Employee> GetEmployees()
    {
    return db.Employees;
    }

    index page

    <style type="text/css">
    table, tr, td, th {
    border: 1px solid grey;
    border-collapse: collapse;
    }
    </style>

    <script src="~/Scripts/angular.min.js"></script>
    <script>
    var App = angular.module("myApp", [])
    App.controller("myCtrl", function ($scope, $http) {
    GetAll();
    function GetAll() {

    $http.get('/api/employee/').then(function (response) {
    $scope.Employee = response.data
    }, function () {
    alert("failure");
    }
    );
    }


    });


    </script>
    <div ng-app="myApp" ng-controller="myCtrl">
    <table>
    <tr><td>Id</td><td>FirstName</td><td>LastName</td><td>Company</td></tr>
    <tr ng-repeat="item in Employee">


    <td>{{item.Id}}</td>
    <td>{{item.FirstName}}</td>
    <td>{{item.LastName}}</td>
    <td>{{item.Company}}</td>

    </tr>



    </table>



    </div>

    code has no error.problem getting slow on loading first time


    how to solve this


    Regards

    Baiju
  • #769657
    I think the mentioned code was very clear. please check what was other stuff you have in the default page.

    The default page is usually used to have 40% - 50% more scripts than other pages. So that is cause of it maybe. Because of other pages load at a good speed than its not an issue with IIS or any other. The scripts are causing this.

    very first time, when you load it used to take lot of time to download all the scripts and links mentioned in the page and cached. so, second time on-wards it wont take that much time
    and it takes half of the first request time.

    Try to checking all scripts once again. And delete any unused script it has and specify only the required scripts or links.

    Thanks!
    B.Ramana Reddy


  • Sign In to post your comments