我正在向EWS发送请求,如下所示:
var service = new ExchangeService(exchangeVersion)
{
KeepAlive = true,
Url = new Uri("some autodiscovery url"),
Credentials = new NetworkCredential(username, password),
UserAgent = "myClient"
};
var subscription = service.SubscribeToPushNotifications(
new[] { inboxFolderFoldeID },
new Uri("some post back url"),
15,
null,
EventType.NewMail,
EventType.Created,
EventType.Deleted,
EventType.Modified,
EventType.Moved,
EventType.Copied);
但是,它会导致请求将User-Agent标头设置为myClient (ExchangeServicesClient/15.00.0913.015)
,其中字符串的其余部分来自使用此默认值的EWS库。有没有办法删除标题的默认部分,只是将其作为myClient
?
编辑:我可以看到EWS库似乎只是在请求中传递的值前缀:https://github.com/OfficeDev/ews-managed-api/blob/master/Core/ExchangeServiceBase.cs
答案 0 :(得分:0)
您需要从GitHub重新编译库,因为现有变量的范围不允许您以任何其他方式更改它们。例如,您需要做的就是修改UserAgent
public string UserAgent
{
get { return this.userAgent; }
set { this.userAgent = value + " (" + ExchangeService.defaultUserAgent + ")"; }
}
并删除前缀,然后在ExchangeService类上设置属性时,它只是您的自定义值。