| 
WCF. Чтение из блоб работает в selfhosted но не работает в IIS. 
    
           
    
    #38057369
    
    
        Ссылка: Ссылка на сообщение: Ссылка с названием темы: | 
|  | 
|  | 
| У меня есть такой сервис: 1.2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 
 [ServiceContract]
    interface IContentControler
    {
        [WebGet(
            UriTemplate = "b64/{id}",
            BodyStyle = WebMessageBodyStyle.Bare,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        string GetContentAsBase64(string id);
    }
С вот такой соответственно реализацией:
  1.2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.
 14.
 15.
 16.
 17.
 18.
 19.
 20.
 21.
 22.
 23.
 24.
 25.
 26.
 
 public string GetContentAsBase64(string id)
        {
            Guid guid;
            if (!Guid.TryParse(id, out guid))
                //return null;
                guid = Guid.Empty;
            blobSrorage b;
            using (var context = new InteractiveMapEntities())
            {
                Contents c;
                try
                {
                    c = context.Contents.Where(λ => λ.ID == guid).Select(λ => λ).Single();
                }
                catch
                {
                    //Till debag
                    c = context.Contents.Select(λ => λ).First();
                }
                if (c == null)
                    return null;
                b = ReadContentFromDB(c.ID);
                WebOperationContext.Current.OutgoingResponse.ContentType = c.ContentType + '/' + Path.GetExtension(c.Name).Substring(1);
            }
Конфигурация вот такая:
  1.2.
 3.
 4.
 5.
 6.
 7.
 8.
 9.
 10.
 11.
 12.
 13.
 14.
 15.
 16.
 17.
 18.
 19.
 20.
 21.
 22.
 23.
 24.
 25.
 26.
 27.
 28.
 29.
 30.
 31.
 32.
 33.
 34.
 35.
 36.
 37.
 38.
 39.
 40.
 41.
 42.
 43.
 44.
 45.
 46.
 47.
 48.
 49.
 50.
 51.
 52.
 53.
 54.
 55.
 56.
 57.
 58.
 59.
 60.
 61.
 62.
 63.
 64.
 65.
 66.
 67.
 68.
 69.
 70.
 71.
 72.
 73.
 74.
 75.
 76.
 77.
 78.
 79.
 80.
 81.
 82.
 83.
 84.
 85.
 86.
 87.
 88.
 89.
 90.
 91.
 92.
 93.
 94.
 95.
 96.
 97.
 98.
 99.
 100.
 101.
 102.
 103.
 104.
 105.
 106.
 107.
 108.
 109.
 110.
 111.
 112.
 113.
 114.
 115.
 116.
 117.
 
 <?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
  </appSettings>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--handlers>
      <add name="ExtensionlessUrl-Integrated-4.0"
           path="*."
           verb="GET,HEAD,POST,DEBUG,PUT,DELETE,UPDATE,OPTIONS"
           type="System.Web.Handlers.TransferRequestHandler"
           preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers-->
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*,application/octet-stream,text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1" />
        <add name="Access-Control-Allow-Methods" value="GET,HEAD,POST,DEBUG,PUT,DELETE,UPDATE," />
        <add name="Access-Control-Allow-Headers" value="Content-Type, Accept, SOAPAction, Origin"/>
        <add name="Access-Control-Max-Age" value="1728000" />
      </customHeaders>      
    </httpProtocol>    
  </system.webServer>
  <system.web>
    <customErrors mode="On"/>
    <pages validateRequest="false"/>
    <compilation debug="true" />
    <httpRuntime maxUrlLength="2048" enableHeaderChecking="false" maxRequestLength="2000000"/>
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" 
             type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" 
             serviceUri="" />
      </providers>
    </membership>
    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider"
             type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
             serviceUri=""
             cacheTimeout="86400" />
      </providers>
    </roleManager>
  </system.web>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webBind"
                 transferMode="Buffered"
                 crossDomainScriptAccessEnabled="true"
                 receiveTimeout="01:05:00"
                 maxReceivedMessageSize="2147483647"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647">
          <readerQuotas maxArrayLength="2147483647"
                        maxStringContentLength="2147483647" />
          <security mode="None" />
        </binding>
      </webHttpBinding>
      <netHttpBinding>
        <binding name="wsBind" messageEncoding="Text">
          <security mode="None"/>
        </binding>
      </netHttpBinding>
    </bindings>
    <services>
      <service name="ServiceLibrary.Business_Layer.ContentControler">
        <endpoint address=""
                  behaviorConfiguration="webEndPointBehavior"
                  binding="webHttpBinding"
                  bindingConfiguration="webBind"
                  contract="ServiceLibrary.Service_Layer.IContentControler" />
        <endpoint address="ws" binding="netHttpBinding" bindingConfiguration="wsBind" contract="ServiceLibrary.Service_Layer.IContentControler"/>
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/InteractiveMap" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webEndPointBehavior">
          <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" defaultBodyStyle="Wrapped"/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceThrottling maxConcurrentCalls="64" maxConcurrentInstances="64" maxConcurrentSessions="64"/>
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <connectionStrings>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "R:\wcf.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>
</configuration>
Проблема: 
В Self-hosted режиме приложение всё мне возвращает как положено. Из под IIS возвращает ошибку 400.
 
Думаю ноги растут из каких то секурити настроек IIS, но к сожалению сам я всё ещё не понял что именно не так. Буду очень благодарен за совет. | 
|  |