How to protect WebMethod in asp.net/Jquery

I am using Jquery Ajax to call WebMethod from an aspx page. Here is my code

$(document).ready(function () {
        $("#btnshow").click(function () {
               $.ajax({

                type: "POST",
                url: "example.aspx/showData",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    $("#Result").text(msg.d);
                }
            });
        });
    });

on aspx.cs page:

[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
public static List<LandmarkList> showData()
{
    LandmarkList ObjLL = new LandmarkList();
    return ObjLL.GetDataList();
}

My question is, what is a professional way to protect this web method? What are the possible ways to protect web methods so that the user does not copy this URL from client debugging tools and use it.

Note. These are open pages, the user does not need to log in for these pages.

UPDATE: I want someone to continue to use my web service without actually visiting my site.

+4
source share
1 answer

showData(), , url example.aspx/showData .

-, , . , , , ( -) ( ). , , . http://www.asp.net/web-api/overview/security/preventing-cross-site-request-forgery-%28csrf%29-attacks.

, - , , , - , . , , script , , . - , , " -, , / ".

, , , - , -.

0

Source: https://habr.com/ru/post/1536315/


All Articles