asp net mvc login page doesn't work inside iframe - html

I am working on a feature where our site is able to load another mvc site.
Basically I am using a Iframe with Id=aquaVetIframe where I put the url for my mvc site(setup of the src attribute for the iframe is done from codebehind). Everything is working fine in chrome. but at moment to test it using IE 10 the only thing what i can see in IE is the login page.
After sign in with the user the page return to the same login page. I could suppose that is related with the caching but i am not 100% sure.
here some code:
My aspx container:
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
<meta http-equiv="Cache-Control" content="max-age=0" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<style type="text/css">
html, body{height: 100%;}
</style>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="MainContent" runat="server">
<div style="height: 100%; width: 100%;">
<iframe id="aquaVetIframe" runat="server" allowfullscreen="true" style="position: absolute;height: 100%; width: 100%;border:0px"> </iframe>
</div>
</asp:Content>
Code behind:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim urlQueryString = Request.QueryString("urlId")
aquaVetIframe.Attributes("src") = urlQueryString
End Sub
At the top of my page I tried add the next tags, but with no luck:
<meta http-equiv="Cache-Control" content="max-age=0" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
Here an image of the http post requests using IE10 and chrome (browser where currently is working my app)
http://postimg.org/image/iaifcljdz/
UPDATE:
Adding this line to my mvc application, cookies are allowed from IE and the application run fine while I executing the page directly in the browser (right click on run on IE browser in VS2013)
context.BeginRequest += (sender, args) => HttpContext.Current.Response.AddHeader("p3p", "CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");
The issue what i have now is that my mvc aplication is not executing when I run my application from the begining.. for some strange reason the js libraries from mvc app are not loading..
see screenshot

Three things at a first look:
1) the iframe loads a full html page. So I recommend you to import the jquery libs inside the page you loaded inside the iframe (the login page);
2) IE is a good source of problem when testing a localhost server. It sometimes force a compatibility to IE8 or even IE7 on intranet (that includes localhost) pages. Ensure you have the IE10+ mode enabled. This question shows you how to do it:
You can achieve it by adding the following tag to your page
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
</head>
OR you can also add the following code in your web.config, inside the system.webserver tag (create it if it doesn't exist):
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=Edge" />
</customHeaders>
</httpProtocol>
</system.webServer>
3) As you didn't show your tags including the JS files, then It's a good idea to take a look at them (including the jquery ones). Ensure:
You are opening and closing <script></script> tags correctly. NEVER USE THE SHORT FORM <script /> when including a JS file because it won't work;
Make sure you are using the correct path. Using a relative path (like ~/scripts/jquery.js) doesn't work because of '~'. You can also find some trouble if you are using a subfolder for your site's root, like http://localhost/mysite/. In this case, your includes should include the folder /mysite or use relative paths (like scripts/jquery.js, ../scritps/jquery.js, etc).
Maybe this is isn't enought, but is a first needed step to get closer to a working code.

Go to IE > interntet options > security > custom level > Scroll down Misc > find "Launching programs and files in an Iframe" > enable

Consecutive ajax call with no change in request are often considered as cached by some browsers and this issue is particularly reproducible in IE 10. The response for request is HTTP 304 Not Modified and request doesn't hit the database. The solution is to use ajaxSetup to set cache to false like :
$(document).ready(function() {
$.ajaxSetup({ cache: false });
});
NOTE: This will set cache false for all ajax calls in the session.
OR
Using cache: false in particular ajax calls, if you don't want to disable cache for all ajax calls.
$.ajax({
...
cache: false,
...
});
For non-ajax call you can use :
Response.Cache.SetExpires(DateTime.Now.AddSeconds(0));
to response for suspected cached calls.
Also, it may be seems odd but I also faced similar issue in IE but that was due to cookie. Somehow there were two different cookies are created with same name & thus values stored in cookie wasn't found thus user was stuck on login page. Check if COOKIE is also not culprit in your case too.

Related

IE11 caching breaking status page

