M
Mike Taylor
I'm trying to create a base page class for my project (am new to
ASP.NET, so am a bit stumped) - I'm using VS.NET 2003, btw.
OK, my dummy base page class is shown below:
using System;
using System.Web;
using System.Web.UI;
using System.Web.Security;
using System.Security.Principal;
namespace NewBarn.WebModules
{
public class ltAdminPage2 : System.Web.UI.Page
{
private IPrincipal p = HttpContext.Current.User;
public ltAdminPage2()
{
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
}
}
In this project, I'm also implementing custom security, and in this
base page class, I want to determine the current user's roles etc. by
accessing the HttpContext.Current.User.
However, this line seems to be tripping things up for some reason:
private IPrincipal p = HttpContext.Current.User;
If I try and create a .aspx page and change the code-behind to inherit
from ltAdminPage2 rather than System.Web.UI.Page, VS.NET won't let me
open that page in design view.
When I try to open the .aspx in VS.NET, I get an error: "The file
could not be loaded into the Web Forms designer. Please correct the
following error and then try loading it again: An exception occurred
while trying to create an instance of NewBarn.WebModules.ltAdminPage2.
The exception was 'Object reference not set to an instance of an
object.'. Make sure all of the classes used in the page are built or
referenced in the project."
If I comment out the IPrincipal line, it opens the file just fine (but
obviously I can't access the current user's Principal).
What have I done wrong? Am I not referencing the IPrincipal properly?
Confused.
Mike Taylor
ASP.NET, so am a bit stumped) - I'm using VS.NET 2003, btw.
OK, my dummy base page class is shown below:
using System;
using System.Web;
using System.Web.UI;
using System.Web.Security;
using System.Security.Principal;
namespace NewBarn.WebModules
{
public class ltAdminPage2 : System.Web.UI.Page
{
private IPrincipal p = HttpContext.Current.User;
public ltAdminPage2()
{
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
}
}
In this project, I'm also implementing custom security, and in this
base page class, I want to determine the current user's roles etc. by
accessing the HttpContext.Current.User.
However, this line seems to be tripping things up for some reason:
private IPrincipal p = HttpContext.Current.User;
If I try and create a .aspx page and change the code-behind to inherit
from ltAdminPage2 rather than System.Web.UI.Page, VS.NET won't let me
open that page in design view.
When I try to open the .aspx in VS.NET, I get an error: "The file
could not be loaded into the Web Forms designer. Please correct the
following error and then try loading it again: An exception occurred
while trying to create an instance of NewBarn.WebModules.ltAdminPage2.
The exception was 'Object reference not set to an instance of an
object.'. Make sure all of the classes used in the page are built or
referenced in the project."
If I comment out the IPrincipal line, it opens the file just fine (but
obviously I can't access the current user's Principal).
What have I done wrong? Am I not referencing the IPrincipal properly?
Confused.
Mike Taylor