System net webexception the remote server returned an error 500 internal server error

User-96023207 posted
  • Remove From My Forums
  • Question

  • User-96023207 posted

    Hello,

    I’m using the POST method to send the request to the production server and in web response I got the remote server returned an error: (500) Internal Server Error.  I looked in the Even Viewer Application log in localhost and it shows the exception
    message: «The remote server returned an error: (500) Internal Server Error.»  I posted the same issue in asp.net at
    http://forums.asp.net/t/1335692.aspx but no real solution for this issue yet.  I’m hoping anyone here knows or familiar with this issue can help me out with this.  Thanks and really appreciated!

    Exception information:

    Exception type: WebException

    Exception message: The remote server returned an error: (500) Internal Server Error.

    The remote server returned an error: (500) Internal Server Error.

    Description:
    An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

    Source Error:

    Line 75:                 newStream.Close();     //close the stream
    Line 76:                 //Get web Response
    Line 77:                 WResponse = (HttpWebResponse)myRequest.GetResponse();
    Line 78:                 StreamReader sr = new StreamReader(WResponse.GetResponseStream(), Encoding.ASCII);
    Line 79:                 ReturnData = sr.ReadToEnd();

Answers

  • User1064866747 posted
    looking at your error message first of all I would suggest you to recompile your whole application, make sure all the required dlls are there in bin folder when you recompile it.

    • Marked as answer by

      Tuesday, September 28, 2021 12:00 AM

  • Remove From My Forums
  • Question

  • Hello guys,

    the environment is a single Exchange 2010 (hub, cas, mbx) with no Rollup Update 1 running on Windows Server 2008 R2 Standard.

    We got an error running test for ActiveSync:

    Test-ActiveSyncConnectivity -MailboxCredential (get-credential phazzruncak_r) -TrustAnySSLCertificate |fl
    RunspaceId                  : 28227de2-09a6-464b-87a0-70bf2d246957
    LocalSite                   : PHaZZ-Drienova
    SecureAccess                : True
    VirtualDirectoryName        :
    Url                         :
    UrlType                     : Unknown
    Port                        : 0
    ConnectionType              : Plaintext
    ClientAccessServerShortName : exch01
    LocalSiteShortName          : PHaZZ-Drienova
    ClientAccessServer          : exch01.phazz.local
    Scenario                    : Options
    ScenarioDescription         : Issue an HTTP OPTIONS command to retrieve the Exchange ActiveSync protocol version.
    PerformanceCounterName      :
    Result                      : Success
    Error                       :
    UserName                    : runcak_r
    StartTime                   : 1. 2. 2010 12:08:48
    Latency                     : 00:00:00.0468000
    EventType                   : Success
    LatencyInMillisecondsString : 46.80
    Identity                    :
    IsValid                     : True

    RunspaceId                  : 28227de2-09a6-464b-87a0-70bf2d246957
    LocalSite                   : PHaZZ-Drienova
    SecureAccess                : True
    VirtualDirectoryName        :
    Url                         :
    UrlType                     : Unknown
    Port                        : 0
    ConnectionType              : Plaintext
    ClientAccessServerShortName : exch01
    LocalSiteShortName          : PHaZZ-Drienova
    ClientAccessServer          : exch01.phazz.local
    Scenario                    : FolderSync
    ScenarioDescription         : Issue a FolderSync command to retrieve the folder hierarchy.
    PerformanceCounterName      : DirectPush Latency
    Result                      : Failure
    Error                       : [System.Net.WebException]: The remote server returned an error: (500) Internal Server Err
                                  or.

                                                                HTTP response headers:

                                                                MS-Server-ActiveSync: 14.0
                                  X-MS-RP: 2.0,2.1,2.5,12.0,12.1,14.0
                                  MS-ASProtocolVersions: 2.0,2.1,2.5,12.0,12.1,14.0
                                  MS-ASProtocolCommands: Sync,SendMail,SmartForward,SmartReply,GetAttachment,GetHierarchy,C
                                  reateCollection,DeleteCollection,MoveCollection,FolderSync,FolderCreate,FolderDelete,Fold
                                  erUpdate,MoveItems,GetItemEstimate,MeetingResponse,Search,Settings,Ping,ItemOperations,Pr
                                  ovision,ResolveRecipients,ValidateCert
                                  Content-Length: 6218
                                  Cache-Control: private
                                  Content-Type: text/html; charset=utf-8
                                  Date: Mon, 01 Feb 2010 11:08:48 GMT
                                  Server: Microsoft-IIS/7.5
                                  X-AspNet-Version: 2.0.50727
                                  X-Powered-By: ASP.NET

                                                                UserName                    : runcak_r
    StartTime                   : 1. 2. 2010 12:08:48
    Latency                     : -00:00:01
    EventType                   : Error
    LatencyInMillisecondsString :
    Identity                    :
    IsValid                     : True

    Can anyone help on this issue, please?

    Thanks,
    Robert

    Some parameters here…

    Get-ActiveSyncVirtualDirectory |fl
    RunspaceId                                 : 28227de2-09a6-464b-87a0-70bf2d246957
    MobileClientFlags                          : BadItemReportingEnabled, SendWatsonReport
    MobileClientCertificateProvisioningEnabled : False
    BadItemReportingEnabled                    : True
    SendWatsonReport                           : True
    MailboxLoggingEnabled                      : False
    MobileClientCertificateAuthorityURL        :
    MobileClientCertTemplateName               :
    ActiveSyncServer                           : https://webmail.hazz.sk/Microsoft-Server-ActiveSync
    RemoteDocumentsActionForUnknownServers     : Allow
    RemoteDocumentsAllowedServers              : {}
    RemoteDocumentsBlockedServers              : {}
    RemoteDocumentsInternalDomainSuffixList    : {}
    MetabasePath                               : IIS://EXCH01.PHaZZ.local/W3SVC/1/ROOT/Microsoft-Server-ActiveSync
    BasicAuthEnabled                           : True
    WindowsAuthEnabled                         : False
    CompressionEnabled                         : True
    ClientCertAuth                             : Ignore
    WebsiteName                                : Default Web Site
    WebSiteSSLEnabled                          : True
    VirtualDirectoryName                       : Microsoft-Server-ActiveSync
    Path                                       :
    Server                                     : EXCH01
    InternalUrl                                : https://exch01.phazz.local/Microsoft-Server-ActiveSync
    InternalAuthenticationMethods              : {}
    ExternalUrl                                : https://webmail.hazz.sk/Microsoft-Server-ActiveSync
    ExternalAuthenticationMethods              : {}
    AdminDisplayName                           :
    ExchangeVersion                            : 0.10 (14.0.100.0)
    Name                                       : Microsoft-Server-ActiveSync (Default Web Site)
    DistinguishedName                          : CN=Microsoft-Server-ActiveSync (Default Web Site),CN=HTTP,CN=Protocols,CN=
                                                 EXCH01,CN=Servers,CN=Exchange Administrative Group (FYDIBOHF23SPDLT),CN=Ad
                                                 ministrative Groups,CN=PHAZZ,CN=Microsoft Exchange,CN=Services,CN=Configur
                                                 ation,DC=PHaZZ,DC=local
    Identity                                   : EXCH01Microsoft-Server-ActiveSync (Default Web Site)
    Guid                                       : b267652e-fa11-4bf5-bbad-dcc721e69af3
    ObjectCategory                             : PHaZZ.local/Configuration/Schema/ms-Exch-Mobile-Virtual-Directory
    ObjectClass                                : {top, msExchVirtualDirectory, msExchMobileVirtualDirectory}
    WhenChanged                                : 18. 1. 2010 10:54:19
    WhenCreated                                : 7. 12. 2009 15:25:29
    WhenChangedUTC                             : 18. 1. 2010 9:54:19
    WhenCreatedUTC                             : 7. 12. 2009 14:25:29
    OrganizationId                             :
    OriginatingServer                          : dc01.PHaZZ.local
    IsValid                                    : True

    Get-ExchangeCertificate |fl
    AccessRules        : {System.Security.AccessControl.CryptoKeyAccessRule, System.Security.AccessControl.CryptoKeyAccessR
                         ule}
    CertificateDomains : {webmail.hazz.sk, exch01, exch01.phazz.local}
    HasPrivateKey      : True
    IsSelfSigned       : False
    Issuer             : CN=Internal CA, DC=PHaZZ, DC=local
    NotAfter           : 25. 1. 2012 12:16:58
    NotBefore          : 25. 1. 2010 12:16:58
    PublicKeySize      : 2048
    RootCAType         : Enterprise
    SerialNumber       : 2427072E00000000000B
    Services           : IMAP, POP, IIS
    Status             : Valid
    Subject            : CN=webmail.hazz.sk, OU=IT Division, O=PHaZZ MVSR, L=Bratislava, S=Slovak Republic, C=SK
    Thumbprint         : F1656B6BB1E5236E2374343F7459ED02519F9945

    AccessRules        : {System.Security.AccessControl.CryptoKeyAccessRule, System.Security.AccessControl.CryptoKeyAccessR
                         ule, System.Security.AccessControl.CryptoKeyAccessRule, System.Security.AccessControl.CryptoKeyAcc
                         essRule}
    CertificateDomains : {Exch01, Exch01.PHaZZ.local}
    HasPrivateKey      : True
    IsSelfSigned       : True
    Issuer             : CN=Exch01
    NotAfter           : 7. 12. 2014 15:21:21
    NotBefore          : 7. 12. 2009 15:21:21
    PublicKeySize      : 2048
    RootCAType         : None
    SerialNumber       : 5BE5A57033447A864C2FAE707264353F
    Services           : IMAP, POP, SMTP
    Status             : Valid
    Subject            : CN=Exch01
    Thumbprint         : 6FFFB840FE3D9449425707ED2F61A14CC93642B2

    Get-ActiveSyncMailboxPolicy |fl
    RunspaceId                               : 28227de2-09a6-464b-87a0-70bf2d246957
    AllowNonProvisionableDevices             : True
    AlphanumericDevicePasswordRequired       : False
    AttachmentsEnabled                       : True
    DeviceEncryptionEnabled                  : False
    RequireStorageCardEncryption             : False
    DevicePasswordEnabled                    : False
    PasswordRecoveryEnabled                  : False
    DevicePolicyRefreshInterval              : unlimited
    AllowSimpleDevicePassword                : True
    MaxAttachmentSize                        : unlimited
    WSSAccessEnabled                         : True
    UNCAccessEnabled                         : True
    MinDevicePasswordLength                  : 4
    MaxInactivityTimeDeviceLock              : 00:15:00
    MaxDevicePasswordFailedAttempts          : 8
    DevicePasswordExpiration                 : unlimited
    DevicePasswordHistory                    : 0
    IsDefaultPolicy                          : True
    AllowStorageCard                         : True
    AllowCamera                              : True
    RequireDeviceEncryption                  : False
    AllowUnsignedApplications                : True
    AllowUnsignedInstallationPackages        : True
    AllowWiFi                                : True
    AllowTextMessaging                       : True
    AllowPOPIMAPEmail                        : True
    AllowIrDA                                : True
    RequireManualSyncWhenRoaming             : False
    AllowDesktopSync                         : True
    AllowHTMLEmail                           : True
    RequireSignedSMIMEMessages               : False
    RequireEncryptedSMIMEMessages            : False
    AllowSMIMESoftCerts                      : True
    AllowBrowser                             : True
    AllowConsumerEmail                       : True
    AllowRemoteDesktop                       : True
    AllowInternetSharing                     : True
    AllowBluetooth                           : Allow
    MaxCalendarAgeFilter                     : All
    MaxEmailAgeFilter                        : All
    RequireSignedSMIMEAlgorithm              : SHA1
    RequireEncryptionSMIMEAlgorithm          : TripleDES
    AllowSMIMEEncryptionAlgorithmNegotiation : AllowAnyAlgorithmNegotiation
    MinDevicePasswordComplexCharacters       : 3
    MaxEmailBodyTruncationSize               : unlimited
    MaxEmailHTMLBodyTruncationSize           : unlimited
    UnapprovedInROMApplicationList           : {}
    ApprovedApplicationList                  : {}
    AllowExternalDeviceManagement            : False
    MobileOTAUpdateMode                      : MinorVersionUpdates
    AllowMobileOTAUpdate                     : True
    AdminDisplayName                         :
    ExchangeVersion                          : 0.1 (8.0.535.0)
    Name                                     : Default
    DistinguishedName                        : CN=Default,CN=Mobile Mailbox Policies,CN=PHAZZ,CN=Microsoft Exchange,CN=Serv
                                               ices,CN=Configuration,DC=PHaZZ,DC=local
    Identity                                 : Default
    Guid                                     : 7732ef06-83b7-479f-a886-74af5f1bdb90
    ObjectCategory                           : PHaZZ.local/Configuration/Schema/ms-Exch-Mobile-Mailbox-Policy
    ObjectClass                              : {top, msExchRecipientTemplate, msExchMobileMailboxPolicy}
    WhenChanged                              : 7. 12. 2009 15:25:29
    WhenCreated                              : 7. 12. 2009 15:25:29
    WhenChangedUTC                           : 7. 12. 2009 14:25:29
    WhenCreatedUTC                           : 7. 12. 2009 14:25:29
    OrganizationId                           :
    OriginatingServer                        : dc01.PHaZZ.local
    IsValid                                  : True

