Search code examples
c#asp.netajaxwebmethod

Securing Webmethods


I am using JQuery AJAX with webmethods . As regular session authentication wont work in webmethod what are possible methods of securing webmethods so that a user wont copy that url from client debugging tools and use it .


Solution

  • You can use sessions in your webmethods. Simply add (true) into your WebMethod attribute.

    [WebMethod(true)]
    public string MyMethod
    

    If you're using some of the built in authentication you can also use:

    [Authorize(Roles = "RoleName")]