How to get the Window user name after you deploy the Silverlight application. It displays & ldquo; Default Pool & ldquo; as the user name of the window

advertisements

I am trying to get Window username in silver light Application. I open aspx page from my silver light page on button click event using below code:

public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
    }

    private void btntest_Click(object sender, RoutedEventArgs e)
    {
        HtmlPage.Window.Navigate(new Uri("WebForm1.aspx", UriKind.Relative));
    }
}

Now on WebForm1.aspx, I am trying to get Window Username using below code:

 public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Label1.Text = System.Environment.UserName;
        }
     }

When I run my silverlight project in my local machine, It gives right Window username in Label1 and it works fine. But When I deploy my appication in IIS and check then It display "DefaultPool" in my Label1.

Can any one help to solve this issue?

Is there any setting in ISS I have to do to get Window UserName?

Thanks, Hitesh


Always test your code in IIS, even on your local machine.

Just like your question yesterday, the code is run on the server machine. So it will return your username on your test box if you run it in Visual Studio instead of IIS and it will return the name of the user IIS is using to host your page or service otherwise.

Why do you want to get the user name? Getting part of the user credential of the client is really not the business of a web application, no matter what technical background.

If you want to get user credentials in a web application, ask the user. If you think you are on a trust level that makes the user want to send his data automatically, create a real application. That's a lot less trouble than a web application where you have to support all kinds of devices and have to cope with all kinds of limitations that are normal for applications we open in our browsers daily.