سؤال

Please help me to fix my problem. My problem is the HTTPContext.Current is always equal to null. Thanks in advance.. Please see below code

HttpContext _context = null;
public EventReceiver()
{
    _context = HttpContext.Current;
}
هل كانت مفيدة؟

المحلول

Since you're receiving the event, the event has already occurred. By now, the context is gone.

نصائح أخرى

HttpContext.Current will not be available to your custom class EventReceiver unless you pass it from the class which has it like WebPage

You should not rely on context in event receivers. Instead you should get all objects from the properties of the event that are passed to the methods of the receivers as an argument.
see this question

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top