-1

I'm currently working with an ASP.NET Web Application (Basic VS2017 MVC template) and due to requirements with switching between two applications I need to completely disable DNS caching browser side, as well as close any open connections. Currently, even after the DNS record is changed, Chrome and IE still route to the should-be-dead page.

Posts I've tried:

For that last one, I'm not sure I have it working as intended. After applying each of the above my headers are:

Response Headers:

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Content-Length: 1079
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Expires: 0
Vary: Accept-Encoding
Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 02 Aug 2017 21:36:50 GMT

Request Headers:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:ARRAffinity=789fe7bbe28c722b0920137dba18498fceae0426a05f2d26c581fb12b875c8d9
Host:[redacted]
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36

keep-alive seems to still be enabled for the request, but I don't know if that has any impact.

I also have two Web.config files due to the default setup in VS. I've been putting my changes in both to see what sticks. Below are the edited portions:

views/Web.config:

<system.webServer>
  <staticContent>
    <clientCache cacheControlMode="DisableCache" />
  </staticContent>
  <httpProtocol allowKeepAlive="false" />
  <handlers>
    <remove name="BlockViewHandler"/>
    <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
  </handlers>
</system.webServer>

appName/Web.config

<system.webServer>
  <staticContent>
    <clientCache cacheControlMode="DisableCache" />
  </staticContent>
  <httpProtocol allowKeepAlive="false" />
  <validation validateIntegratedModeConfiguration="false" />
  <modules>
    <remove name="ApplicationInsightsWebTracking" />
    <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
  </modules>
</system.webServer>

My best guess is that my browser isn't rechecking the DNS record, as checking it with nplookup gives the redirected location even while the old page is still up. Looking at the network traffic with Wireshark shows that to connection is kept open, so that would be a likely reason why. Any advice on how I can force a browser to recheck the DNS record would be greatly appreciated. Thank you in advance.

dornadigital
  • 167
  • 13
  • are you sure that you understand what DNS is, why there is no dns cache in browser and why you cannot control it via web-site response? – Iłya Bursov Aug 02 '17 at 22:08
  • https://superuser.com/questions/203674/how-to-clear-flush-the-dns-cache-in-google-chrome I'm open to other ideas, but that's my best guess as to why I'm continually redirected to the wrong site. – dornadigital Aug 02 '17 at 22:12
  • ok, google re-invented wheel and created another dns cache, but you still cannot control it via web-site response, as dns works _before_ your site is actually requested – Iłya Bursov Aug 02 '17 at 22:15
  • @IlyaBursov: https://support.opendns.com/hc/en-us/articles/227988627-How-to-Clear-the-DNS-Cache-on-Computers-and-Web-Browsers https://superuser.com/questions/367197/internet-explorer-dns-cache-location This appears to simply be a modern browser feature. Again, I'm open to other explanations of the problem, but please do some research before responding. – dornadigital Aug 02 '17 at 22:22
  • @IlyaBursov: The SuperUser post I linked to has reference to an official Microsoft page detailing how IE does indeed handle DNS caching. https://support.microsoft.com/en-us/help/263558/how-internet-explorer-uses-the-cache-for-dns-host-entries – dornadigital Aug 02 '17 at 22:28
  • you're not getting the point, DNS works at different level, even if browser decided to cache it (which is not very good idea actually, especially for such long time) - you cannot control it via web-response – Iłya Bursov Aug 02 '17 at 22:37
  • https://dyn.com/blog/web-browser-dns-caching-bad-thing/ – Iłya Bursov Aug 02 '17 at 22:38
  • @IlyaBursov: I'm not arguing that it isn't a bad idea. I believe that it may be breaking my Dns routing. That's why I'm trying to get around it. But as my references show, It's an incredibly common feature. If you have a solution or alternative suggestion for what is going wrong I'd be happy to hear it. – dornadigital Aug 02 '17 at 22:53
  • what do you mean under "dns routing"? – Iłya Bursov Aug 02 '17 at 22:58
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/150884/discussion-between-dornadigital-and-ilya-bursov). – dornadigital Aug 02 '17 at 23:19
  • I find it odd that people have down-voted this without any comment. If you dislike my question please comment, as I am unable to fix it otherwise. – dornadigital Aug 08 '17 at 21:29

1 Answers1

0

Turns out that the problem was indeed that "keep-alive" header. More specifically, that the open connection that resulted bypassed any Dns lookup. Accessing the IIS Manager and changing the HTTP Response Headers to disable keep-alive forces the browser to recheck the Dns record every time.

dornadigital
  • 167
  • 13