473,401 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Forms Authentication not working on server

Hello there,

keywords so you can find this message: russell mccloy server forms
authentication InvalidCastException not working after login logon

We have an issue with Forms Authentication. I have a site using forms
authentications. It runs perfectly on 3 pcs and 2 servers but wont run
on our ISP's server.

After login the following error occurs:

[InvalidCastException: Specified cast is not valid.]
BNFL_EnergyUnit.rms.rmsUserControls.rmsMenu.setUpM enuBasedOnAccessLevel()
BNFL_EnergyUnit.rms.rmsUserControls.rmsMenu.Page_L oad(Object
sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +739

I have beed reading for hours and cant find anything.
Got to get this site live by tomorrow.
any help will be greatly appreciated.

RuSs
Nov 19 '05 #1
6 1530
you have a null refernce in setUpMenuBasedOnAccessLevel :) seriously, we
can't tell you anything more....if the function is short you can paste it
and we'll take our best guess at it...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Russell" <ru************@hotmail.com> wrote in message
news:15**************************@posting.google.c om...
Hello there,

keywords so you can find this message: russell mccloy server forms
authentication InvalidCastException not working after login logon

We have an issue with Forms Authentication. I have a site using forms
authentications. It runs perfectly on 3 pcs and 2 servers but wont run
on our ISP's server.

After login the following error occurs:

