1
Answer

How To send Values from aspx.cs to controller class?

Photo of Jaya Prakash

Jaya Prakash

1y
395
1

I have an aspx login page and in my controller class works as a webhook page getting response from api 
but i have to insert userid who is currently logged in and using the service but my webhook page works only in beta

in my table i have to insert userid how can i? 
im doing only in asp.net taking apicontroller class to hit APIs

Answers (1)

3
Photo of Jayraj Chhaya
298 6k 96.3k 1y

To send the user ID from the ASPX login page to the controller class, you can utilize the ASP.NET session state to store and retrieve the user ID. In the ASPX.CS file, after successful login, store the user ID in the session:

Session["UserID"] = loggedInUserID;

Then, in your controller class, retrieve the user ID from the session:

int userID = Convert.ToInt32(Session["UserID"]);

You can then use this userID to insert the user ID into your table. Ensure to handle cases where the session might be null or expired.

Accepted