This entry is a note for myself but I decided to share, might be useful for someone. In my current project I had a requirement of detecting in synchronous plugin if request is from API (SDK call) or from UI , similar behaviour to CallerOrigin from v4. We know that synchronous plugin are executed by IIS so they have access to HttpContext going further we can find our what is Request.Path and that’s where answer is , have a look at “pseudo code” bellow
HttpContext webContext = HttpContext.Current;
switch (webContext.Request.Path)
{
// -- API service call
case : /OrgName/XRMServices/2011/Organization.svc
// -- UI call
case: OrgName/userdefined/edit.aspx
}
We didn’t wan’t to use any funny attribute wich would be populated by JS etc so this is simple solution and it was good enough to differentiate API call from UI call. I haven’t test how asynchronous plugin will behave, so definitely there is room for more R&D and more blog enties.