Link to home
Create AccountLog in
Avatar of akoIT
akoIT

asked on

an unknown error has occurred while processing the request on the server. the status code returned from the server was 500

Hi All,

Can you help me resolve this issue on button click?

an unknown error has occurred while processing the request on the server. the status code returned from the server was 500
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

What code you have written? Can you please share.
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of akoIT
akoIT

ASKER

Hi Pawan thanks for response. Here is the sample code.

I have a button and an gridview inside update panel.

<asp:UpdatePanel ID="sample" runat="server" >
 <contentTemplate>

       <button type="button" runat="server" onclick="javascript: LoadingModal();" onserverclick="GenerateReport" />

     <asp:GridView ID="gridViewRpt" runat="server">
     </asp:GridView>


 </ contentTemplate>
</asp:UpdatePanel>

CODE BEHIND:

Protected Sub GenerateReport(sender as object, e as EventArgs)
........
gridViewRpt.DataSource = cmd.ExecuteReader()
gridViewRpt.DataBind()
End Sub

when i click the button on the first time, there is no error, but when i click it again this error is occured.
Avatar of akoIT

ASKER

Hi Ryan Chong, how can I prevent this kind of error?
how can I prevent this kind of error?

try to verify what's the exact error generated from server end...

for example, if you can't just-in-time debugging... try do a try catch in Sub GenerateReport and send that error into a custom log file for debugging.

Just-In-Time Debugging in Visual Studio
https://msdn.microsoft.com/en-us/library/5hs4b7a6.aspx?f=255&MSPPError=-2147217396

for the custom log, we usually use log4net library which you can get from NuGet Manager.

log4net
https://www.nuget.org/packages/log4net/