I work on asp.net MVC application . suppose my user name of my pc is Michel
so i need to rerun this name Michel when application hosted on iis
so i can insert this name with every transaction done and which user insert transactions
i face issue on that it always return name of application on iis hosted app
so how to solve that please
Jayraj ChhayaPosted Dec 19, 2023, 6:02 AM
Hello,
To retrieve the user profile for the machine when your ASP.NET MVC application is hosted on IIS, you can use the
Environment.UserNameproperty. This property returns the username of the currently logged-in user on the server where the application is running.However, since you want to display the username of the PC where the application is accessed, you need to use a different approach. One way to achieve this is by using JavaScript on the client-side to retrieve the PC username and send it to the server.
Here's an example of how you can accomplish this:
By using this approach, you will be able to capture the PC username and use it in your application, regardless of whether it is hosted on IIS or accessed from a different machine.
Jignesh KumarPosted Dec 19, 2023, 4:46 AM
Hello Ahemd,
you can access user profile information through the
HttpContextobject.