Answered by:
Can we use HttpContext in Plugin?

Question
-
Hi All,
Can we use HttpContext in asyncronous plugin??
If not any alternate to it?
Dare to promiseMonday, July 6, 2009 1:51 PM
Answers
-
Hi Deepak,
Synchronous plugin would run immediately so if there is lot of processing in plugin user could notice a slight delay, in case of asynchronous, plugin wouldn't fire immediately it would be taken by CrmAsyncService that would decide when it get's fired !!
Sdk suggests :
"Register plug-ins for asynchronous events when they have to perform lots of processing or for functions that are not time critical. Registering a plug-in that performs lots of processing for a synchronous event can adversely affect the performance of the Microsoft Dynamics CRM system"
Regards,
Nishant Rana
http://nishantrana.wordpress.com- Marked as answer by D-Virdi Tuesday, July 7, 2009 12:14 PM
Tuesday, July 7, 2009 10:59 AM -
Hi Deepak,
It will hit the performance, and in this case real bad, if you intend to audit *every changed field* on the CRM form.
The difference between Async and non Async plugin is, When you trigger an actionCreate/Update/Delete] CRM UI will wait if there are sync plugins registered. Async plugin, by design will not block the call so your control will immidiately return back to the main thread and CRM UI will not wait till your plugin execution is not complete and will immidiately move on. For auditing, you should go with Async Plugin only or all your calls will wait till the whole auditing process is complete.
Regards,
Chinmay
http://metrix.blogspot.com- Proposed as answer by Nishant RanaMVP Tuesday, July 7, 2009 11:20 AM
- Marked as answer by D-Virdi Tuesday, July 7, 2009 12:14 PM
- Edited by Chinmay Patel Wednesday, July 8, 2009 9:55 AM Correction made
Tuesday, July 7, 2009 11:00 AM
All replies
-
There are no HttpContext in all kinds of plugin.
Truth is opened the prepared mind My blog - http://a33ik.blogspot.comMonday, July 6, 2009 3:06 PMModerator -
I mean to using system.Web
can we use HttpContext.Current.SessionId ???
Dare to promiseTuesday, July 7, 2009 6:02 AM -
Hi,
I don't think we could use HttpContext in an asynchronous plugin, however you could use it in the synchronous plugin !!
Check out this post !
http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/0b3eb82a-b631-4d59-ba0e-bbd0732a6814
Regards,
Nishant Rana
http://nishantrana.wordpress.comTuesday, July 7, 2009 7:53 AM -
Thanks nishant,
I'hv to use httpcontext for getting Logged User Name and Session Id in my AuditLog plugin.
So making it syncronous will hit the performance?? as audit log plugin is recording every entity viewed, created. updated and deleted.
Whats the basic difference b/w asyncronous and syncronous plugin
Dare to promiseTuesday, July 7, 2009 10:38 AM -
Hi Deepak,
Synchronous plugin would run immediately so if there is lot of processing in plugin user could notice a slight delay, in case of asynchronous, plugin wouldn't fire immediately it would be taken by CrmAsyncService that would decide when it get's fired !!
Sdk suggests :
"Register plug-ins for asynchronous events when they have to perform lots of processing or for functions that are not time critical. Registering a plug-in that performs lots of processing for a synchronous event can adversely affect the performance of the Microsoft Dynamics CRM system"
Regards,
Nishant Rana
http://nishantrana.wordpress.com- Marked as answer by D-Virdi Tuesday, July 7, 2009 12:14 PM
Tuesday, July 7, 2009 10:59 AM -
Hi Deepak,
It will hit the performance, and in this case real bad, if you intend to audit *every changed field* on the CRM form.
The difference between Async and non Async plugin is, When you trigger an actionCreate/Update/Delete] CRM UI will wait if there are sync plugins registered. Async plugin, by design will not block the call so your control will immidiately return back to the main thread and CRM UI will not wait till your plugin execution is not complete and will immidiately move on. For auditing, you should go with Async Plugin only or all your calls will wait till the whole auditing process is complete.
Regards,
Chinmay
http://metrix.blogspot.com- Proposed as answer by Nishant RanaMVP Tuesday, July 7, 2009 11:20 AM
- Marked as answer by D-Virdi Tuesday, July 7, 2009 12:14 PM
- Edited by Chinmay Patel Wednesday, July 8, 2009 9:55 AM Correction made
Tuesday, July 7, 2009 11:00 AM