title: How to use Basic authentication for web browser requests with ServiceStack?
body: <p>I have a REST API built using ServiceStack. I am using BasicAuthentication without any issues when calling the REST APIs (I am registering the <code>AuthFeature</code> with the <code>BasicAuthProvider</code>).</p>
  
  <p>Now I am trying to build some HTML management pages. These should also be authenticated.</p>
  
  <p>The [Authenticate] attribute redirects to the /login page, so I created the following DTO and matching service to handle logins:</p>
  
  <pre><code>    [DefaultView("Login")]
      public class SiteLoginService : EnshareServiceBase
      {
          public object Get(SiteLoginRequest req)
          {
              return new SiteLoginRequest();
          }
  
          public object Post(SiteLoginRequest req)
          {
              //I am trying to use the registered IAuthProvider, which is the BasicAuthProvider
              var authProvider = ResolveService&lt;IAuthProvider&gt;();
              authProvider.Authenticate(this, EnshareSession,
                                        new ServiceStack.ServiceInterface.Auth.Auth()
                                        {
                                            Password = req.Password,
                                            UserName = req.UserName
                                        });
              return HttpResult.Redirect(req.Redirect);
          }
      }
  
      [Route("/login")]
      public class SiteLoginRequest : IReturn&lt;SiteLoginRequest&gt;
      {
          public string Redirect { get; set; }
          public string Password { get; set; }
          public string UserName { get; set; }
      }
  </code></pre>
  
  <p>However, the BasicAuthProvider always throws HttpError: "Invalid BasicAuth credentials" when I fill in username and password on the Login view page and POST these to the SiteLoginService. It is probably because the web browser is not filling in the Basic auth header, but I do not know how to authenticate with filled in username and password.</p>
  
  <p><strong>How to properly authenticate site users against the AuthProvider which works with the existing REST API?</strong></p>