We help IT Professionals succeed at work.

WebForm.aspx not getting username

yo_bee
yo_bee asked
on
342 Views
Last Modified: 2014-05-12
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
Comment
Watch Question

Daniel Van Der WerkenIndependent Consultant
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
yo_beeDirector of Information Technology
CERTIFIED EXPERT

Author

Commented:
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 KulkarniSr. Sw Eng

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

You many need to write code to eliminate computer name from this.
yo_beeDirector of Information Technology
CERTIFIED EXPERT

Author

Commented:
Where would I place this?
Sr. Sw Eng
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
yo_beeDirector of Information Technology
CERTIFIED EXPERT

Author

Commented:
Now in Debug is show correctly, but in production is shows NT AUTHORITY\IUSR
Top Expert 2013
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
yo_beeDirector of Information Technology
CERTIFIED EXPERT

Author

Commented:
I will test tomorrow.
Thanks for all the suggestions.
yo_beeDirector of Information Technology
CERTIFIED EXPERT

Author

Commented:
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?

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.