views:

654

answers:

2

I am using internet IE 7, IE 8

My application in running in dns fail over environment with primary and back up server. As the primary server is down, failover changes to the secondary server after 2 - 3 minutes.

But the problem is, the current opened page in IE is still sending requests to the primary server due to dns caching, which stores the IP of the primary server for default 30 minutes) and hanged.

This problem can be solved if we can clear or edit the dns cache with C# ASP.Net coding.

Thanks in advance for replying.

A: 

There is an undocumented api called DnsFlushResolverCache in dnsapi.dll, see this link for an example for how to use it from C# (not ASP.NET) .

cartman
+1  A: 

You cannot access a client machine's DNS Cache from your ASP.NET server or anything in the browser. It would be a huge security hole to either of those environments to do so.

The better approach if you're looking for DNS failover is to talk to your network administrator. Ask him/her to set the TTL for your DNS records to a number smaller than your failover time. This will increase the frequency with which the client machines refresh their caches (for your site only) and shorten their downtime in the event of a failover.

The negligible drawback is that it can increase (ever so slightly) their wait time for the site because they have to do DNS requests more often.

Jason Punyon
If that wait time becomes an issue, talk to your network admin again to fix the problems with their network hardware :)
Aaron Digulla
@Aaron Digulla: Thanks, updated to state that the drawback is really negligible.
Jason Punyon