In one project, we had a requirement to pass a logged in user ID to a WCF service.  There are two ways to achieve this:

  • .Net coding
  • Using Liquid notation

In this blog, we will take a look at passing a user ID using Liquid notation which is much easier. This involves two steps:

  • Assigning the logged in user ID to a hidden field
  • Retrieving the value of the hidden field and passing it to the WCF service using JavaScript.

Assigning a Logged in User to a Hidden Field

This is done in the copy (HTML) section of the webpage. The liquid notation which gives the logged in user is “{{user.id}}”.

 pass a logged in user - assigning to a hidden field

 

Passing the User ID to the WCF Service

In the Advanced section of the Web form, write the java script to extract the data from the hidden control and pass the value to the WCF service.

WCF service

Conclusion

In this blog we saw how to pass a logged in user ID to a WCF Service from Adxstudio Portal. I hope this was helpful. Please drop in your comment.