I have a status page that needs to be constantly refreshed. It makes ajax calls to a Java server and gets the updated statuses. It works perfectly in Chrome, but in IE11 it is not refreshing when I click refresh. However, when I open the dev tools, it does work. As soon as I close dev tools, it stops working. I have the following meta tags in my head:
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0">
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
And it won't be enough to set my own browser to not use caching; I need it to work for users without them having to change their browser settings.
According to this, https://support.microsoft.com/en-us/kb/234067, there is a bug in IE around this. https://support.microsoft.com/en-us/kb/222064 explains it. Maybe you're hitting that? I would also say you should make sure your meta tags are at the top of the head section.
Alternatively, I think the best solution would be to use HTTP headers. I've had very good results with cache HTTP headers.
I found a solution: Apparently, IE caches ajax calls, so that needs to be disabled. Adding 'cache: false' to the ajax call fixes the issue:
$.ajax({
url: www.url.com,
cache: false
})

IE10 iFrame loads page but doesn't display

I am trying to set up an iFrame to show a form from another domain within our company. And testing it in Chrome or Firefox works just fine.
The problem is, for IE 10, instead of showing the form, the browser is instead showing a blank page in the iFrame.
I've broken it down to a very simple test.html on my desktop. The Developer's Tools show that the network call not only works - but it registers loading files that are being included in the page I'm trying to call. I've even seen the debug statements in the form's javascript firing, and ajax calls running. But the iFrame is still showing blank.
I have hunted and searched and cannot figure out how to make this work.
The calling page has:
<!doctype html>
...
<DIV><iframe height="400" width="100%" src="http://my.domain.com/myForm?userName=clicky&email=cMcTesterton#domain.com"></iframe></DIV>
The called page has as its first two lines:
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!doctype html>
Which, of course, changes to simply
<!doctype html>
I am using URL binding, so there isn't an extension to speak of.
I have gone into IE's Internet Options -> Security -> Custom level ... -> miscellaneous to enable Launching Programs and files in an IFRAME and Navigate windows and frames across different domains
I can't even figure out what else to look for. It especially confuses me that according to the console, it has to be reading the page I'm trying to bring up. It just isn't showing it.
You have to configure, either (1) your site http://my.domain.com or (2) the page located in the site http://my.domain.com to send out the X-Frame-Options meta tag.
The X-Frame-Options meta tag is basically a hint to tell the browser that it's safe to render the page inside an iframe.
Option 1 - configure your webserver to send out the X-Frame-Options meta tag
<system.webServer>
...
<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="ALLOW-FROM http://my.otherdomain.com" />
</customHeaders>
</httpProtocol>
...
</system.webServer>
Option 2 - configure your page (the one referenced at src="http://my.domain.com/myForm?userName=clicky&email=cMcTesterton#domain.com") to send out the X-Frame-Options meta tag
<head>
<meta name="X-Frame-Options" content="ALLOW-FROM http://my.otherdomain.com">
....
</head>
Source

Auto refresh in Mac not working for some site

I got a code that refreshes the html page as per the seconds I desire. I am on an Mac and I use the TextEdit app to make the HTML file. This code works for www.apple.com but it does not work for say, https://www.bitcointalk.org or http://www.macrumors.com.
I am not sure why this is happening. All I am doing is replacing the apple URL with bitcointalk url. I know I can also do this refreshing via Safari extension, but I need this code to work.
Thanks a lot
The code I am using is:
<html>
<head>
<meta http-equiv="refresh" content="5">
</head>
<FRAMESET>
<FRAME src="http://www.apple.com/">;
</FRAMESET>
</html>
EDIT: What I am trying to do is, create this html and move it to my iPhone, so that I can do the web refresh through my phone. Right now there are only paid apps in the App store that lets you refresh a page automatically every few seconds/minute and they are not really that good.
As #esqew pointed out in their comment, the sites that aren't showing up forbid access via frames by setting the X-Frame-Options HTTP header to DENY or SAMEORIGIN.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options

How can I make my HTML5 website render in latest IE version AND be W3C Compliant?

