Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your assumption for this beeing an issue of IIS 6 is probably right.</p> <p>I just created a WCF service "xxx.svc" and hosted it in the IIS (7.5), and when I requested it with fiddler2 with a correct Authorization header, it did not send a HTTP 401.</p> <p>I will post my code so that you test it on IIS 6. If it still gives you HTTP 401, then this is surely an IIS 6 issue, if not try to compare and contrast your code with mine and see what configurations are different.</p> <p>web.config:</p> <pre><code>&lt;configuration&gt; &lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;/system.web&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;webHttpBinding&gt; &lt;binding name="webHttpBindConfig"&gt; &lt;security mode="TransportCredentialOnly"&gt; &lt;transport clientCredentialType="Basic" proxyCredentialType="None" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/webHttpBinding&gt; &lt;/bindings&gt; &lt;services&gt; &lt;service name="MyTestSvc.MyService"&gt; &lt;endpoint address="http://localhost/TestBasicAuth/Service1.svc" behaviorConfiguration="webHttpEndpointBehavior" binding="webHttpBinding" bindingConfiguration="webHttpBindConfig" name="webHttpBindingEndpoint" contract="MyTestSvc.IMyService" /&gt; &lt;host&gt; &lt;baseAddresses&gt; &lt;/baseAddresses&gt; &lt;/host&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;endpointBehaviors&gt; &lt;behavior name="webHttpEndpointBehavior"&gt; &lt;webHttp /&gt; &lt;/behavior&gt; &lt;/endpointBehaviors&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true"/&gt; &lt;/system.webServer&gt; &lt;/configuration&gt; </code></pre> <p>Service1.svc</p> <pre><code>&lt;%@ ServiceHost Language="C#" Debug="true" Service="MyTestSvc.MyService" CodeBehind="Service1.svc.cs" %&gt; </code></pre> <p>IService1.cs</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace MyTestSvc { // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together. [ServiceContract] public interface IMyService { [OperationContract] [WebGet(UriTemplate=@"/Hello")] string GetData(); } } </code></pre> <p>and finally: Service1.svc.cs</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace MyTestSvc { // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together. public class MyService : IMyService { public string GetData() { WebOperationContext webCtx = WebOperationContext.Current; IncomingWebRequestContext incomingCtx = webCtx.IncomingRequest; string hdrVal = incomingCtx.Headers["Authorization"]; return string.Format("Authorization: {0}", hdrVal); } } } </code></pre> <p>fiddler Results: <img src="https://i.stack.imgur.com/hZ4f5.png" alt="Fiddler Composer request"></p> <p><img src="https://i.stack.imgur.com/Up5Jg.png" alt="fiddler inspector, request/response raw"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload