Avatar of yo_bee
yo_bee
Flag for United States of America asked on

WebForm.aspx not getting username

I have a simple webform that works during debugging, but once I publish to the website it is not working as expected.

The Form gets web address and appends the user name (SmithJ) to the end of the address.
This works as it is expected to during the debug process.

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1" %>

<!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>   
<div>
 

    <form id="form1" method="get" action="https://commerce.wsj.com/auth/group/login?">
   
    <input type="hidden" name="groupSignOnId" value="TestLaw"/>
    <input type="hidden" name="groupSignOnPassword" value="fstessstM34iAw"/>
    <input type="hidden" name="groupUserKey" id="groupUserKey" runat="server"/>
    <input type="submit" value="Register your WSJ Subscription"/>
    </form>
</div>


1.	Enter First & Last Name <br />
2.	Enter your Firm E-mail address & confirm it<br />
3.	Create a unique password for yourself <br />
4.	Select your Job Title<br />
5.	Check the Subscriber Agreement<br /> 
6.	Press Create Account<br />
    <br />
&nbsp;&nbsp;&nbsp; This is an exampe:<br />
<asp:Image ID="img1" runat="server" ImageUrl=".\images\img1.png" Height="576px" 
        Width="333px" />
    <br />
    <br />
7.	Once you press Create Account you will be brought to another page that shows you that you successfully registered for the firm subscription to WSJ<br />
8.	Press OK and you will be brought to WSJ Online site 
    <a href="http://online.wsj.com/home-page">http://online.wsj.com/home-page</a><br />
    <br />
<asp:Image ID="Image1" runat="server" ImageUrl=".\images\img2.png" Height="164px" 
        Width="278px" /><br />     
    <div>
      
       <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
   

    </div>

</body>
</html>

Open in new window


Here is the VB code snippet:
Imports System.Web


Public Class WebForm1
    Inherits System.Web.UI.Page



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        groupUserKey.Value = Environment.UserName()
        Label1.Text = Environment.UserName()
    End Sub



End Class

Open in new window


For testing purposes I added ASP:LABEL to display what the value is.
When it run it from the IIS server it just displays the APPLICATION POOL assigned to the app.

If there is a better way for me to accomplish getting the user name to the id="groupUserKey" value then I am completely open to the change.

Thanks
Web ApplicationsASP.NET

Avatar of undefined
Last Comment
yo_bee

8/22/2022 - Mon
SOLUTION
Daniel Van Der Werken

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
yo_bee

ASKER
That change just returns an empty value both in the debug and production.

There must be a setting on the IIS server that is not pulling the
Environment.UserName() where in Debug it is.

any ideas?
Utkarsh Kulkarni

Please check with following
Request.LogonUserIdentity.Name.ToString()

You many need to write code to eliminate computer name from this.
yo_bee

ASKER
Where would I place this?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
Utkarsh Kulkarni

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
yo_bee

ASKER
Now in Debug is show correctly, but in production is shows NT AUTHORITY\IUSR
SOLUTION
guru_sami

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
yo_bee

ASKER
I will test tomorrow.
Thanks for all the suggestions.
yo_bee

ASKER
I ended up leveraging Page.User.Identity.Name.Substring(7) to get my desired results.

Now I am looking to bypass the form and het redirect directly from a hyperlink on my intranet page.

Is this possible?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.