Knowledge base

.NET

How does it work?

To make use of Netbiscuits Server-Side .Net Device Detection, all you have to do is download the server-side client, configure it, and start using it.

A typical .Net Device Detection configuration code block will look something like this:

DcsConfiguration dcsConf = new DcsConfiguration ();
dcsConf.AccountName = "[account_name]";
dcsConf.Token = "[token]";
dcsConf.ParamProfile = "[profile]";
DcsService dcs = new DcsService(dcsConf);

With the .Net client configured, the following events happen when a user’s browser requests a page from your website:

  • Your server requests the Device Detection profile from a Netbiscuits Device Detection server
  • The Device Detection server runs a series of tests to identify the user’s device
  • A collection of parameters and values is created and returned to your server in JSON format
  • Device Detection can also (optionally) gather dynamic data within the user’s browser, like current Bandwidth and Geolocation – Learn more about using using Dynamic Parameters
  • Once complete, the Device Detection object can be used to customize the user’s experience for the exact device they are using

How can I use .Net Device Detection?

  1. First of all, make sure you’ve created a Netbiscuits account and have logged in.
  2. If you’re all set there, then you need to download your desired .Net client (xml or dll).
  3. Next, copy your .Net configuration code.
  4. Once copied, paste that code block to instantiate a new Netbiscuits.Dcs.Configuration.DcsConfiguration, something like:
    DcsConfiguration dcsConf = new DcsConfiguration ();
    dcsConf.AccountName = "[accountName]";
    dcsConf.Token = "[token]";
    dcsConf.ParamProfile = "default";
    DcsService dcs = new DcsService(dcsConf);
    
  5. Then create a detect() method; this will be filled with the Device Detection information, something like:
    DeviceInformation info = dcs.GetDeviceParameter(Request);
    
  6. Finally, you are ready to make use of the Device Detection information in your code, something like:
    protected void Page_Load( object sender, EventArgs e)
    {
        try {
            DeviceInformation info = dcs.GetDeviceParameter(Request);
            DeviceInformation device = info.GetGroup("device");
            DeviceInformation browser = info.GetGroup("browser");
            String vendor = device.GetStringValue("vendor");
            String model = device.GetStringValue("modelname");
        } catch (Exception e) {
            log.Error(e.Message);
        }
    }
    
  7. Similar code can now be used anywhere in your website’s code, something like:
    protected void Page_Load( object sender, EventArgs e)
    {
        try {
            DeviceInformation info = dcs.GetDeviceParameter(Request);
            DeviceInformation device = info.GetGroup("device");
            DeviceInformation browser = info.GetGroup("browser");
            String vendor = device.GetStringValue("vendor");
            String model = device.GetStringValue("modelname");
            // fill data into table
            TableRow tr = new TableRow();
            TableCell cell1 = new TableCell();
                cell1.Text = device.GetStringValue("vendor");
            tr.Cells.Add(cell1);
            TableCell cell2 = new TableCell();
                cell2.Text = device.GetStringValue("modelname");
            tr.Cells.Add(cell2);
            TableCell cell3 = new TableCell();
                cell3.Text = device.GetStringValue("operatingsystemvendor");
            tr.Cells.Add(cell3);
            TableCell cell4 = new TableCell();
                cell4.Text = device.GetStringValue("operatingsystemmodel");
            tr.Cells.Add(cell4);
            this.dcstable.Rows.Add(tr);
        } catch (Exception e) {
            log.Error(e.Message);
        }
    }
    

Demos

To help you further with getting started, we have created a series of demos that you can download and run on your own server (including your localhost).

We hope this has helped you get up and running with the Netbiscuits .Net Device Detection. If you have any questions or need help with your setup, please contact us.

Or if you’re ready for the next step, find out about all the Device Detection Parameters you can build into your website!

Learn more about Device Detection Parameters

YouTube aktivieren?

Auf dieser Seite gibt es mind. ein YouTube Video. Cookies für diese Website wurden abgelehnt. Dadurch können keine YouTube Videos mehr angezeigt werden, weil YouTube ohne Cookies und Tracking Mechanismen nicht funktioniert. Willst du YouTube dennoch freischalten?