Programming with aspNetDns

     There are two main namespaces in aspNetDns that you will be working with. aspNetDns and aspNetDns.Records. They will be discussed below.

 

Namespace aspNetDns

The aspNetDns namespace contains the DnsQuery object and the DnsQueryTypes. The DnsQuery object is an object that will allow you generically query any DNS record or class. The DnsQuery object requires a type from DnsQueryTypes and will return the Resource Record object, the base class for all DNS Records. 

Namespace aspNetDns.Records

The aspNetDns.Records namespace contains all of the Resource Records classes. Some of these classes include Address (A) Records, CanonicalName (CName) Records, Start of Authority (SOA) Records, Mail Exchange (MX) Records, and many more. These classes also contain the static, or shared, methods that allow you to query DNS servers with one line of code.

 

Asynchronous Programming

aspNetDns also support asynchronous programming through the use of callbacks. All record classes can be called asynchronously to retrieve records. aspNetDns transparently passes all operation to a background thread, and immediately continues executing your code, on the primary thread. Once the background thread has finished querying records, aspNetDns will execute the callback functions specified when the asynchronous operation first started.  A listing of sample asynchronous calls can be found below.

 

Programming Examples

The following examples demonstrate using the aspNetDns namespace, along with the aspNetDns.Records namespace.

 

Using the aspNetDns Namespace

Querying Address Records
A simple query for Address records

Querying MX Records
A simple query for MX Records

Querying Canonical (CName) Name Records
A simple query for CName or alias records.

Performing a Reverse Lookup using Pointer Records
Performing a Reverse lookup on an IP Address

Querying Start of Authority Records
Querying for Start of Authority Records for a given domain.

Using Failover DNS Servers
Use multiple DNS servers for failover functionality.

 

Using the aspNetDns.Records Namespace

Querying Address Records
A simple query for Address records.

Querying MX Records
A simple query for MX records.

Performing a Reverse Lookup using Pointer Records
Perform a reverse lookup on an IP Address.

Querying Start of Authority Records
Query a domain for Start of Authority records.

 

Asynchronous Programming Samples

Asynchronously query Address Records
A simple asynchronous query for Address records.

Asynchronously query MX Records
A simple asynchronous query for Mail (MX) Exchange records.

Asynchronously perform a Reverse Lookup
A simple asynchronous reverse lookup of an IP Address using pointer records.