Search code examples
c#asp.netasp.net-ajax.net-4.5

Sys.WebForms.PageRequestManagerServerErrorException: Exception of type 'System.Web.HttpUnhandledException' was thrown


Currently I am developing (on Windows) an asp page that pulls user submitted ratings on topics, and displays the information for admins. the window shows the average rating for each topic, and if the user decides to, should be able to click a button ("Details" button) to have the page display a modal with each individual submission. What is happening is that, when the "Details" button is clicked, the following pops up in Google Chrome's console:

Uncaught Error: Sys.WebForms.PageRequestManagerServerErrorException: 
Exception of type 'System.Web.HttpUnhandledException' was thrown.
    at Function.Error.create (ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5)
    at Sys.WebForms.PageRequestManager._createPageRequestManagerServerError (ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_ZPalWLzUD8kN%2f8CMQnRLOXpq%2bJ1Q98VkxisU6TES%2fxc%3df_f&t=636832247730000000&n=f:5)
    at Sys.WebForms.PageRequestManager._onFormSubmitCompleted (ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_ZPalWLzUD8kN%2f8CMQnRLOXpq%2bJ1Q98VkxisU6TES%2fxc%3df_f&t=636832247730000000&n=f:5)
    at Array.<anonymous> (ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5)
    at ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5
    at Sys.Net.WebRequest.completed (ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5)
    at XMLHttpRequest._onReadyStateChange (ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5)
Error.create @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5
_createPageRequestManagerServerError @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_ZPalWLzUD8kN%2f8CMQnRLOXpq%2bJ1Q98VkxisU6TES%2fxc%3df_f&t=636832247730000000&n=f:5
_onFormSubmitCompleted @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_ZPalWLzUD8kN%2f8CMQnRLOXpq%2bJ1Q98VkxisU6TES%2fxc%3df_f&t=636832247730000000&n=f:5
(anonymous) @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5
(anonymous) @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5
completed @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5
_onReadyStateChange @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5
XMLHttpRequest.send (async)
executeRequest @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5
executeRequest @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5
invoke @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5
_onFormSubmit @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_ZPalWLzUD8kN%2f8CMQnRLOXpq%2bJ1Q98VkxisU6TES%2fxc%3df_f&t=636832247730000000&n=f:5
(anonymous) @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5
b @ ScriptResource.axd?d=%2fS7cVnwlWD4SmD%2b83Da0flhLDlvn%2b4mQMwbS6JaJMJ8%3d_AifO125gmd63G1Swcz7qV9r0jEeTlD3He6XxAk%2bAR8o%3df_f&t=636832247730000000&n=f:5

I have never seen this before, and honestly am not sure why it is appearing. The only happens when the button is clicked while the page is hosted on an Ubuntu system using Apache/Mod_Mono. I haven't been able to find any sort of reasoning behind why this is showing either. The following is my code, front and back-end:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
   <asp:UpdatePanel ID="FeedbackViewContent" runat="server">
      <ContentTemplate>
         <div class="modal fade" id="RatingsModalCenter" tabindex="-1" role="dialog" aria-labelledby="RatingsModalCenterTitle" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
               <div class="modal-content">
                  <div class="modal-header">
                     <h4 class="modal-title" id="RatingsModalCenterTitle" runat="server">Application Feedback</h4>
                     <button type="button" id="close" class="close close-dark" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                     </button>
                  </div>
                  <div class="modal-body" runat="server" id="EditorModalBody">
                     <div class="row">
                        <div class="col-6 col-lg-6">
                           <h6>Information Average (All Time):</h6>
                           <asp:TextBox ID="txtRateInfo" runat="server" ReadOnly="true" CssClass="kv-fa rating-loading"></asp:TextBox>
                           <asp:Label ID="lblRateInfo" runat="server" Text="" AssociatedControlID="txtRateInfo"></asp:Label>
                        </div>
                        <div class="col-6 col-lg-6">
                           <h6>Presentation Average (All Time):</h6>>
                           <asp:TextBox ID="txtRatePres" runat="server" ReadOnly="true" CssClass="kv-fa rating-loading"></asp:TextBox>
                           <asp:Label ID="lblRatePres" runat="server" Text="" AssociatedControlID="txtRatePres"></asp:Label>
                        </div>
                     </div>
                  </div>
               <div class="modal-footer">
                  <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
               </div>
            </div>
         </div>
      </div>
      <asp:Panel ID="PanelContent" runat="server"></asp:Panel>
   </ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
   $('.kv-fa').rating({
      theme: 'krajee-fa',
      min: '1',
      max: '5',
      size: 'xs',
      step: '0.1',
      stars: '5',
      displayOnly: true,
      filledStar: '<i class="fa fa-star"></i>',
      emptyStar: '<i class="fa fa-star-o"></i>',
      showCaption: false,
      showClear: true,
   });

   function showModal() {
      $("#RatingsModalCenter").modal('toggle');
   }
