Having a common class!

Hi,

I'm facing a small problem and it would be great if someone could help me out. I'm creating a class for my project. The project is of two parts. One part is done using ASP.NET and the other part is a windows application developed using C#. The class is common to both the asp part and the windows app part. Now I need to know if the client's browser supports activeX. I know this can be done using "Request.Browser.ActiveXControls" in asp.net. But I need to add this functionality to the class. So in the class I gave it using the System.Web, and added the following code

HttpApplication obj = new HttpApplication();
obj.Request.Browser.ActiveXControls;


But I get the error saying "Request is not available in this context" when I use this class in the asp.net part. I also tried to simply specify Request.Browser.ActiveXControls in the class, but when I use this class in the windows app it just wouldn't compile even after giving a reference to System.Web. How can I add this fuctionality to my class so that when I use this class in the asp.net part it should fuction, and if I use it in the windows app part it should not function.

Thanks & Regards,

Frenzy



Answer this question

Having a common class!

  • khani

    Hi,

    Can someone provide a solution to this or any other alternative.

    Thanks & Regards,

    Frenz


  • Ermac

    Thanx a lot! It works great!!
  • Blu_Fire739

    Try this. It seems to work for me.

    using System;

    using System.Web;

    ....

    public bool SupportsActiveXControls()

    {

    if (HttpContext.Current != null)

    return (HttpContext.Current.Request.Browser.ActiveXControls);

    else

    return true;

    }


  • Having a common class!