0

I am getting the title error when I do the code in .netcore2.2.

Following is my code,

var browser = Request.Browser;
System.Web.HttpBrowserCapabilitiesBase myBrowserCaps = browser;

HttpBrowserCapabilitiesBase in this keyword it showing me the title error.

While this code is working perfectly below the .netcore2.2. HttpBrowserCapabilitiesBase is the interface of System.web DLL below the .netcore2.2.

It means the updated .net framework this namespace is not exist now which namespace is work, that I am not getting.

s.k.Soni
  • 1,139
  • 1
  • 19
  • 37

1 Answers1

0

Depending on which information you need, you could look that up in the headers (e.g. Request.Headers["User-Agent"] as shown here) instead, or get it using a library like Device Detection.

Edit: Here is a tutorial for getting the device type information using the ASP.NET Core Detection library:

  • Install the Wangkanai.Detection NuGet package.
  • Add to the ConfigureServices method in your Startup.cs:

    services.AddDetection();
    
  • In the controller inject: IDeviceResolver deviceResolver

  • ... and get the device information via: deviceResolver.Device.Type, e.g.:

    var isMobile = deviceResolver.Device.Type == DeviceType.Mobile;
    var isDesktop = deviceResolver.Device.Type == DeviceType.Desktop;
    ...
    

See the documentation for further information.

user7217806
  • 2,014
  • 2
  • 10
  • 12
  • I dont want the browser name, I want the condition that my webapplication is working in computer browser or in mobile browser? – s.k.Soni Apr 10 '20 at 06:52
  • I added an example using the `ASP.NET Core Detection` library for getting the device type. – user7217806 Apr 12 '20 at 20:25