title: WCF: unsecured or incorrectly secured fault was received from the other party
body: <p>I have created one wcf service with aspnet role &amp; security.</p>
  
  <p>When I consumed that in one website and try to check that, with correct username &amp; password it works perfect, but with incorrect username &amp; password it gives me an error:</p>
  
  <blockquote>
    <p>An unsecured or incorrectly secured fault was received from the other
    party. See the inner FaultException for the fault code and detail.</p>
  </blockquote>
  
  <p>I would have expected to get "Access is Denied" instead.</p>
  
  <p>So, Any idea why???</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>You are right we can add FaultContracts ... but even though I added it gives me same error.. moreover I tried to check the same user isinrole or not if not then externally fired the FaultException... </p>
  
  <p>Still getting the same error not getting the actual "Access is Denied".</p>
  
  <p>Just to update you that I have used aspnet Form Authentication for checking the credential &amp; in role...
  code is somewhat like</p>
  
  <pre><code>public class SampleService : ISampleService
  {
      [PrincipalPermission(SecurityAction.Demand, Role = "admin")]
      public string GetCurrentTime()
      {
          if (!Roles.IsUserInRole(HttpContext.Current.User.Identity.Name, "admin"))
              return DateTime.Now.ToString();
          else
              throw new FaultException("Access is denied");
      }
  }
  
  [ServiceContract]
  public interface ISampleService
  {
      [OperationContract]
      string GetCurrentTime();
  }
  </code></pre>
  
  <p>At the client side, Where i consumed, this service... </p>
  
  <pre><code>protected void btnSubmit_Click(object sender, EventArgs e)
      {
          try
          {
              ChannelFactory&lt;AuthCustWithAspnetRoleService.ISampleService&gt; factory = new ChannelFactory&lt;AuthCustWithAspnetRoleService.ISampleService&gt;("*");
              factory.Credentials.UserName.UserName = txtUserName.Text.Trim(); // "admin"; 
              factory.Credentials.UserName.Password = txtPassword.Text.Trim(); // "admin";
              AuthCustWithAspnetRoleService.ISampleService proxy = factory.CreateChannel();
              lblMessage.Text = proxy.GetCurrentTime();
          }
          catch (Exception ex)
          {
              lblMessage.Text = ex.Message;
          }
      }
  </code></pre>
  
  <p>Hope this will guide you more about my code and you may help me in more detail....
  I don't know why other (few reference where i understood this concept) got "Access is denied" and I am not directly getting this from system...</p>