Click here to Skip to main content
16,005,339 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have an app which uses some data from user computer (accessed via class System.Environment)
Specifically I need System.Environment.UserName and System.Environment.UserDomainName. Is it possible to access that data from within C# ASP.NET web-page? If so - what should be the approach?

Thank you in advance!
Posted

 
Share this answer
 
Comments
MK-Gii 6-Feb-14 10:10am    
Seems like this will only get stuff from the server - not from the user. What I actually need - is username of person dialing into my website. For example user from outside the world comes and the page get's his UserID (from his local computer). All the WindowsIdentity and Principal classes refer to the server side where the code is actually running... I suppose we need some sort of different approach here...
Artefakt94 6-Feb-14 11:14am    
http://stackoverflow.com/questions/11417640/how-i-can-obtain-client-hostname-local-computer-name-and-user-name-in-c-sharp-a
Refer the link , especially the last part of the Article.

System Information[^]
 
Share this answer
 
If I got you correctlt then try like this

.aspx Page


HTML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="envornment.aspx.cs" Inherits="TestApplication.envornment" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    User Name :
    <asp:Label ID="lblUserName" runat="server"></asp:Label>
    <br />
     User Domain Name :
    <asp:Label ID="lblUserDomainName" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>



.aspx.cs Page


C#
using System;
namespace TestApplication
{
    public partial class envornment : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblUserName.Text = Request.ServerVariables["REMOTE_USER"];
            lblUserDomainName.Text = Request.ServerVariables["REMOTE_ADDR"];
        }
    }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900