Why won't my styles show in a Dynamics CRM 4 IFRAME? - dynamics-crm

I have created a web page (ASP.NET) that includes a stylesheet to mimic Dynamics CRM styles. This is to be used in a CRM IFRAME (within a form).
The stylesheet is referenced as follows:
<head id="Head1" runat="server">
<link href="Styles.css" rel="stylesheet" type="text/css" />
</head>
When I load the page in Visual Studio, all is well. When I load it in CRM, none of the styles are shown and no images are displayed. If I browse directly to the image, I get a 404 error. However, the pages function correctly.
I have set read permissions for "Everyone" on the server to see if that was causing a problem but it didn't help. I also tried putting a plain HTML page in the folder and that won't load either - again a 404.
The page is installed in the ISV folder ..../isv/MyProject.
Can anyone help?
EDIT
This is on a multi-tenancy system. On my test company (testcompany) if I browse to http://crm/testcompany/isv/MyProject/MyPage.aspx, the page is loaded (without styles and images).
If I browse to http://crm/testcompany/isv/MyProject/TestImage.gif, the image is not shown.
If I browse to http://crm/isv/MyProject/TestImage.gif, the image is shown. Does this suggest a problem with the server setup and the way CRM messes around with virtual directories?
This does mean that if I set the styles reference to /isv.MyProject/Styles.css, the page looks correct. However, as I don't know where the project will be installed by customers, this is inappropriate.

The issue is that CRM uses an ASP.NET Virtual Path Provider to include the tenant name in the URL path. But for file types that are not handled by the ASP.NET handler, IIS fails to find them.
As a work around, you can reference your CSS from your HTML page using a path like href="../Styles.css"
Actually you'd probably be better off using href="/ISV/MyProject/Styles.css" because when CRM is accessed using an Internet Facing Deploy configuration, it does not include the tenant name in the path.

Although already answered, this post describes the 'problem' in detail http://blogs.msdn.com/emeadcrmsupport/archive/2010/03/22/how-to-create-a-relative-url-in-site-map-to-static-content-under-the-isv-folder-in-crm-4.aspx

Related

Can't scrape this site with Goutte Laravel Package. Elements exist in view source

I am building a scraping tool with the Laravel Goutte Package https://github.com/FriendsOfPHP/Goutte I have been able to scrape most websites until I came across this website http://www.bhutanpost.bt/ which I need to scrape.
The problem I am suspecting is that the site has charset as UTF-7 and the returned xml is not the same as it is shown in "view source". The elements I am trying to scrape do exist in the view source so I can say they are not pulled dynamically by JS.
Any help will be highly appreciaetd.
I dug through it and found a dirty fix,
The problem was with the loadHtml function of DomCrawler which was inside parseXhtml function. When the meta tag is not explicitly defined loadHtml causes problems so here was my fix:
$dom->loadHTML('<meta http-equiv="Content-Type" content="text/html; charset='.$charset.'">'.$htmlContent);
I prepended the meta details before the HTML content.

Blazor Web Assembly - accessing images in RCL

I'm new to Blazor - so this may be obvious but I can't figure it out. I have a WebAssembly project and a separate Razor Class Library where I have some components. I have a component that I want an image in - I place the image in the wwwroot/img folder of the library and access as below
<img src="/img/logo.png" alt="test logo" />
But it will not display - I've tried
<img src="_content/img/logo.png" alt="test logo" />
But it won't display either.
The only way I can get my image to display is to put it into the wwwroot/img folder of the Client Project. But I want my component library to be able to be used in other projects.
Any guidance much appreciated. I'm coming from a Windows Forms background so I have a lot to learn :)
I´m also new to web development, but afaik the wwwroot folder serves as folder for static files your webpage uses (this is also the only folder the browser can access for media files for security reasons as I have understood it).
I had the same problem some days ago, I solved it by putting everything into the wwwroot folder, but I also found an article in which another way is suggested.
http://blog.vivensas.com/static-image-in-blazor-inside-and-outside-web-root/
There it is basically suggested to create a method in the Startup.cs file, which will be able to get your images from elsewhere:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseStaticFiles();
app.UseStaticFiles( new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path. Combine(Directory . GetCurrentDirectory(), “StaticFilesFolder” )),
RequestPath = “/StaticFiles”
});
}
Then you can use your images like this:
#page “/”
<h3> Display Image in Blazor</h3>
<div>
<img src=”/StaticFiles/Image/OutsideWebRoot.png” />
</div>
#code {
}
Edit: Maybe I misunderstood your question, for this to work it also has to be in the client project. I don´t know the way to get images from other solutions than the client project.
I came across this problem as well in my Blazor Server application (.NET 6). I was using RCL in my blazor application and when I tried to save static assets in my RCL's /wwwroot/images and make use of them in that same RCL's component (to show an icon), I got a 404 when I utilized that in my Blazor app.
Here's how I did a little trick to get past this problem:
I stored all my static assets in my Blazor app (instead of RCL)
In my Blazor app's styleseet (site.css or any other), I created CSS variables for those assets, like:
--logo: url(/images/logo/logo-light.png);
and then in my RCL, I made use of them using a class selector and applied the content to that CSS variable created, like:
.icon:before {
content: var(--logo)
}
Worked like a charm.
2 years later, just in case... at least in .Net 5, 6,...
To fix the problem you need to set the source of the image tag to _content/YourRazorClassLibraryName/img/logo.png
Example:
<img src="_content/YourRazorClassLibraryName/img/logo.png" />
Important
If you do not reference the image from HTML, like in the example, the image will NOT get downloaded to _content/YourRazorClassLibraryName/img. So, at least one html element in your app needs to use the image, otherwise it will not get downloaded. Setting the background image of elements in CSS will also cause the image to get downloaded.
You can inspect this by:
running your app
pressing F12 in chrome\edge to launch developer tools
go to Sources tab
expand [site_url]/_content/[YourRazorClassLibrary]
check if img folder is there or the image that is not referenced in the HTML exists

