Postback Request of ASP.NET Controls are taking too much time

I have created an asp.net website http://www.oureasymart.com which is working fine In localhost. but after hosting it to godaddy when an asp.net control like button is clicked then it is taking too much time around 1 minute to perform its operation. This problem is for every asp.net control of each page.
I think there is no issue with code behind or click event because I tried a simple Response.Redirect() method to move to next page on click of that button but still it is taking same time. Also I tried to call same method with the help of Jquery Ajax and it is working fine. I also enabled tracing in which I checked there is no event which is taking even 1 second. Please have a look at the code and screenshot of trace info and suggest what may be the issue.
TRACE INFO : https://drive.google.com/file/d/19Cl6wpe_Y20FCzxI9d0bUvj8BdaUdgjR/view?usp=drivesdk

In trace info screenshot is taken by searching a product and then clicking on page index in Product Search page.

<div class="row">
                    <asp:Repeater ID="repeater1" runat="server">
                        <ItemTemplate>
                            <div id="lblsp" class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                                <div class="my-list hovereffect w3l-pricehkj">
                                    <img src='data:images/png;base64,<%# Eval("Img1") != System.DBNull.Value ? Convert.ToBase64String((byte[])Eval("Img1")): string.Empty %>' alt="IMG-PRODUCT" style="max-height: 200px;min-height:200px" />
                                    <h3><%#Eval("Prod_Name") %></h3>
                                    <div class="single-infoagile" style="margin-top: 10px">
                                            <ul>
                                                <li>Cash on Delivery Eligible.
                                                </li>
                                                <li>Shipping Speed to Delivery.
                                                </li>

                                            </ul>
                                        </div>
                                    <h6><span>₹<%#Eval("Cost")%></span></h6>

                                    <asp:HiddenField ID="hid_packageId" runat="server" Value='<%#Eval("Prod_Name") %>' />
                                    <div class="overlay">
                                        <h2><%#Eval("Prod_Name") %></h2>
                                        <a class="info" href="ViewProduct.aspx?Name=<%#Server.UrlEncode(Eval("Prod_Name").ToString()) %>">View Details</a>
                                        <input id="btn_addtocart" type="button" class="info" causesvalidation="false" value="Add to Cart" />

                                    </div>
                                </div>

                            </div>
                        </ItemTemplate>
                    </asp:Repeater>
                    <br />
                    
                </div>
            </div>
                

            </div>
            <div class="pagechange">
                            <table>
                                <tr>
                                    <asp:Label ID="lblpage" runat="server" Text="" Font-Size="Medium"></asp:Label></tr>
                                <tr>
                                    <td>
                                        <input id="btn_Prev" type="button" class="btn-link" causesvalidation="false" value="<" />
                                    </td>
                                    <td>
                                        <asp:DataList ID="rptPaging" runat="server" OnItemCommand="rptPaging_ItemCommand" OnItemDataBound="rptPaging_ItemDataBound"
                                            RepeatDirection="Horizontal">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="lbPaging" runat="server" CommandArgument='<%# Eval("PageIndex") %>' CommandName="newPage"
                                                    Text='<%# Eval("PageText") %> ' Width="20px">      
                                                </asp:LinkButton>
                                            </ItemTemplate>
                                        </asp:DataList>
                                    </td>
                                    <td>
                                        <input id="btn_Next" type="button" class="btn-link" causesvalidation="false" value=">" />
                                    </td>
                                </tr>
                            </table>
                        </div>

    **Code Behind:**

 protected void rptPaging_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (!e.CommandName.Equals("newPage")) return;
            CurrentPage = Convert.ToInt32(e.CommandArgument.ToString());
            BindDataIntoRepeater();
        }

 private void BindDataIntoRepeater()
        {
            if(_pgsource.DataSource ==null)
            {
                var dt = GetDataFromDb();
                _pgsource.DataSource = dt;
            }
            _pgsource.AllowPaging = true;
            // Number of items to be displayed in the Repeater
            _pgsource.PageSize = _pageSize;
            _pgsource.CurrentPageIndex = CurrentPage;
            // Keep the Total pages in View State
            ViewState["TotalPages"] = _pgsource.PageCount;
            // set Previous, Next buttons visible          
            //lblPrevious.Visible = !_pgsource.IsFirstPage;
            //lbNext.Visible = !_pgsource.IsLastPage;
            // Bind data into repeater
            
            ProductSearch p = new ProductSearch();
            p.repeater1.DataSource = _pgsource;
            p.repeater1.DataBind();
            // Example: "Page 1 of 10"
            int total = 0;
            if (ViewState["total"] != null)
            {
                total = (int)ViewState["total"];
            }
            lblpage.Text = "Page " + (CurrentPage + 1) + " of " + _pgsource.PageCount + "(" + total + " resultS)";
            // Call the function to do paging
            HandlePaging();
        }
        private void HandlePaging()
        {
            var dt = new DataTable();
            dt.Columns.Add("PageIndex"); //Start from 0
            dt.Columns.Add("PageText"); //Start from 1

            _firstIndex = CurrentPage - 5;
            if (CurrentPage > 5)
                _lastIndex = CurrentPage + 5;
            else
                _lastIndex = 10;

            // Check last page is greater than total page then reduced it 
            // to total no. of page is last index
            if (_lastIndex > Convert.ToInt32(ViewState["TotalPages"]))
            {
                _lastIndex = Convert.ToInt32(ViewState["TotalPages"]);
                _firstIndex = _lastIndex - 10;
            }

            if (_firstIndex < 0)
                _firstIndex = 0;

            // Now creating page number based on above first and last page index
            for (var i = _firstIndex; i < _lastIndex; i++)
            {
                var dr = dt.NewRow();
                dr[0] = i;
                dr[1] = i + 1;
                dt.Rows.Add(dr);
            }

            rptPaging.DataSource = dt;
            rptPaging.DataBind();
        }

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I found the reason for this. Actually on button click View State had huge data because of
Repeater Control I used. Which was causing delay to reach the reach request to server. I disabled View State for repeater and this fixed the problem.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x