locked
Uploading file problem The remote server returned an unexpected response: (400) Bad Request RRS feed

  • Question

  • User-1716494584 posted

    Hello,

            I searched so many forums but i am confused which setting i have to do in web.config file and where i have to do? I have two application seperate 1.Asp.net application 2.WCF Service Application; i added service reference in my Asp.net application.these applications are not hosted on IIS i am testing it on my local machine.Please provide me guide line to pass uploaded file to Service application. 

    Asp.net application web.config

    <configuration>
    	<configSections>
    	</configSections>
    	<system.web>
    		<compilation debug="true" targetFramework="4.0">
    			<assemblies>
    				<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    				<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    				<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    				<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    			</assemblies>
    		</compilation>
    	</system.web>
    	<system.serviceModel>
    		<bindings>
    			<basicHttpBinding>
    				<binding name="BasicHttpBinding_IWCF" 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>
    		</bindings>
    		<client>
    			<endpoint address="http://localhost:7147/WCFService.svc" binding="basicHttpBinding"
    			 bindingConfiguration="BasicHttpBinding_IWCF" contract="HostedWCF.IWCF"
    			 name="BasicHttpBinding_IWCF" />
    		</client>
    	</system.serviceModel>
    </configuration>

    Service Application Web.config

    <configuration>
    	<connectionStrings>
    		<!--<add name="DPOConnectionString" connectionString="Data Source=s15346491\SQLEXPRESS;Database=DatabaseName;Uid=UserID;Password=password;"/>-->
    		<add name="ConnectionString" connectionString="Data Source=SWAPNIL-PC;Initial Catalog=PayrollNet;Integrated Security=True" />
    	</connectionStrings>
    	<appSettings>
    		<add key="LogoPath" value="C:\Users\HARSH12\Desktop\New Conversion 26-7-2013\ConstructionApplication\CMSERPService\ErrorLog\ErrorLog.txt" />
    	</appSettings>
    	<system.web>
    		<compilation debug="true" targetFramework="4.0" />
    	</system.web>
    	<system.serviceModel>
    		<behaviors>
    			<serviceBehaviors>
    				<behavior>
    					<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
    					<serviceMetadata httpGetEnabled="true" />
    					<!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
    					<serviceDebug includeExceptionDetailInFaults="false" />
    				</behavior>
    			</serviceBehaviors>
    		</behaviors>
    		<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    	</system.serviceModel>
    	<system.webServer>
    		<modules runAllManagedModulesForAllRequests="true" />
    		<defaultDocument>
    			<files>
    				<add value="WCFService.svc" />
    			</files>
    		</defaultDocument>
    	</system.webServer>
    </configuration>

    Tuesday, January 28, 2014 7:13 AM

Answers

  • User260886948 posted

    Hi,

    If you want to upload the a large file, it will be better for you to increase the timeout and size value to a larger size and also please try to use a streamed mode instand of the buffered mode:

    <binding name="BasicHttpBinding_ITransferService" closeTimeout="04:01:00"
         openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
         allowCookies="false" bypassProxyOnLocal="false" 
         hostNameComparisonMode="StrongWildcard"
         maxBufferSize="2147483647" maxBufferPoolSize="2147483647" 
         maxReceivedMessageSize="2147483647"
         messageEncoding="Text" textEncoding="utf-8" 
         transferMode="Streamed"
         useDefaultWebProxy="true">
      <readerQuotas maxDepth="128" 
          maxStringContentLength="2147483647" maxArrayLength="2147483647"
          maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None">
          <transport clientCredentialType="None" 
                  proxyCredentialType="None" realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>


    Also if the above can not help, please try to set includeExceptionDetailInFaults to true to get more error information:

     <serviceDebug includeExceptionDetailInFaults="false" />
    

    Best Regards,
    Amy Peng

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 29, 2014 9:52 AM

All replies

  • User-2139489267 posted

    How're you calling your WCF service from Asp.net application? Code would definitely help.

    Tuesday, January 28, 2014 8:23 AM
  • User-1716494584 posted

    I just included service references using "Add service references"

    Tuesday, January 28, 2014 8:31 AM
  • User260886948 posted

    Hi,

    If you want to upload the a large file, it will be better for you to increase the timeout and size value to a larger size and also please try to use a streamed mode instand of the buffered mode:

    <binding name="BasicHttpBinding_ITransferService" closeTimeout="04:01:00"
         openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00"
         allowCookies="false" bypassProxyOnLocal="false" 
         hostNameComparisonMode="StrongWildcard"
         maxBufferSize="2147483647" maxBufferPoolSize="2147483647" 
         maxReceivedMessageSize="2147483647"
         messageEncoding="Text" textEncoding="utf-8" 
         transferMode="Streamed"
         useDefaultWebProxy="true">
      <readerQuotas maxDepth="128" 
          maxStringContentLength="2147483647" maxArrayLength="2147483647"
          maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="None">
          <transport clientCredentialType="None" 
                  proxyCredentialType="None" realm="" />
          <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>


    Also if the above can not help, please try to set includeExceptionDetailInFaults to true to get more error information:

     <serviceDebug includeExceptionDetailInFaults="false" />
    

    Best Regards,
    Amy Peng

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 29, 2014 9:52 AM