Unable to set maxReceivedMessageSize through web.config

前端 未结 4 439
北荒
北荒 2020-12-09 12:58

I have now investigated the 400 - BadRequest code for the last two hours. A lot of sugestions goes towards ensuring the bindingConfiguration attribute is set correctly, and

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-09 13:21

    All right, this one really caused me a hard time resolving, which I will spare others for. The challenge was in the fact, that I used the <%@ ServiceHost Factory="System.ServiceModel.Activation.WebServiceHostFactory" Service="fullyQualifiedClassName" %>, which is a nice and easy factory implementation approach.

    However, this approach has it drawbacks; since no configuration is needed in the web.config file, the WebServiceHostFactory class by design does not ever read from the web.config file. I know; I could inherit from this class, and make the appropriate changes so it may indeed read from the config file, but this seemed a little out of scope.

    My solution was to go back to the more traditional way of implementing the WCF; <%@ ServiceHost Service="fullyQualifiedClassName" CodeBehind="~/App_Code/Catalogue.cs" %>, and then use my already configured values in the web.config file.

    Here is my modified web.config file (with respect to Maddox headache):

    
        
          
            
              
              
            
          
        
        
          
            
          
        
        
          
            
              
            
          
          
            
              
              
            
            
              
              
            
          
        
      
    

    Another benefit of this change is, that you can now reference your WCF-rest service directly from .NET; this cannot be done using the Factory model and my implementation of XmlElement through out the solution.

    I hope this can help others with similar issues ...

提交回复
热议问题