I have successfully completed the Try It Out 'Adding a Login Page to WroxUnited' example. Unfortunately, the coding provided for this example is not of the same high standard found in other chapters of the book. In fact, it is positively riddled with errors and concept problems. Anyway, whoever gets through it will have learnt quite a lot about ASP.Net by the time they finish.
For instance, on Page 674, navbar.ascx.
vb (and not navbar.ascx as stated), we are told to test right$(Request.ServerVariables("APPL_PHYSICAL_PATH "),11) = "WroxUnited\" to prove that we are in the main directory and not the admin subdirectory. However, this value never changes, regardless of whether we are viewing a page in the admin subdirectory or not. The result of this is that linking from one admin page to another does not work. We should be testing "PATH_INFO" instead:
If right$(Request.ServerVariables("PATH_INFO"),10)="a dmin.aspx" then .. will test that we
are in the admin subdirectory. This is the same test shown in the btn_Logout Sub.
Also, on the same page, there is a mismatch between the persistence of the UserLevel and AdminLevel cookies and user authentication (request.IsAuthenticated is true), which causes the page to fail.
If Not Request.Cookies("UserNameCookie") is Nothing
should be placed before any tests of the cookie values, and a cookie Expiry value is required when creating them.
In other pages, the Admin Level field (which is crucial to the example) is not included in the Players table for the WroxUnited database, the
Add new player link on the PlayerAdmin page does not work (it fails to initialise the Status properly); the
Delete a player link does not work because of the associated PlayerTeam table entry, and in the Header.ascx user control does not work for pages in the admin subdirectory (it needs rewriting using ASP.Net controls instead of HTML tags).
The coding shown in this chapter of book could never have worked, so has not been tested. That really isn't good enough. But never mind, if you are stuck on this one, enjoy the experience, you will lean a lot.