</script>

And in code-behind:

//This method is called in Page_Load()
//Purpose is to add the categories to the page that were rated.
protected void ViewReportLayout() {
   PanelContent.Controls.Clear();
   DataTable tblRatingResults = ratings.Select("[Select query to get topics & avg rating from table]");
      if (tblRatingResults.Rows.Count > 1) {
         var listUnordered = new HtmlGenericControl("ul");
         PanelContent.Controls.Add(listUnordered);
//for each topic entry in the results
         foreach (DataRow rating in tblRatingResults.Rows) {
            HtmlGenericControl ListCatItem = new HtmlGenericControl("li");
            ListCatItem.Attributes.Add("class", "list-group-item p-2");
            if (rating["overallAvg"] != null && rating["overallAvg"].ToString() != "") {
//Is there a rating for this topic?
               HtmlGenericControl rateCol1 = new HtmlGenericControl("div");
               HtmlGenericControl rateCol2 = new HtmlGenericControl("div");
               TextBox rateStar = new TextBox();
               HtmlGenericControl rateStr = new HtmlGenericControl("span");
               rateStar.Attributes.Add("class", "kv-fa");
               rateStar.Text = rating["overallAvg"].ToString();
               rateStr.InnerText = Math.Round((decimal)rating["overallAvg"],2).ToString() + " / 5";
               CatRow2.Controls.Add(rateCol1);
               CatRow2.Controls.Add(rateCol2);
               ListCatItem.Controls.Add(rateStar);
               ListCatItem.Controls.Add(rateStr);
            } else {
               HtmlGenericControl rateCol1 = new HtmlGenericControl("div");
               var rateStar = new HtmlGenericControl("span");
               rateCol1.Attributes.Add("class", "col-12 py-0 mb-0");
               rateStar.InnerText = "NO DATA";
               rateCol1.Controls.Add(rateStar);
               ListCatItem.Controls.Add(rateCol1);
            }
//Finally, add the button to show the "Details" modal.
            Button rateBtnDetail = new Button();
            rateBtnDetail.ID = "btnDetail-" + rating["CatID"].ToString();
            rateBtnDetail.Text = "View Details";
            rateBtnDetail.Click += rateBtnDetail_Click;
            CatRow3.Controls.Add(rateBtnDetail);
            listUnordered.Controls.Add(ListCatItem);
         }
      }
   }
}
//This method is called when a 'rateBtnDetail' is clicked.
void rateBtnDetail_Click(object sender, EventArgs e) {
   Button btnClicked = (Button)sender;
   string btnName = btnClicked.ID;
   int catID;
   if (int.TryParse(btnName.Replace("btnDetail-", ""), out catID) != false) {
      string saniCatID = training.Quote(catID.ToString());
      string catAvgBothQuery = "SELECT AVG(ratings.RateInformation) AS 'AvgInfo', AVG(ratings.RatePresentation) AS 'AvgPres', ratings.CatID, categories.CatName FROM categories LEFT JOIN ratings ON categories.CatID = ratings.CatID WHERE ratings.CatID = " + saniCatID + " GROUP BY ratings.CatID";
      string catRateDetailQuery = "SELECT * FROM ratings WHERE CatID = " + saniCatID + " ORDER BY RateTimestamp DESC LIMIT 20";
       DataTable CatAvgBoth = training.Select(catAvgBothQuery);
       DataTable CatRateDetail = training.Select(catRateDetailQuery);
       if (CatAvgBoth.Rows.Count == 1 && CatRateDetail.Rows.Count > 0) {
       txtRateInfo.Text = CatAvgBoth.Rows[0]["AvgInfo"].ToString();
       lblRateInfo.Text = Math.Round((decimal)CatAvgBoth.Rows[0]["AvgInfo"], 2).ToString() + " / 5";
       txtRatePres.Text = CatAvgBoth.Rows[0]["AvgPres"].ToString();
       lblRatePres.Text = Math.Round((decimal)CatAvgBoth.Rows[0]["AvgPres"], 2).ToString() + " / 5";
       }
    }
    ScriptManager.RegisterStartupScript(FeedbackViewContent, FeedbackViewContent.GetType(), "popModal", "showModal();", true);
}

Basically, what is happening is upon clicking the rateBtnDetail button for any topic, the error above appears in Chrome's console. i have commented out the ScriptManager line where i call the "showModal();" startup script, and it still generates the error when any of the 'Details" buttons are clicked. At this point, I am lost, and looking for some direction as to what this could be caused by.


Solution

  • Solved it, turned out to be a simple mistake. My issue was that for my rateStar TextBox, I was attempting to add the css class as an attribute using rateStar.Attributes.Add("class", "kv-fa");.

    Instead, I needed to use rateStar.CssClass = "kv-fa";.