【发布时间】:2017-07-01 05:18:31
【问题描述】:
使用 NLog 网络服务目标
https://github.com/nlog/NLog/wiki/WebService-target
当目标 api 使用 Windows 身份验证时,我收到 401。
Error 发送到 Webservice 时出错:ws 异常:System.Net.WebException:远程服务器返回错误:(401) Unauthorized。
如果我允许匿名,一切正常
我试图在调用日志记录步骤时使用模拟。但是,上面的异常是在NLog内部日志文件中产生的(我打开了)。
if (user.ImpersonateValidUser())
{
try
{
Logger logger = LogManager.GetCurrentClassLogger();
LogEntry l = new LogEntry()
{
AppName = "MyTestController",
LoggedOnDate = DateTime.Now,
LogMessage = "this is a test",
LogType = 1,
ServerName = "dev-test3"
};
logger.Error(l);
}
}
如何调用使用 Windows 身份验证的 Web 服务目标?
【问题讨论】:
标签: asp.net-web-api2 nlog windows-server-2012