我在ServiceStack上有一些服务,并在这个项目中使用SignalR.
现在,我想保护集线器连接(仅对经过身份验证的用户进行访问),但我使用ServiceStack框架身份验证..(不是asp.net身份验证)和ServiceStack的会话(写入AuthUserId ih此会话和身份验证标志).
因此,当用户尝试连接到集线器时 - 集线器必须检查身份验证...
(是的,我可以从Hub请求Cookie(例如,方法OnConnected),但是在Authorize Attribute中检查身份验证 - 我必须在此类中进行(不在集线器中)
(http://www.asp.net/signalr/overview/signalr-20/security/hub-authorization)
所以,我创建了课程
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
public class AuthorizeMyAttribute : AuthorizeAttribute
{
protected override bool UserAuthorized(System.Security.Principal.IPrincipal user)
{
//... how can i request Cookies? / or may be can access for ServiceStack session...
// and return true or false
}
}
Run Code Online (Sandbox Code Playgroud)
我能做些什么?谢谢!
主题:我创建控制台应用程序(文档解析器)并使用 NLog 记录处理事件。构建后,我使用 ILMerge 工具将所有 DLL 合并到一个可执行文件(它需要使用结果工具更舒适)
如果我使用外部 NLog.config xml 文件进行记录器配置 - 它运行良好(在将所有 dll-s 和 exe 合并到单个文件之前和之后)
所以,问题:但是如果我尝试在 docsloader.exe.config 文件中使用“nlog”部分 - 它只能在没有 IL 合并的情况下工作(如果所有 dll 和 exe 文件都处于单独模式)。如果我首先将结果合并到单个文件并运行 docsloader.exe,我会看到:
Unhandled Exception: System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for nlog: Could not load file or
assembly 'NLog' or one of its dependencies. The system cannot find the file specified. (C:\d\projects\_\out\docsloader.exe.Config line 5)
---> System.IO.FileNotFoundException: Could not load file or assembly 'NLog' or one of its dependencies. The system …Run Code Online (Sandbox Code Playgroud) .net ×1
app-config ×1
asp.net ×1
authorize ×1
c# ×1
ilmerge ×1
nlog ×1
servicestack ×1
signalr ×1