[InvalidCastException: Specified cast is not valid.]
BNFL_EnergyUnit.rms.rmsUserControls.rmsMenu.setUpM enuBasedOnAccessLevel() BNFL_EnergyUnit.rms.rmsUserControls.rmsMenu.Page_L oad(Object
sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +739

I have beed reading for hours and cant find anything.
Got to get this site live by tomorrow.
any help will be greatly appreciated.

RuSs

Nov 19 '05 #2
Well, seeing the code of this method
BNFL_EnergyUnit.rms.rmsUserControls.rmsMenu.setUpM enuBasedOnAccessLevel()

and the specific line of code this error occurs on would be very helpful...

"Russell" <ru************@hotmail.com> wrote in message news:15**************************@posting.google.c om...
Hello there,

keywords so you can find this message: russell mccloy server forms
authentication InvalidCastException not working after login logon

We have an issue with Forms Authentication. I have a site using forms
authentications. It runs perfectly on 3 pcs and 2 servers but wont run
on our ISP's server.

After login the following error occurs:

[InvalidCastException: Specified cast is not valid.]
BNFL_EnergyUnit.rms.rmsUserControls.rmsMenu.setUpM enuBasedOnAccessLevel()
BNFL_EnergyUnit.rms.rmsUserControls.rmsMenu.Page_L oad(Object
sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Control.LoadRecursive() +98
System.Web.UI.Page.ProcessRequestMain() +739

I have beed reading for hours and cant find anything.
Got to get this site live by tomorrow.
any help will be greatly appreciated.

RuSs

Nov 19 '05 #3
ok.

The code that is failing is on most pages of my site and is:

energyCUSTOM_PRICIPAL currentLoggedInUser =
(energyCUSTOM_PRICIPAL)Context.User;

Basically I have created a more detailed object (energyCUSTOM) that
inherits IPrincipal

The reason I didnt send code is becuase this code works on all our
servers, it just wont work on our ISP so I thought you may know of some
IIS reason why forms authentication isnt working on one server but is on
other.

I cna give more info if required.

thanks
RuSs

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #4
if that's really the line that's failing...the only possibility is that
Context is null...

This to me is impossible if you are using this within a page 'cuz
Page.Context can't be null...my guess is that it's a nother line which is
bugged..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"russell mccloy" <ru************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
ok.

The code that is failing is on most pages of my site and is:

energyCUSTOM_PRICIPAL currentLoggedInUser =
(energyCUSTOM_PRICIPAL)Context.User;

Basically I have created a more detailed object (energyCUSTOM) that
inherits IPrincipal

The reason I didnt send code is becuase this code works on all our
servers, it just wont work on our ISP so I thought you may know of some
IIS reason why forms authentication isnt working on one server but is on
other.

I cna give more info if required.

thanks
RuSs

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #5
Have you tried comparing the object type that "context.user" is at the point of that code on a server that works vs. your ISP. It would be interesting to know if they are different... Are you doing any other code that plays around with the context?

"russell mccloy" <ru************@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
ok.

The code that is failing is on most pages of my site and is:

energyCUSTOM_PRICIPAL currentLoggedInUser =
(energyCUSTOM_PRICIPAL)Context.User;

Basically I have created a more detailed object (energyCUSTOM) that
inherits IPrincipal

The reason I didnt send code is becuase this code works on all our
servers, it just wont work on our ISP so I thought you may know of some
IIS reason why forms authentication isnt working on one server but is on
other.

I cna give more info if required.

thanks
RuSs



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #6
ok,

on my server....which works my context.User is of type:
BNFL_EnergyUnit.CODE.BLL.energyCUSTOM_PRICIPAL

but on the server it is:
System.Security.Principal.GenericPrincipal

something on the server is causing context.User to be a GenericPrincipal
but on my machine it allows me to convert context.user to my
energyCUSTOM_PRICIPAL

Following is my energyCUSTOM_PRICIPAL then inherits IPrincipal

using System;
using System.Security.Principal;
using BNFL_EnergyUnit.CODE.DAL;
using System.Collections;

namespace BNFL_EnergyUnit.CODE.BLL
{
//************************************************** *******************
//
// CustomPrincipal Class
//
// The CustomPrincipal class implements the IPrincipal interface so it
// can be used in place of the GenericPrincipal object. Requirements
for
// implementing the IPrincipal interface include implementing the
// IIdentity interface and an implementation for IsInRole. The custom
// principal is attached to the current request in Global.asax in the
// Authenticate_Request event handler. The user's role is stored in
the
// custom principal object in the Global_AcquireRequestState event
handler.
//
//************************************************** *******************

public class energyCUSTOM_PRICIPAL : IPrincipal
{
private int _UserID;
private int _GroupID = 0;

// Required to implement the IPrincipal interface.
protected IIdentity _Identity;

/// <summary>
/// creates an new instance of the energy unit custom principle which
is a session based object that stores the currently logged on user's
creds. for the current session.
/// </summary>
public energyCUSTOM_PRICIPAL() {}

/// <summary>
/// creates an new instance of the energy unit custom principle which
is a session based object that stores the currently logged on user's
creds. for the current session.
/// </summary>
public energyCUSTOM_PRICIPAL(IIdentity identity, int userID, int
groupID)
{
_Identity = identity;
_UserID = userID;
_GroupID = groupID;
}

// IIdentity property used to retrieve the Identity object attached to
// this principal.
public IIdentity Identity
{
get { return _Identity; }
set { _Identity = value; }
}

// The user's ID, created when the user was inserted into the database
public int UserID
{
get { return _UserID; }
set { _UserID = value; }
}

/// <summary>
/// the users access level editor / content manager / super admin
/// </summary>
public int GroupID
{
get { return _GroupID; }
set { _GroupID = value; }
}
//************************************************** ******************
*
//
// Checks to see if the current user is a member of AT LEAST ONE of
// the roles in the role string. Returns true if found, otherwise
false.
// role is a comma-delimited list of role IDs.
//
//************************************************** ******************
*

public bool IsInRole(string role)
{
string [] roleArray = role.Split(new char[] {','});

foreach (string r in roleArray)
{
if (_GroupID == int.Parse(r))
return true;
}
return false;
}

public bool checkIfUserCanEditThisPage(int userId, int pageId)
{
dataAccessLayer DBLayer = new dataAccessLayer();
return DBLayer.checkIfUserCanEditThisPage(userId, pageId);
}

public ArrayList getUserStreams(int userId, string stream)
{
dataAccessLayer DBLayer = new dataAccessLayer();
return DBLayer.getUserStreams(userId, stream);
}

public static void updateUsersLastLoginDate(int userId)
{
dataAccessLayer DBLayer = new dataAccessLayer();
DBLayer.updateUsersLastLoginDate(userId);
}

/*public ArrayList getUserPages(int userId)
{
dataAccessLayer DBLayer = new dataAccessLayer();
return DBLayer.getUserPages(userId);
}*/

}
}
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: ElmoWatson | last post by:
I tried on the Security newgroup, as well as other places, and haven't gotten an answer yet - - I'm pulling my hair out over this one. I'm trying to get Forms Authentication working.....I can get...
3
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be...
4
by: 23s | last post by:
I had this problem in the past, after a server reformat it went away, and now after another server reformat it's back again - no clue what's doing it. Here's the flow: Website root is public, no...
0
by: William F. Zachmann | last post by:
A web site that will run on Windows Server 2003 and IIS 6.0 needs to provide three levels of access, one for the public and two others for two levels of subscribers. This is a port of a prior site...
5
by: Cesar | last post by:
Hello, I have an application that is using forms authentication and it seems to be working fine most of the time. Unfortunatelly, it sometimes just redirects me to the login screen. It seems that...
1
by: Waqas Pitafi | last post by:
Hi, 3rd day is already gone without any solution. My problem is, I have a Windows Server 2003 sp1 machine as my development platform having NTFS filesystem. Other notable components installed...
8
by: Tomasz | last post by:
Hello Developers! I have an interesting problem using my custom MembershipProvider, RoleProvider and Forms Authentication. Both MembershipProvider and RoleProvider require session state, where...
4
by: =?Utf-8?B?R3V1czEyMw==?= | last post by:
Hi, I created a web site on a remote server. To logon the user must enter a user id and password. The site is uses Forms Authentication. The web config file looks as follows: ...
5
by: Rory Becker | last post by:
Having now created a Custom MembershipProvider that seems to work correctly with my Logon and ChangePassword controls, I am, as they say, a happy bunny. The next stange is to move on to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.