Access Javascript variable in Razor code

前端 未结 2 1454
逝去的感伤
逝去的感伤 2020-12-21 14:34

I want to pass javascript variable in the C# method which is call from the Razor page. May I know how can I do that? (I refer this link but it did not work for me.)

2条回答
  •  情深已故
    2020-12-21 14:45

    You can't do something like this, because razor works in render time of the page. UserID is not available at render time, thats why you can not pass it as a variable to servercode.

    if you need to call SomeMethod on runtime, you can make a ajax request for it.

提交回复
热议问题