In trying to implement authentication in CKFinder , following this "howto" , I wrote the following file stored in my CKFinder directory:
<%@page codepage="65001" language="C#" lcid="6153"%> <% using CKSource.CKFinder.Connector.Core; using CKSource.CKFinder.Connector.Core.Authentication; public class MyAuthenticator:IAuthenticator{ public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){ return Task.FromResult((IUser)new User(true,"editor")); } } %>
However, when I try to load it, I get a compiler error ( CS1513 ) in the line containing the second using statement, stating that a closing bracket ( } ) is expected, despite the fact that there is no opening bracket in front of the file ( { ) .
Given that I do not have ASP.NET knowledge, can someone shed light on what is happening here, and how would I decide to solve it?
I, despite the fact that I know that this will not work, tried to add } at the end of this line to find out what will happen, and this will cause another compiler error - " CS1518 : Expected class, delegate, enumeration, interface or structure "- in a completely different file" App_Web_auth.aspx. *. *. 0.cs "(asterisks are random strings of characters at each reboot), which, oddly enough, contains several directories in my %WINDIR% . This error occurs on line 214, which is the second line in the following extract:
[System.Diagnostics.DebuggerNonUserCodeAttribute()] protected override void FrameworkInitialize() { base.FrameworkInitialize(); this.@ __BuildControlTree(this); this.AddWrappedFileDependencies(global:: ASP.auth_aspx.@ __fileDependencies); this.Request.ValidateInput(); }
UPDATE 1
If I completely delete the public class, I get another compiler error - " CS1003: Syntax error" ("expected") - this time in the line containing the first using statement. Litigation and error led me to the fact that using instructions should be enclosed in pairs, but after adding a public class I still get the original error about the missing one } .
<%@page codepage="65001" language="C#" lcid="6153"%> <% using(CKSource.CKFinder.Connector.Core); using(CKSource.CKFinder.Connector.Core.Authentication); public class MyAuthenticator:IAuthenticator{ public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){ return Task.FromResult((IUser)new User(true,"editor")); } } %>
Removing the class again leads to another new error - " CS0119 :" CKSource.CKFinder.Connector.Core "is a" namespace "that is not valid in this context"
UPDATE 2
Per SeM , I added the following to the system.web CKF section "Web.config":
<pages> <namespaces> <add namespace="CKSource.CKFinder.Connector.Core" /> <add namespace="CKSource.CKFinder.Connector.Core.Authentication" /> </namespaces> </pages>
And updated the contents of my file:
<%@page codepage="65001" language="C#" lcid="6153"%> <%@import namespace="ConnectorBuilder.SetAuthenticator"%> <% public class MyAuthenticator:IAuthenticator{ public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){ return Task.FromResult((IUser)new User(true,"editor")); } } %>
This, however, leads to the original error (" CS1513 :} expected"), which is now thrown to line 214 (first line in the following example) of this mystery file in my %WINDIR% - with added strangeness, the contents of this file somehow changed .
private void @__Render__control1(System.Web.UI.HtmlTextWriter @__w, System.Web.UI.Control parameterContainer) { #line 3 "x:\redacted\path\to\myfile.aspx" public class MyAuthenticator:IAuthenticator{ public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){ return Task.FromResult((IUser)new User(true,"editor")); } } #line default #line hidden }
UPDATE 3
Modifying my file to use script tag:
<%@page codepage="65001" language="c#" lcid="6153"%> <%@import namespace="ConnectorBuilder.SetAuthenticator"%> <script language="c#" runat="server"> public class MyAuthenticator:IAuthenticator{ public Task<IUser> AuthenticateAsync(ICommandRequest commandRequest,CancellationToken cancellationToken){ return Task.FromResult((IUser)new User(true,"editor")); } } </script>
This leads to a completely new error on line 2: " CS0246 : the name of the type or namespace" ConnectorBuilder "cannot be found (do you miss the using directive or assembly references?)"
UPDATE 4
I removed the import directive and received the following error in a line declaring a public task: " CS0246 : The type or name of the namespace" CancellationToken "could not be found (do you miss the use directive or link build?)".