?
Solved

IIS 7 error when browsing asp.net website

Posted on 2013-01-12
7
Medium Priority
?
917 Views
Last Modified: 2013-01-14
when browsing ASP.net from IIS 7,  I am getting the following error. How can I change:

mylen = Len(NTuser) -8
NTuser = Mid(NTuser, 9, myLen)            

 so that it wont give me an error.


Argument 'Length' must be greater or equal to zero.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Argument 'Length' must be greater or equal to zero.

Source Error:
Line 62:         NTuser = UCase(Request.ServerVariables("LOGON_USER"))
Line 63:         mylen = Len(NTuser) -8
Line 64:         NTuser = Mid(NTuser, 9, myLen)

Source File: C:\inetpub\wwwroot2\TEST\default.aspx    Line: 64

Stack Trace:
[ArgumentException: Argument 'Length' must be greater or equal to zero.]
   Microsoft.VisualBasic.Strings.Mid(String str, Int32 Start, Int32 Length) +723658
   ASP.default_aspx.page_Load(Object Sender, EventArgs E) in C:\inetpub\wwwroot2\TEST\default.aspx:64
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428

Version Information: Microsoft .NET Framework Version:2.0.50727.4223; ASP.NET Version:2.0.50727.4223
0
Comment
Question by:ocdc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 13

Expert Comment

by:Surone1
ID: 38770760
you need to check if Len(NTuser) is at least 9 (or mylen is at least 1) before you use the mid function
0
 

Author Comment

by:ocdc
ID: 38771112
How do i do that? Thanks.
0
 
LVL 82

Accepted Solution

by:
David Johnson, CD, MVP earned 200 total points
ID: 38771123
You must not have anonymous authentication turned on. http://support.microsoft.com/kb/306359

You should do some error checking to ensure that you are actually getting a value for NTUser.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ocdc
ID: 38771205
It is not turned on.
0
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 38771219
Do you have forms or Windows Authentication Turned On? (you need one or the other preferably Windows Authentication)
0
 

Author Comment

by:ocdc
ID: 38771297
Windows Authentication Turned On
0
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 38771339
Try this and check your results, expecially username length

Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Web Server Username Test</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Username is: <asp:TextBox ID="TextBox1" runat="server" Width="386px">Username</asp:TextBox>
    Username Length is: <asp:Label ID="Label1" runat="server"></asp:Label>
    Uppercase Username is: <asp:Label ID="Label3" runat="server"></asp:Label>
    After Mid-String Operation: <asp:Label ID="Label4" runat="server"></asp:Label>
    </div>
    </form>
</body>
</html>

Open in new window

Code behind default.aspx.vb
Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub TextBox1_Load(sender As Object, e As EventArgs) Handles TextBox1.Load
        TextBox1.Text = Request.ServerVariables("LOGON_USER")
        Label1.Text = Len(Request.ServerVariables("LOGON_USER"))
        Label3.Text = UCase(Request.ServerVariables("LOGON_USER"))
        Label4.Text = Mid(UCase(Request.ServerVariables("LOGON_USER")), 9, Len(Request.ServerVariables("LOGON_USER")))
    End Sub
End Class

Open in new window

0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question