I've written an asp.net page as below:
Basically there is an error thrown at:Code:<%@ Page Language="C#" %> <script runat="server"> public class SitePermissions { private bool viewFiles = false; private bool addFiles = false; private bool editFiles = false; private bool deleteFiles = false; private bool addClients = false; private bool editClients = false; private bool deleteClients = false; private bool accessAllowed = false; private bool RoleAccessAllowed( string[] enteredFilePaths, string checkPermissionType ) { this.accessAllowed = false; foreach (string enteredFilePath in enteredFilePaths) { if ( User.IsInRole( checkPermissionType + ":" + enteredFilePath ) ) { this.accessAllowed = true; } } return this.accessAllowed; } public SitePermissions( string[] roles ) { this.RoleAccessAllowed( roles, "view_files" ); this.RoleAccessAllowed( roles, "add_files" ); this.RoleAccessAllowed( roles, "edit_files" ); this.RoleAccessAllowed( roles, "delete_files" ); this.RoleAccessAllowed( roles, "add_clients" ); this.RoleAccessAllowed( roles, "edit_clients" ); this.RoleAccessAllowed( roles, "delete_clients" ); } public bool ViewFiles { get { return this.viewFiles; } } public bool AddFiles { get { return this.addFiles; } } public bool EditFiles { get { return this.editFiles; } } public bool DeleteFiles { get { return this.deleteFiles; } } public bool AddClients { get { return this.addClients; } } public bool EditClients { get { return this.editClients; } } public bool DeleteClients { get { return this.deleteClients; } } ~SitePermissions() {} } string strClientPath, strCssPath; ArrayList roleList = new ArrayList(); string[] roleListArray, splitPath; SitePermissions UsersRoles; public void Page_Load( Object sender, EventArgs e ) { strClientPath = Request.Params[ "path" ]; if (Request.Browser.Type.ToLower().IndexOf("ie") != -1) { strCssPath = "general_ie.css"; } else { strCssPath = "general_moz.css"; } splitPath = strClientPath.Split(new char[] {'/'}); string tempPath = ""; foreach (string subpath in splitPath) { if (subpath != "") { tempPath += "/" + subpath; roleList.Add( tempPath ); } } roleListArray = (string[]) roleList.ToArray( typeof( string ) ); UsersRoles = new SitePermissions( roleListArray ); Progress.Text = UsersRoles.ViewFiles.ToString(); } </script> <!-- <%= strClientPath %>.aspx remapped to <%= Request.Path %>?path=<%= strClientPath %> --> <html> <head> <title>HRO'C Client Extranet</title> <link href="/css/<%= strCssPath %>" type="text/css" rel="stylesheet" /> </head> <body> <form runat="server"> <div id="extranetTitle" class="extranetTitle"> Client<br /> Extranet </div> <br /> <%= strClientPath %> <asp:Textbox id="Progress" runat="Server" Textmode="Multiline" Style="position: absolute; top: 250px; left: 400px; width:250px; height: 100px;">Start</asp:Textbox> </form> </body> </html>
Line 20: if ( User.IsInRole( checkPermissionType + enteredFilePath ) ) {
The error is CS0118: 'System.Web.UI.Page.User' denotes a 'property' where a 'class' was expected
I presuming I cannot access User.IsInRole from within my new class.
This is my first stab at asp.net using OOP so point out where I'm going wrong and where I could improve.
Cheers
DJ




Reply With Quote