简体   繁体   中英

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

System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.HttpWebRequest.GetResponse() at SMS.Testpage.btnsubmit_Click(Object sender, EventArgs e)

this is the error im getting when my im uploading my files to the remote server. As in case of local host it is working fine and returning the same wat i am expecting , but im not getting why it is behaving like this , if any one having the idea on my errors , plz let me get out of this big issue.I really struggling with this issue since 3 weeks.

Here is my web config code---

<configuration>
  <connectionStrings>
    <add name="mydbcon" connectionString="Data Source=xyz;Initial Catalog=smspro;Persist Security Info=True;User ID=xyz;Password=xyz" />
  </connectionStrings>

  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime />
     <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    <!--<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>-->
  </system.web>
  <appSettings />

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="epBasicHttp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="UserName" algorithmSuite="Default"/>
          </security>
        </binding>
      </basicHttpBinding>
      <netTcpBinding>
        <binding name="tcpBinding" receiveTimeout="00:15:00" sendTimeout="00:15:00"  maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
          <security mode="None">
            <transport clientCredentialType="None" protectionLevel="None" />
            <message clientCredentialType="None" />
          </security>
        </binding>
        <!--<binding name="epNetTcp" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/`enter code here`>
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
          <security mode="None">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
            <message clientCredentialType="Windows"/>
          </security>
        </binding>-->
      </netTcpBinding>
    </bindings>
    <services>
      <service name="SMS.Services.Communication">
        <endpoint address="http://localhost:3053/Services/Communication.svc" binding="webHttpBinding" contract="SMS.Services.ICommunication"
                  behaviorConfiguration="Web"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="Web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <serviceHostingEnvironment  minFreeMemoryPercentageToActivateService="0"/>
    <!--<serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" />-->
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

Your code is crashing when it runs in the server. You need to get more details about why it is crashing inorder to fix it. The first thing to do is to update the web config so that it can give you more details of the error. Set the customErrors element's mode property value to "Off"

<system.web>
    <customErrors mode="Off" />
    //Other items goes here
</system.web>

The possible reasons i can think of are

  1. You have an incorrect connection string. Some have the code is not able to access your db server. Double check the db server name is correct.

  2. The code do not have permissions to write to some directory (When you do a file upload, you need to make sure that the directories permission's are updated so that ASP.NET can write to that folder).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM