باستخدام httpcontext.current.currentHandler للوصول إلى وقت التشغيل

StackOverflow https://stackoverflow.com/questions/2312588

  •  22-09-2019
  •  | 
  •  

سؤال

هل هناك أي مأزق محتمل لاستخدام httpcontext.current.currentHandler للوصول إلى وقت التشغيل؟

public static GetView<T>(T view) where T : IView
{
    return  HttpContext.Current.CurrentHandler as T;
}
هل كانت مفيدة؟

المحلول

لا أعتقد ذلك ، طالما أنك تدرك أنه يمكن أن يكون null.

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