CSS and images do not appear until my application makes a database call

I'm hoping this isn't a double-post - I couldn't find my issue in the search, but I imagine it might be asked in several ways. My project involves a PHP5 workspace running the Laravel 4 framework.
Quickly, my issue occurs when I access any webpage within my private project that does not first make a call to a database. When viewing the page, my images are missing and the CSS styles - though correctly called in source, and accessible when I click on the HREF's for my styles - aren't displayed properly.
After going to a page that makes a database call (for instance, my Manage Users page which displays a list of users in the database), all images and styles in all pages work. Essentially, I:
Access the homepage, which is static HTML. It's styles are broken.
Access an admin panel page which is static HTML. It's styles are broken.
Access an admin panel page that pulls a list of users to the database. The styles suddenly work.
Any pages I visit after this point display styles properly.
Has this happened to anyone else? Is there a simple way to resolve this?

Redirect to another page by using the Content Editor Web Part is not working

I am using content editor to redirect on a different page of a SharePoint 2010 site. It had following code:
<script '"text/javascript"'></script>
<meta http-equiv="refresh" content="1;url=http://intouch/...">
Its working only for a specific group of users. I exactly don't know which permission level is working to it. I have Full control so its working well for me. Other users, who hava Read or Contribute permission, does not work.
Although I want to reduce time. It is now 1 sec (i.e. content attribute value in meta tag), can it be reduced?
In other words how can i improve its performance.
According to this page you can set the value of the timer to 0 and it will redirect immediately.
Another alternative is to use the SharePoint page template "Redirect" which allows you to redirect to a specific URL without adding any code. However, it may not be immediate, and it only works on sites where the Publishing feature is activated.

Page tab loads content from some domains but not others?

I’ve created a welcome tab for a Page. When I set the Page Tab URL to pull content from http://journalism.unr.edu/facebook/welcome/, the tab comes up blank. But when I uploaded a copy of the content to a free 000webhost.com hosting account at http://rsj.netii.net/welcome/, and used that address as the Page Tab URL, the content loads just fine. What I want to know is, why?
I’ve experimented with pulling content from other URLs into my page tab:
yahoo.com - works
google.com - doesn’t work
unr.edu - works
journalism.unr.edu - doesn’t work
unr.edu/engineering - doesn’t work (shows error message: “The page cannot be displayed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.”)
Does anyone know why page tabs/iframe apps load content from some domains but not others? Can anyone tell me how to fix the journalism.unr.edu web server (I have access to it, I work for the journalism school) so that page tabs can load content from it? We’d like to be able to pull content straight from our website without having to copy it over to a free hosting account.
I'm not sure what is the problem with http://journalism.unr.edu/facebook/welcome/
But I cannot even get it to load inside of an iframe. Maybe there's some restriction setup in the hosting or server that servers that site. Or maybe a more complex issue with the server not allowing it to be iframed from a different host domain.
Simple to test, just make an html page like.
<html>
<body>
<p>I hope it loads</p>
<iframe src="http://journalism.unr.edu/facebook/welcome/" width="400" height="300"></iframe>
</body>
</html>
Also: "unr.edu/engineering - doesn’t work (shows error message: “The page cannot be displayed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.”)"
That one is because you're pointing to a resource on the server that does not allow HTTP POSTs.

Resources