BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
In Chapter 5,Roles¡¢EditRole¡¢RoleAssignments in admin is error.It is about
(SitePrincipal)Context.User.Moreover£¬what mean about"Put user code to initialize the page
here"in the progam(EditRole.aspx.cs)?
I tried to complete thePhile\Modules\admin\roles.aspx ,but received the following message
from Anthecinus C# Editor:
//--------------------------------------------
1¡¢admin/roles.aspx error£º
Stack Trace:
System.InvalidCastException: Can't convert type. at
thePhile.Modules.Accounts.Web.Roles.Page_Load(Obje ct sender, EventArgs e) in
C:\Inetpub\wwwroot\thePhile\Modules\Users\Admin\Ro les.aspx.cs:line 41 at
System.EventHandler.Invoke(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs
e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain()
//--------------------------------------------
2¡¢admin/Editrole.aspx error£º
Stack Trace:
System.InvalidCastException: Can't convert type. at
thePhile.WebModules.Web.EditRole.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\thePhile\Modules\Users\Admin\Ed itRole.aspx.cs:line 59 at
System.EventHandler.Invoke(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs
e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain()
//--------------------------------------------
3¡¢admin/RoleAssignments.aspx error£º
Stack Trace:
System.IndexOutOfRangeException: Nothing in row 0.at System.Data.DataRowCollection.get_Item(Int32
index) at thePhile.WebModules.Accounts.Data.Role.Retrieve(In t32 roleId) in
C:\Inetpub\wwwroot\thePhile\AccountsData\Role.cs:l ine 64 at
thePhile.WebModules.Accounts.Business.Role..ctor(I nt32 currentRoleId) in
C:\Inetpub\wwwroot\thePhile\AccountsBusiness\Role. cs:line 27 at
thePhile.Modules.Accounts.Web.RoleAssignments.Page _Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\thePhile\Modules\Users\Admin\Ro leAssignments.aspx.cs:line 43 at
System.EventHandler.Invoke(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs
e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain()
It's likely to the class SitePrincipal and class SiteIdentity can not work.
What are some possible solutions that I need to check?
Hello, excuse for my English. I see that nobody has not answered you. Also I have the same problem I have resolved the problem? I continue to try. If I resolve I make you to know. Soon...
Could you post the code? I don't have the book. It's likely that you are storing a custom SitePrincipal object in the context's User property. However, after the page reloads, it drops that reference. Use another mechanism, such as the Session, to store that reference.
This sounds like the problem that we answer about once every 2 weeks. The order of these 2 lines has to be switched:
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
base.OnInit(e); // THIS LINE MUST COME FIRST !!!!
InitializeComponent();
}