Answers

  • SOLVED ;-)

    Damned, we found out that some users did not inherit some permissions from object’s parent in active directory organization’s OU.
    This is strange as we did not see any exchange application errors…

    Anyway, thanks to all.

    Regards,
    Robert

    • Marked as answer by

      Thursday, February 4, 2010 1:39 PM

Problem

Error message appear when you try to browse your content in Office document

Symptom

Error mesage :
System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at Cognos.Office.Framework.DataSource.Cognos8.HttpConnection.Send(String sSOAPRequestBody, String sAction, Boolean cacheResult)
at Cognos.Office.Framework.DataSource.Cognos8.HttpConnection.Send(ISOAPRequest request)
at CognosOfficeConnection.Datasource.ReportStore.PortalTree_DoWork(RequestInfo req)
at Cognos.Office.Framework.Threading.ThreadPool.doWork(RequestInfo requestInfo)
at Cognos.Office.Framework.Threading.AsyncCall.AsyncItem`3.Run()
at Cognos.Office.Framework.Threading.AsyncCall.CallMethod()

Cause

wrong settings in IIS 7.x

Resolving The Problem

Open IIS7.x Administartion tool by running “Start>Run>inetmgr.exe”,
selecting your website/application/virtual directory in the left-hand tree view,
clicking on the “Error Pages” icon,
clicking “Edit Feature Settings” action,
and then selecting “Detailed Errors”.
Stop and start IIS

[{«Product»:{«code»:»SSEP7J»,»label»:»Cognos Business Intelligence»},»Business Unit»:{«code»:»BU053″,»label»:»Cloud u0026 Data Platform»},»Component»:»Cognos for Microsoft Office»,»Platform»:[{«code»:»PF033″,»label»:»Windows»}],»Version»:»10.1.1;10.1″,»Edition»:»»,»Line of Business»:{«code»:»»,»label»:»»}}]

In this article I will explain how to solve the following error (exception) occurring inside the GetResponse method of HttpWebRequest class in C# and VB.Net.

An exception of type ‘System.Net.WebException’ occurred in System.dll but was not handled in user code. Additional information: The remote server returned an error: (500) Internal Server Error.

Exception

In following code snippet, the response is being received using the GetResponse method of HttpWebRequest class.

using (HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse())

{

    using (Stream stream = httpResponse.GetResponseStream())

    {

        string json = (new StreamReader(stream)).ReadToEnd();

    }

}

But it raises the following exception:-

An exception of type ‘System.Net.WebException’ occurred in System.dll but was not handled in user code. Additional information: The remote server returned an error: (500) Internal Server Error.

HttpWebRequest GetResponse: The remote server returned an error: (500) Internal Server Error

Reason

This exception could be occurring due to any internal error related to database, runtime error, etc. But problem is the above exception does not give any information why the exception is occurring.

Solution

Though this is not a solution, it will help us find the real cause of the exception.

The code snippet is now wrapped into a Try-Catch block and the WebException is caught in the Catch block.

The exception details are extracted from the WebException object using StreamReader class.

try

{

    using (HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse())

    {

        using (Stream stream = httpResponse.GetResponseStream())

        {

            string json = (new StreamReader(stream)).ReadToEnd();

            gvCustomers.DataSource = (new JavaScriptSerializer()).Deserialize<List<Customer>>(json);

            gvCustomers.DataBind();

        }

    }

}

catch (WebException ex)

{

    string message = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();

}

Now when the code is again executed, the details of the exception occurring are now available in the message variable.

HttpWebRequest GetResponse: The remote server returned an error: (500) Internal Server Error

Download Free Word/PDF/Excel API


Comments


No comments have been added to this article.

Comments

@leotabakov

nopCommerce version: 4.10

Steps to reproduce the problem:

  1. Install default NopCommerce instance on Azure App Service & Azure SQL (e.g. from Azure Marketplace)
    image
  2. Scale out (App Service plan) to 2 instances or more
    image
  3. Run simple load test in Azure DevOps (VSTS). e.g. HTTP method GET against store homepage, category page or/and product page
    image

Expected behavior:
Application scales out according to Instance Count and will return 200 Response until it will reach CPU/Memory limit

Actual behavior:
Application returns 500 Internal Server Error for more than 50% of the requests regardless of load level.
image
image

Log level — Error
Short message — The remote server returned an error: (500) Internal Server Error.
Full message —
System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.GetResponse()
at System.Net.WebClient.GetWebResponse(WebRequest request)
at System.Net.WebClient.DownloadBits(WebRequest request, Stream writeStream)
at System.Net.WebClient.UploadBits(WebRequest request, Stream readStream, Byte[] buffer, Int32 chunkSize, Byte[] header, Byte[] footer)
at System.Net.WebClient.UploadValues(Uri address, String method, NameValueCollection data)
at Nop.Services.Tasks.TaskThread.Run() in E:nopCommercesourcessrcLibrariesNop.ServicesTasksTaskThread.cs:line 65

@leotabakov
leotabakov

changed the title
Azure App Service multi instance — more than 50% requests (500) Internal Server Error.

Azure App Service multi instance — more than 50% requests (500) Internal Server Error

Oct 29, 2018

@angeor2

Same issue. This should be related to shadow copy

When you have multiple instances you may have one instance up and running while another is stuck because it failed to start. Due to ARRAffinity cookies it is possible you are always directed to the working one. Other users may be stuck with the problematic instance. You could try private/incognito mode to try to see if that’s the case.
The exceptions you see should be from email scheduler trying to reach your problematic server. I assume that they are failing when trying to trigger the email because there is a minimum upload rate that is acceptable in aspnetcore. (if I’m not mistaken the emails are triggered using an http call)

The aforementioned thread describes the reason some instances fail to start in the first place and propose a solution. Up until now the proposed solution hasn’t worked for me

@angeor2

As posted to this thread I managed to consistently run multiple instances by setting Nop:UsePluginsShadowCopy to false and deleting all the deps files for the plugins.

Setting CopyLockedPluginAssembilesToSubdirectoriesOnStartup to true did not work, as sometimes I got System.UnauthorizedAccessException and instances failed to start. Whenever some of the instances did not start I was getting the aforementioned System.Net.WebException at the same time the Send email task was triggered.

@ajhena

Any updates on this? I am experiencing this issue just on deployment. I have 4.1 and the UsePluginsShadowCopy set to false and it isn’t helping. Would it make sense to just turn off the tasks. This is causing me major problems with my site.

@skoshelev

Hi @srrl. The 500 error from the screenshot is not related to shadow copying, the problem seems to be related to the incorrect setting of the store URL address and requests from the scheduled task cannot be executed. In version 4.20, we improved the informativeness of error messages in the system on a schedule tasks, and also solved the issue of disabling shadow copying. Pleace, try to reproduce this issue on the 4.20 beta version, and if the problem still exists, reopen this tiket with new ditails.

Понравилась статья? Поделить с друзьями:
  • System net webexception the remote server returned an error 403 forbidden
  • System net webexception the remote server returned an error 401 unauthorized
  • System net webexception error trustfailure authentication failed see inner exception
  • System net http httprequestexception an error occurred while sending the request
  • System launcher ошибка загрузки xiaomi