Unfortunately I had the problem with my HTML5 website, where my Internet Explorer browser (I'm on version 11) decided it was the right thing to do to load the website in IE7 compatibility mode.
Insert annoyed face
Adding this <meta http-equiv="X-UA-Compatible" content="IE=edge" /> to the website does make it work correctly in IE, however if you put the website through the W3C Validator, it throws this error at you:
Line 6, Column 59: Bad value X-UA-Compatible for attribute http-equiv
on element meta.
I want to know if anyone knows if there's a way of having the best of both worlds?
It may be a little late for a contribution, but maybe someone can use it. Based on the fact that <meta http-equiv="..." content="..."> is used to simulate an HTTP response header (see here), if you have access to a scripting language like PHP, you could try something like this:
<?php
header('X-UA-Compatible: IE=edge');
?><!DOCTYPE html>
<html lang="en">
...
That way, the server still sends the header, but it's not in the HTML5 code itself. I used this on my website and it validates correctly on the W3C validator. I'm not sure about it having the expected results with IE rendering. Maybe someone can give feedback. My experiments are not too conclusive. I did find some small differences between using the PHP header function and using the meta tag when I tested a page in http://netrenderer.com/.
As I was on a local website, I had to un-tick the Display intranet sites in Compatibility View:
Alt+T > Compatibility view settings
The other option I found which has helped for my published project was to add some code in web config file:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=Edge" />
</customHeaders>
</httpProtocol>
</system.webServer>
This is obviously IIS on Windows, but you can apparently achieve this on Apache.

How do you disable caching on Modal dialogs in IE?

We have implemented a popup window as a modal dialog using the IE method:
window.showModalDialog('...aspx')
The target of the popup window is itself an ASP.Net web page.
Assume for the following steps that the popup has never been launched:
Launch popup.
Page_Load event handler executes on server side.
Close popup.
Immediately launch popup again.
This time Page_Load event handler doesn't execute.
It's clear that the popup content is being cached because if at Step 4 we clear the temporary internet files the Page_Load event handler is executed the second time.
We have experimented with adding the following to the Head of the web page (as recommended by several other sources) but none of it seems to work.
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
We have also seen places where the use of these is discouraged
Can anyone help?
Add a timestamp querystring variable to the URL of the dialog content - number of ticks since 1/1/08 or something - IE will treat it as a new page and ignore the cache.
To clear cache add this in page load:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Given that the http-equiv directives don’t work (and arguably shouldn’t be used), and despite it unfortunately being in the hack category of solutions, I think we are going to have to go with this (posted by Greg)...
url = "<Some url with query string>"
var date = new Date();
window.showModalDialog(url + “&” + date.getTime(), ... );
It is strange that there is no definitive way to disable caching on these modal dialogs. I’m not sure whether using modal dialogs in web browsers is accepted as a "good idea" or not, but we are aware of at least some of the shortcomings and alternatives, but are just unfortunately unable to use them in this project.
Thanks for your suggestions.
Place Fiddler in between the IE and your server. Then check if the response to your request carries a HTTP header Cache-Control. Is there some value given other than no-cache ? If so then maybe IE will give this header priority over your http-equiv directive.
If not, you should try to make the server send the HTTP header Cache-Control:no-cache. If IE does not respect this, it's a bug in IE. Experience shows it's less painfull to opt for a different solution than to press for a bugfix, so in this case I'd agree to the tip of Greg.
First i tried by using the following code.
meta http-equiv="Cache-Control" content="no-cache"
meta http-equiv="Pragma" content="no-cache"
meta http-equiv="Expires" content="-1"
but it was not given any solution after, i tried with Query String with time stamp variable,
like
vat time = new Date().getTime();
url?queryString&time=time
then it works....
Thanks...
you forgot a tag to reprocess the page.
<base target="_top" />
if you put below tags, the cache will be cleaned:
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<base target="_top" />
One of the strange quirks of IE is that setting no-cache at the beginning of the file doesn't seem to work, but moving that section to after the original HTML often does. Still best to send it as an HTTP header, but the following will work in most cases:
<html>
<head><title>Blah</title></head>
<body>Contents</body>
</html>
<html>
<head>
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
</head>
</html>
The answer Response.Cache.SetCacheability(HttpCacheability.NoCache); is the only one that works correctly with IE9. If you set the timestamp in the querystring, you still have to refresh the page to get a different URL. So, the modal dialog is still cached until the page is refresh, unless you use Response.Cache.SetCacheability(HttpCacheability.NoCache);
Using a timestamp on the URL and Response.Cache.SetCacheability(HttpCacheability.NoCache); would be best, cover all the bases. It is IE we're dealing with after all.
You could also try the following statement at the top of the aspx page being called:
<%# OutputCache Location="None" %>