here I have a site www.mytest.com, it is very simple that only one blank page with an iframe.
<div id="container">
Hello World!!!
</div>
<div>
<iframe style="border: none;height: 100%;width:100%;position: fixed;top: 50px; background:white" src="http://anothersite.com"></iframe>
</div>
I have set Content-Security-Policy in "anothersite.com", and set it allow be accessed by site "www.mytest.com". It works fine, and in mytest.com iframe I could access "anothersite.com" and do normal things.
But, when I trying to access one page of "anothersite.com" in the iframe, it report an error: Uncaught DOMException: Blocked a frame with origin "http://anothersite.com" from accessing a cross-origin frame.
that is because I wrote these code for this page:
var test = '<div class="mystyle"><span>mythings</span></div> ......';
I have tried set document.domain = mytest.com in first site. And log for iframe's domain
console.log("iframeData",document.querySelector('iframe').contentDocument.domain);
console.log("hostName", window.location.hostname);
both of these result are "www.mytest.com". But it still cannot access the special page with same error.
Anyone know how to solve it or any workround for this?
I am trying to add or embed VLC media player into my asp.net web page.
the error I am getting is that object tag must contain a class,classid or progid attribute but I don't know how to get the values for those attributes.
Please help and be free to suggest any other way if possible for any media player that can run MP4 videos.I have
written the following code in the design
<div>
<object type="application/x-vlc-plugin" pluginspage="http://www.videolan.org"
autoplay="yes" lop="no" runat="server" ID="video"
style="width: 452px; height: 278px" />
<object classid="clsid:9BE31822-FDAD-461B-D51-BE1D1C159921" codebase="http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab"
height="28"></object>
</div>
<div><asp:Button ID="button_play" runat="server" Text="Play" on click="button_play_Click"/>
</div>
the error I am getting is that object tag must contain a class,classid or progid attribute but I don't know how to get the values for those attributes.Please help and be free to suggest any other way if possible for any media player that can run MP4 videos.
ill try my best to explain this..
in the site.master I have added a logo to the title like so.
<div class="title">
<img alt="" class="style1" src="Images/logo.png" />
</div>
the logo shows up fine in all pages accept when the url is part of the account.
for example..
"http://localhost:54341/Sitename/mypage.aspx" (shows fine)
however
"http://localhost:54341/Sitename/Account/Register.aspx" (doesnt show)
im guessing its because it is in a parent folder (the images file).
Is there a better way?
EDIT: Images folder is at the top level
thanks in advance
Try using relative path with respect to root of the application:
<img alt="" class="style1" runat="server" src="~/Images/logo.png" />
Explaination:
ASP.NET includes the Web application root operator (~), which you can use when specifying a path in server controls. ASP.NET resolves the ~ operator to the root of the current application. You can use the ~ operator in conjunction with folders to specify a path that is based on the current root.
The following example shows the ~ operator used to specify a root-relative path for an image when using the Image server control In this example, the image file is read from the Images folder that is located directly under the root of the Web application, regardless of where in the Web site the page is located.
<asp:image runat="server" id="Image1"
ImageUrl="~/Images/SampleImage.jpg" />
You can use the ~ operator in any path-related property in server controls. The ~ operator is recognized only for server controls and in server code. You cannot use the ~ operator for client elements.
This should do it...
<img alt="" class="style1" src="<%=ResolveClientUrl("~/Images/logo.png")%>" />
#Kevin Main suggested : You need to put runat="server" on the image for this to work.. this worked a treat
This will work for localhost:54341/Sitename/Account/Register.aspx
<img alt="" class="style1" src="../Images/logo.png" />
so: I've read 8+ stackover flows on relative to absolute. A few sites and went to MS page on this...
however when I've tried and had not success. Then I researched more and wonder solutions I read about are not part of .asp and just asp.net? (yup, I'm a novice / newbie / ignorant)
The situation and my aspiration:
I have a site that was initial just a few products and pages of text / images(~10), the number of products has doubled and I want to migrate to a tree structure for SEO / personal sanity / organization.
The original builder of site used This was great on single layer set up, as it is now.
i.e. example.com/page1.asp
Now I'm putting reviews (lengthy multiple page product reports), adding multiple products, etc on different depths in a tree. So while I can accurately connect to a relative include on
example.com/products/super-widgets/widget/reviews/index.asp
<!-- #include file="../../../../../../inc-footer.asp" -->
the sources inside the include break on as they are relative.
As I have attempted to research, stated above, I have tried to find a "best practice" for converting the relative to absolute for the information in the /inc-footer.asp file. I have consider putting an absolute path for agent to get global images
<img src="http://example.com/images/ex1.png">.
However I believe some say this is a poor choice for coding, I think it is because of speed of experience of clients / web visitors, but I don't know this.
So I have attempted a few trials and errors based on my earlier research with no avail....
inside the include file.asp I have (and failed to succeed with):
from this sites examples (link) I tried:
<img runat="server" src="~/images/tab-leftside.png" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />
and from MS (link) I tried:
<asp:image runat="server" ImageUrl="~/images/tab-rightside.png" alt="design object" width="21" height="20" class="tab-img" /> <a href="javascript:switchid('tab1');" onfocus="this.blur()" >Page 1</a> <img src="" />
while writing this I referenced some of recommendations and tried & failed with ( link )
<img src="<%= VirtualPathUtility.ToAbsolute("~/images/tab-rightside.png") %>" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />
Then I thought I need to modify above example and tried
<img src="<%= VirtualPathUtility.ToAbsolute("~/images/") %>tab-rightside.png" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />
Again with cross reference in writing this (link), I considered a but the include file has no
Only success I have had success with absolute path to http://
<img src="http://example.com/images/tab-leftside.png" class="tab-img" width="22" height="20" /><a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a><img src="" />
Presently, the site is hosted on Windows Server 2003 Microsoft-IIS/6.0
All of the page files are .asp
I use Google chrome to define success in testing above examples. As I experience if it doesn't' work in chrome it's not worth testing in other browsers.
Thanks.
Casey Burnett
<img src='<%= Page.ResolveUrl("~/images/tab-rightside.png") %>'
class="tab-img" width="22" height="20" />
<a href="javascript:switchid('tab2');" onfocus="this.blur()" >Page 2</a>
<img src="" />
Runat = Server won't work for classic ASP. Classic ASP and ASP.net are not interchangeable. They work completely differently.
Regardless of framework I've found Root relative paths work well when your development site is not using local host.
** Root Relative example**
<img src="/images/thisIsACoolImage.gif">
Here is an article on the different path types:
http://brugbart.com/Articles/paths
If you can I would use Root Relative paths, if not use absolute URLs. The only penalty for Absolute URLs the download overhead of a few extra characters in the URL.
I have an ASP.NET site that was working fine running on Windows Server 2003 / IIS6.
I moved it to Windows Server 2008 / IIS7 and the aspx page output now includes gibberish text.
For example:
p����
�����
The majority of the page renders properly, but there is gibberish here and there.
I have checked the event logs and there is nothing.
Any idea what's going on here?
How can I fix this?
I have noticed that this issue shows up when I include multiple Server.Execute statements in the aspx code:
<% Server.Execute("/inc/top.inc"); %>
<% Server.Execute("/inc/footer.inc"); %>
The .inc files above contain just html. It appears that the files have to be of a significant length to cause the error. Here is the sample html I've been testing with:
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
<div class="logo">
<a href="/">
<img src="/logo.png" alt="logo" width="31" height="29" class="logoimg" />
</a>
</div>
Also, the gibberish characters appear inconsistently. If I ctrl+F5 the pages, the gibberish characters change and occasionally don't appear at all.
I would bet the problem is that what you're seeing is the regular error page, gzip-compressed. However, the gzip compression HTTP header got lost when the server was redirected to the error page, so the browser doesn't know to uncompress it. Do you have some custom module that is doing compression? Are you setting the Response.Filter?
http://forums.asp.net/p/329153/330330.aspx contains a discussion of a similar issue, I wonder if it's the same problem you're seeing. Here's an excerpt from rox.scott's answer:
if you are transfering execution of the page after Response.Type, etc., is set then the resulting Response will have the Response.Type and encoding set by the initial page -- which might not be compatible with characters on the second page.
solution: make sure you are correctly specifying Response type and encoding on BOTH pages.
Want to try this and see if it works?
If that doesn't work, http://msdn.microsoft.com/en-us/library/39d1w2xf.aspx has an interesting discussion of various configuration options you can try to force consistent encodings throughout your site. You may want to try some of those. Also, that MSDN article does not use the ContentType directive but instead recommends this:
<%# Page RequestEncoding="utf-8" ResponseEncoding="utf-8" %>
Not sure if that will generate equivalent results as adjusting ContentType, but it's easy enough to try.
Also you can check globalization element in web.config
It must be in system.web section:
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
fileEncoding="utf-8"
responseHeaderEncoding="utf-8"
/>
Pop in to Firefox and try manually switching the page encoding (maybe to Windows-1252 first), see if the gibberish clears up. If it's suddenly readable, then at least you will know it's an encoding problem.
I'd also suggest looking at the output in a hex editor to see what you're actually getting. That could also give you a clue where to look. Might also try turning off gzip encoding or page compression.
this has nothing to do with encoding. This is IIS not knowing how to handle error messages if you are using it in combination with a virtual directory. My guess is that if you run this site in local debug on a machine, the error messages show up fine. Try that, if so, then you can start to infer where the actual error is.
We could never get this resolved.
The only solution that worked was to eliminate use of Server.Execute().
Try setting charset parameter.
<% Page ContentType="text/html; charset=utf-8"%>
This is a bit of a stab, but try setting your pipeline mode to "classic" in IIS.
You are probably sending a different encoding than the encoding of the .inc files.
Check the encodings of your .aspx and .inc files, and check the charset parameter of the content-type header being sent to the browser.
EDIT: Since the server is sending UTF-8, you should convert your .inc files to UTF-8.
To do that, open the file in Visual Studio, click File, Advanced Save Options, and select Unicode (UTF-8 without signature) - Codepage 65001. (Near the bottom of the list)
In the Windows Event Viewer you most probably will be able to find the real cause of the error. That way you can fix it.
Unfortunately you require RPD / physical access to the server, and it's only solving the error. Not the cause of the error not appearing.