Setting headers to override IE intranet compatibility mode in ASP.NET - asp.net

I have an intranet site that loads in IE7 compatibility mode, unless the user has unchecked "Display intranet sites in Compatibility View" on their version of IE8. Unfortunately, the client wants this checked for other sites that they use, so I need to override this setting. I've tried the meta tag,
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
but it does not override the browser setting. However, this question indicates that a server heading will indeed override. This is the example code given in the top answer:
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
I've opened up web.config and put it in <system.webServer> but it doesn't work. I'm watching the headers with fiddler but it isn't adding the header at all. (Also, it still is forced to compatibility mode and Javascript confirms documentMode is 7.) I'm working locally with the ASP.NET Development Server

The <system.webServer> tag is specifically for IIS (7, I believe). It won't affect the Cassini server that Visual Studio uses in-house. If you only need to worry about this issue in a live dev environment, try testing on an instance of IIS. Otherwise, you may want to try IIS Express in development.

Related

external page and iframe issue

I have 2 websites hosted on windows server 2012. One website is using asp.net while other is wordpress. I want to embed asp.net page in wordpress. But, it is not showing anything. I did some research and came to know that perhaps, I have to allow permission for external website. Please guide me how to do it, should I add anything in web.config? I added below in asp.net but it did not help
<head>
<meta http-equiv="X-Frame-Options" content="allow">
</head>
Please guide, how to allow external website in iframe?
The iframe looks like below:
[iframe mydomain.com/signIn.aspx 640px 400px]
Thanks
You can do it in your web.config (if hosted on IIS 7.0 or later):
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-Frame-Options" /> <!-- optional -->
<add name="X-Frame-Options" value="ALLOW" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
This must be added in the application being "framed" (in your case an asp.net app), not in the parent app (wordpress).
Reference: https://www.iis.net/configreference/system.webserver/httpprotocol

Asp.net website compatibility with IE 11

I have an old asp.net intranet website.. I have been using IE 8 till now without any issue. Now I am trying to check if it works well with IE 11. I see that there is no problem with the site when requesting the page from IE 11 from my desktop.
But when I try to debug the same website locally in VS the controls are out of place and even fails to detect the IE Browser by
if(window.ActiveObject) which seems to be correct behaviour for IE 11.
Now I am wondering how the intranet website looks perfectly fine in IE 11. The server is Windows server 2008 IIS 7.
Any suggestion.
The window.ActiveXObject property is hidden from the DOM starting from IE11 so, you can no longer use it.
http://msdn.microsoft.com/en-us/library/ie/dn423948%28v=vs.85%29.aspx
In VS, it happens often to see the markup misaligned whenever in designer mode. But I think you should care less about that and focus more on the code markup instead
In the web config file you can use the customHeaders tag:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<httpRedirect enabled="false" />
<httpProtocol>
<customHeaders>
<remove name="X-UA-Compatible" />
<add name="X-UA-Compatible" value="IE=EmulateIE7" />
</customHeaders>
</httpProtocol>

Internet Explorer compatibility mode

I have a ASP.NET web application which is supposed to work on IE.
If I go to compatibility View Settings and uncheck Display intranet sites in Compatibility View and the domain is not added in the box Websites you've added in Compatibility View, the users sees the code not the forms of the page.
If I check the checkbox, he still sees the code, only after I add it in the box I can see the actual forms of the page.
I tried
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=IE5" />
</customHeaders>
</httpProtocol>
</system.webServer>
but still the same problem.
Is there another way to force it from code? I understand in the future the checkbox will be disabled so I must find I way to force the compatibility mode.
Can I add it to the box for Compatiblity View from code?

Force Browser and Document Mode to ie9 in ie10

This code:
<meta http-equiv="X-UA-Compatible" content="IE=9" />
seems to only change document to ie9 and not browser. Any ideas other than hitting F12 and changing it manually?
A site can not set the Browser mode. The browser mode is chosen before the browser requests content from the site. This specifies how the browser is identified to the site, such as the UA string.
As you mentioned, the Document mode can be set by the author by including a X-UA-Compatible meta element, or by the DOCTYPE used. This overrides the default set by the browser for that browser mode.
Changing the Browser Mode is only useful for using IE to test how an earlier version of IE would handle the site. You can change it on your local machine (but not for the site as a whole) by changing it in the F12 tool.
The user (and thus developer) can change the Browser mode by clicking on the Compatibility View icon in the URL field. This will also be only for that machine, and not for all users.
The only way to change the Browser mode globally is to get the site added to MS’ Compat View List. But you don’t want that unless the site uses a ton of old MS vendor specific code, and will not be updated.
You can read more at http://blogs.msdn.com/b/ie/archive/2010/10/19/testing-sites-with-browser-mode-vs-doc-mode.aspx
Optionally, you can alter the Web.config file to accomplish this as well. (You'll have to restart the service after publishing to see the changes.)
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=Edge" />
</customHeaders>
</httpProtocol>
</system.webServer>
You can use the FEATURE_BROWSER_EMULATION feature of Internet explorer.
Start regedit.exe, go to
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
or
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
create a DWORD iexplore.exe and set the value to 9999 (0x270F).
see this.
you can force highest mode by adding:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Firefox 4.0 always refreshes the Silverlight XAP File

I've trouble with the new FireFox 4.0 Release.
In my Website i hosted a Silverlight Object, named Visualisation.
In Firefox 3.6, Chrome, IE 7, 8, 9 the Browsers load the XAP File Once and get it from cache if not then do a postback or re-enter the site.
In FF 4 it reloads XAP File everytime i enter the site.
I tried a lot and searched the web but have no idea to fix the problem.
My Silverlight Object has the:
<param name="enableCacheVisualization" value="true"/>
The Site which hosted the Object has the Page Head
<%# OutputCache Duration="600000" VaryByParam="none" %>
and i have an own web.config in the ClientBin folder:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="Visualisation.xap">
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
</staticContent>
</system.webServer>
</location>
</configuration>
Any Ideas?
The site runs on a IIS7 (Win 2008 Server) with .Net 4.0 and c# as Backcode
hope for hints
I'd use firebug under the net tab to see what cache headers are being sent by your web server. You want to see something like: Cache-Control: max-age=31536000 and maybe an Etag.
There is a setting for caching under HTTP Headers in IIS under the common headers menu I think.
Another thing you might try playing with is the MIME type. It should be "Content-Type: application/x-silverlight-app"
If the headers are getting sent correctly and Firefox is choosing to ignore them, then there might not be anything you can do.
I've actually had the opposite problem with Chrome. Chrome seems to be very agressive with it's caches and I find myself running old versions of .xaps.
It seems firefox 4.0+ caches only files with 5MB or less in size.
See bug report

Resources