Deny direct URL access to action method

前端 未结 5 1945
深忆病人
深忆病人 2021-02-04 11:56

I\'m trying to find a way to deny any direct access to my action methods. Basically what I want my users to click on links to navigate instead of typing the URL directly into th

5条回答
  •  我在风中等你
    2021-02-04 11:58

    A quick way of doing that is to set a session containing a random number in the action which is redirecting, also pass the random number as a parameter to the other action.

    Inside the other action(redirected one), compare the value of the session with the parameter of the action. If values are equal, the user is getting there by pressing button, otherwise, the user gets there by changing the URL. Hope it helps.

    question on Stackoverflow

提交回复
热议问题