Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Friday 25 October 2013

Restricting access to a webservice in ASP.NET

Restricting access to a webservice can be done via web.config but if you would want to make the decision at runtime then here is an example of how you could achieve this
 

protected void Application_BeginRequest(Object sender, EventArgs e)
{
  if (/*Condition*/)
  {
    if (HttpContext.Current.Request.Url.ToString().Contains("Admin.asmx"))
    {
       HttpContext.Current.Response.StatusCode = 404;
    }
   }
}
Genius ain't anything more than elegant common sense.
Josh Billings

2 comments:

Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers