| | |
how to get network login user name
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2007
Posts: 11
Reputation:
Solved Threads: 0
am trying to create a web page to be used by my network users (inside my intranet)
I want to get the visitor's name of my page ( in another words to get the network login user name of the person who is visiting my web page)
i tried to use the following code but am getting error
<%
' Use the Page.User property to access authentication and
' identity information for the current user. If the user is
' not authenticated, redirect them to a login page.
Sub Page_Load(sender As Object , e As EventArgs)
If User.Identity.IsAuthenticated Then
msgLabel1.Text = "Welcome, <B>" + User.Identity.Name + "</B>!"
Else
Response.Write "sorry"
End If
End Sub
%>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form runat="server">
<h3><asp:label id="msgLabel1" runat="server" /></h3>
</form>
</body>
</html>
but am getting the following error
Server Error in '/' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed.
Source Error:
Line 3: ' identity information for the current user. If the user is
Line 4: ' not authenticated, redirect them to a login page.
Line 5: Sub Page_Load(sender As Object , e As EventArgs)
Line 6: If User.Identity.IsAuthenticated Then
Line 7: msgLabel1.Text = "Welcome, <B>" + User.Identity.Name + "</B>!"
Source File: c:\inetpub\wwwroot\f\username.aspx Line: 5
Show Detailed Compiler Output:
C:\WINDOWS\system32> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_szxvhp9l.dll" /debug- /win32resource:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\szxvhp9l.res" /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_szxvhp9l.0.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_szxvhp9l.1.vb"
Microsoft (R) Visual Basic Compiler version 8.0.50727.42
for Microsoft (R) .NET Framework version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_szxvhp9l.0.vb(101) : error BC30035: Syntax error.
Me.WriteUTF8ResourceString(__w, 0, 327, true)
~~
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_szxvhp9l.0.vb(102) : error BC30429: 'End Sub' must be preceded by a matching 'Sub'.
End Sub
~~~~~~~
c:\inetpub\wwwroot\f\username.aspx(5) : error BC30289: Statement cannot appear within a method body. End of method assumed.
Sub Page_Load(sender As Object , e As EventArgs)
~~~
c:\inetpub\wwwroot\f\username.aspx(7) : error BC30451: Name 'msgLabel1' is not declared.
msgLabel1.Text = "Welcome, <B>" + User.Identity.Name + "</B>!"
~~~~~~~~~
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
I want to get the visitor's name of my page ( in another words to get the network login user name of the person who is visiting my web page)
i tried to use the following code but am getting error
<%
' Use the Page.User property to access authentication and
' identity information for the current user. If the user is
' not authenticated, redirect them to a login page.
Sub Page_Load(sender As Object , e As EventArgs)
If User.Identity.IsAuthenticated Then
msgLabel1.Text = "Welcome, <B>" + User.Identity.Name + "</B>!"
Else
Response.Write "sorry"
End If
End Sub
%>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form runat="server">
<h3><asp:label id="msgLabel1" runat="server" /></h3>
</form>
</body>
</html>
but am getting the following error
Server Error in '/' Application.
--------------------------------------------------------------------------------
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30289: Statement cannot appear within a method body. End of method assumed.
Source Error:
Line 3: ' identity information for the current user. If the user is
Line 4: ' not authenticated, redirect them to a login page.
Line 5: Sub Page_Load(sender As Object , e As EventArgs)
Line 6: If User.Identity.IsAuthenticated Then
Line 7: msgLabel1.Text = "Welcome, <B>" + User.Identity.Name + "</B>!"
Source File: c:\inetpub\wwwroot\f\username.aspx Line: 5
Show Detailed Compiler Output:
C:\WINDOWS\system32> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe" /t:library /utf8output /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_szxvhp9l.dll" /debug- /win32resource:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\szxvhp9l.res" /define:_MYTYPE=\"Web\" /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Specialized,System.Configuration,System.Text,System.Text.RegularExpressions,System.Web,System.Web.Caching,System.Web.SessionState,System.Web.Security,System.Web.Profile,System.Web.UI,System.Web.UI.WebControls,System.Web.UI.WebControls.WebParts,System.Web.UI.HtmlControls "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_szxvhp9l.0.vb" "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_szxvhp9l.1.vb"
Microsoft (R) Visual Basic Compiler version 8.0.50727.42
for Microsoft (R) .NET Framework version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_szxvhp9l.0.vb(101) : error BC30035: Syntax error.
Me.WriteUTF8ResourceString(__w, 0, 327, true)
~~
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\26676eb7\92c7e946\App_Web_szxvhp9l.0.vb(102) : error BC30429: 'End Sub' must be preceded by a matching 'Sub'.
End Sub
~~~~~~~
c:\inetpub\wwwroot\f\username.aspx(5) : error BC30289: Statement cannot appear within a method body. End of method assumed.
Sub Page_Load(sender As Object , e As EventArgs)
~~~
c:\inetpub\wwwroot\f\username.aspx(7) : error BC30451: Name 'msgLabel1' is not declared.
msgLabel1.Text = "Welcome, <B>" + User.Identity.Name + "</B>!"
~~~~~~~~~
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
![]() |
Similar Threads
- External Hard Drive On A Network (Networking Hardware Configuration)
- network login problem (Windows NT / 2000 / XP)
- how to get network login user name (ASP)
- Problem in IIS when login Power User (Networking Hardware Configuration)
- How to extract user network login name with vbscript? (Visual Basic 4 / 5 / 6)
Other Threads in the ASP.NET Forum
- Previous Thread: How to Make a mailbox with all the functionss!!!!
- Next Thread: oracle database
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox class click commonfunctions control countryselector dataaccesslayer database datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql news novell numerical opera panelmasterpagebuttoncontrols problem radio redirect registration relationaldatabases reportemail save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visualstudio vs2008 web webapplications webdevelopemnt webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers





