title: Authentication and Authorization in asmx webservice
body: <p>I have two asmx services one for <code>Account(Login,Register,Logout)</code> and the other <code>Report(adminreport,userreport)</code>.</p>
  
  <p>Now I want to authorize the access only to <strong>report.asmx</strong> based on the login in account.asmx.</p>
  
  <p>I have done it in <strong>global.ascx</strong></p>
  
  <pre><code>protected void Application_AuthenticateRequest(object sender, EventArgs e)
      {
          if (Context.Request.Url.Segments.Length &gt; 2 &amp;&amp; Context.Request.Url.Segments[Context.Request.Url.Segments.Length - 1] != "Login")
          { 
          HttpContext.Current.Response.StatusCode = 403;
          var httpApplication = sender as HttpApplication;
          httpApplication.CompleteRequest();
          }
      }
  </code></pre>
  
  <p>I know doing this is not good way. but my problem was to restrict  <code>Application_AuthenticateRequest</code> for <strong>account.asmx</strong>.</p>
  
  <p>I have tried location in <strong>web.cfg</strong> and it didnot work and I'm calling the service from ajax.</p>