Monday, March 26, 2012

MainPage wont work on server, but other pages do

When i run the project from my local pc everything works fine. However when i deploy the project to the server, all the pages seem to work fine except for the mainpage. I moved the project to the server by changing the vbproj.webifno file to the corresponding path, copying the project and using Internet Information Services to create the application.
This project was previously working on the server, with the code on the mainpage the same as mainpage i'm running now, except for another if statement. (which works ok on my local pc).
Thanks for any help offered
The following error message is displayed:

Server Error in '/TestReportPage' Application.

Index was outside the bounds of the array.

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.IndexOutOfRangeException: Index was outside the bounds of the array.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[IndexOutOfRangeException: Index was outside the bounds of the array.] System.Array.InternalGetValue(Int32 index1, Int32 index2, Int32 index3) +0 System.Array.GetValue(Int32 index) +32 Microsoft.VisualBasic.CompilerServices.LateBinding.LateIndexGet(Object o, Object[] args, String[] paramnames) +189 ReportPage.MainPage.Page_Load(Object sender, EventArgs e) +236 System.Web.UI.Control.OnLoad(EventArgs e) +67 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +731
What is the code on the line that fails? (and a few lines either side of it for context)


Here is the code on the page that uses an array,
** denotes line 66 where the problem seems to come from.
What I dont understand however is why it works on the localhost and not on the server, and the same code has previously worked on the server.

Thanks Aidy...


PrivateSub Page_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)HandlesMyBase.Load

Dim dtodayAsDate = Today

thismth = DatePart(DateInterval.Month, dtoday)

Session("Mth") = thismth - 1

'Get the username of the user logged onto the website

Dim arrSomething, strNTUser, strNTDomain

arrSomething = Split(User.Identity.Name, "\")

Dim sUNameAsString

sUName = arrSomething(1)**

sUName = sUName.ToUpper

lblRole.InnerHtml = sUName

Session("UName") = sUName

...


The username is coming back blank so your array has no elements in it. You need to enable windows authentication and disable anonymous browsing. That will make the identity come back as

domain\user

like you are expecting.


Thanks a million, that did the trick!Big Smile [:D]

0 comments:

Post a Comment