Link to home
Start Free TrialLog in
Avatar of yo_bee
yo_beeFlag 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
SOLUTION
Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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?
Please check with following
Request.LogonUserIdentity.Name.ToString()

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

ASKER

Where would I place this?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yo_bee

ASKER

Now in Debug is show correctly, but in production is shows NT AUTHORITY\IUSR
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yo_bee

ASKER

I will test tomorrow.
Thanks for all the suggestions.
Avatar of 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?