WebBrowser css not loaded - winapi

I have a complex HTML5 based user interface, which I show in my native win32 desktop application using webbrowser (Internet Explorer).
I've decided to open it from local machine instead of web server. But it did not work due to various security restrictions. So I found a workaround: setup asynchronous pluggable protocol for https protocol inside of my process and just provide data from local machine instead of Internet. I had to also implement my custom IInternetSecurityManager for the things to work (for unknown reason it was not enough to just implement IInternetSecurityManager and use file: scheme).
Now all seems to work fine except the one thing: browser completely ignores CSS files. It acts the way as if files are not there. It loads js from files, shows images, but does not "see" CSS files.
If I try to navigate to CSS file, it shows me this error message:
But if I try to access this CSS file using XMLHttpRequest - it "downloads" it fine.
Sorry for not providing a minimal reproducible example - it would be quite hard. Maybe somebody knows the reason, or can suggest me anything that I could try to resolve this issue?

Related

Firefox local filesystem links in quantum

We are wanting to move our intranet users from IE to Firefox but we have some places where we want to be able to open local (or network) files or directories.
I have found quite a few references in Stack Overflow and otherwise but most of them are quite old and none of the old techniques seem to work with the current version of Firefox Quantum (v68 at the time of writing).
The Local Filesystem Links extension seems to work well but I would rather not rely on an extension, particularly one that also requires installation of an addon module, if possible.
Can anybody tell me how to access the local filesystem from a webpage in Firefox by just changing settings in about: config? Or is this just not possible anymore?
I am hoping to get something like <a href="file://///networkdrive/directory"> working if possible
I posted this question on the Mozilla support pages too and got the following solution from jscher2000 which I post here in case it is useful to others
Your timing is excellent, there is now a Policy/GPO way to do this as of Firefox 68. No extension required. See:
+ LocalFileLinks policy configuration: https://github.com/mozilla/policy-templates#localfilelinks
+ Customizing Firefox Using Group Policy (Windows)
+ Customizing Firefox Using policies.json
There also is an old school method which is backwards compatible and doesn't require an extension. It involves adding some lines to an optional user.js file (in the user's current Firefox profile), but which might be more conveniently deployed through an Autoconfig file (in the program folder). Those are both files Firefox reads at startup.
// == FILE URI LINK POLICY (checkloaduri) ==
// Create policy enabling http: or https: pages to link to file:
user_pref("capability.policy.policynames", "filelinks");
user_pref("capability.policy.filelinks.checkloaduri.enabled", "allAccess");
// Sites to which the policy applies (protocol://hostname protocol://hostname)
user_pref("capability.policy.filelinks.sites", "http://example.com http://intranet");
I tried the old school method and that worked perfectly
Our IT team have now added the policy and it is working for us but I had to do the following to get the directories to open in Windows Explorer rather than in a webpage within Firefox.
In about:config I added 2 preferences
network.protocol-handler.expose.file – set this to false
network.protocol-handler.external.file – set this to true

Why is Configuration message appearing on jpeg images exported from DICOM file?

I am trying to make a web based dicom image viewer. I am using c# and asp.net. I am using Clear Canvas libraries found on www.clearcanvas.ca. The problem here is that when I try to export the jpeg images from dicom files the following message appears on them:
"The current configuration system does not support user-scoped setting"
On other forums I have found that this error can be removed by the application scope settings. I have tried that and still the message appears on the images. I have even shifted the user settings in app.config file to applicationsettings sections. Since web based solutions do not support user settings because the website has to run on the server. If some one has done this and removed this message from the images, then please share it here. I would really appreciate some help on removing this error. Thanks.
The ClearCanvas ImageViewer components were written to using several User settings. IIS based applications do not support user settings. An exception is occurring within the assembly due to the lack of support for user settings and placing it on the image.
There's a couple of solutions. You could go and modify the code by changing all of the settings to be application settings instead of user settings. You could also create a new .NET settings provider that supports user settings that could be used within IIS.

Swapping an image during web development

I'm trying to see what a certain webpage would look like if I replaced a certain image with another. Rather than upload the image, edit the site, etc, each time I tweak it, I'd like to know if there's a way to change the image in the page to my local version while viewing the remote page.
I use Firebug for debugging web development usually, but I'm open to any other tool that might do this.
(It is absolutely impossible to search for this and find anything but questions about dynamic image swapping on a deployed website, so sorry if this is a duplicate.)
Added: I just tried substituting a file:/// URI pointing to the image (copied and pasted from the address bar after manually opening the image), and alas, it did not work — the image fails to change.
It seems to only work with the http[s] protocols (likely for security reasons). You can store your images on service like Dropbox, share the image or folder, then use the public URLs.
Really, you can use any web accessible images, so a local server would work too.
If your image is in a localhost server(not as file mind you) i think you can still put that localhost url in the firebug inspect element and it'll work.
Tried an absolute file path but it doesn't work apparently. So I guess you just have to make do with a localhost server image. That works for me
Quick and Lowtech Answer: Take a screen shot of the page open it in photoshop and drop the local image on a layer above the webpage image.
Hi if you are serving from a webserver, u probably can't point it to a file on ur local drive. Even if its localhost, u can't point to a local file c:/test.jpg for example. Its because the browser sorts of sandbox ur page so that scripts can't access local files.
One way is to upload the new file (new_file.jpg) to the webserver, give the image link an id
<img id="something1" src="test.jpg"/>
Using jQuery in the firebug watch window do
$("#something1").attr("src","new_file.jpg");
You should see the image change. If you are not using jQuery, you can use document.getElementById("something1") and get the element to modify.
Another way is to use http://makiapp.com/
You can overlay an image from you computer onto any website you look at with this. Very cool tool for lining up a comp with your code.
You can:
Drag your test image into Google Drive
Open it in a browser
Go to the actual image path
Use this path as a substitute in Firebug
It's almost as fast as working from a local drive.

Problem with Outlook plugin and webbrowser

I've created a couple of Office plugins. The plugin shows a set of html files installed on the clients computer. The plugin uses a COM-accessible assembly which shows a WinForm with a WebBrowser on it. The plugin makes the WebBrowser navigate to a file on the clients computer. The assembly is also used in other programs to show the same information.
When showing the local html files using a 'normal' browser (e.g. double clicking a file in Windows Explorer) the browser popup a security warning about running active content. This is because we have some javascript in it. This warning is supressed by setting the 'Allow active content to run in files on My Computer' in the Internet Explorer settings. This solves the issue using a 'normal' browser.
Funny enough the 'active content' warning is not shown when getting the same file using a Word/Excel/PowerPoint plugin. It calls the same assembly, using the same WinForm and using the same content. Despite the setting 'Allow active content to run from My Computer' being false, the content is shown without a warning and the javascript is executed.
Now, the problem and the real question is that Outlook does the reverse. No matter what I use for 'Allow active content to run from My Computer' the browser warning about the active content in the html file is shown. When I confirm the message and allow the scripts to continue, the javascript runs fine. So, even when I set the 'Allow active content to run from My Computer' to true, the warning is given.
I've gone through all (sort of) relevant settings in Outlook, but nothing helps.
I assume that Outlook is using some kind of private context for a webbrowser (probably because it is using a webbrowser object internally).
The real question is: how can I make the Outlook plugin respect the IE settings?
(I understand this is a long story and maybe not clear enough. Please let me know if I have to elaborate more).
I couldn't get rid of the security warning without lowering the security setting. And that is not an option: we are talking about a project that will be installed on millions of computers.
I decided to go another route. Let's see if we can make the browser trust the html pages. So, what to do to get rid of the 'Active content' warning.
First I investigated what exactly triggers the warning. That was easy: any tag in your html file will do. And I need script, so removing that isn't an option. But, when hosted from a website, the scripts run fine and don't suffer from a warning. So, I investigated if it is possible to run my files in the Internet-context.
I found out there is a way, at least for IE (which in my case is sufficient). If you save a webpage as a complete HTML file from IE, the browser adds a comment to the html to signal its origin. Something like: . If you later open that stored html file, the file is shown in the Internet context.
So, I tried adding to the html file. And, voila, the file is opened in the Internet context. The security warning about active content is gone and the scripts are executed fine.
But, that raised another problem. We have a couple of window.open statements in the scripts and using that causes he cross domain browsing problems that in recent IE versions are blocked. Even if you use a relative path in the window.open call, if fails and you end up with a blank window.
In our case, we can (probably) decide to get rid of the window.open calls. But, if a reader ever finds a solution for using window.open in this scenario, I would be very happy if you let me know.
So, for now: case closed...
Internet explorer use Mark of web in such cases
<!-- saved from url=(0014)about:internet -->
<!doctype html>
<!-- saved from url=(0023)http://www.contoso.com/ -->
<html>
<head>
<title>A Mark of the Web Example.</title>
</head>
<body>
<p>Hello, World</p>
</body>
</html>
More info from here
https://msdn.microsoft.com/en-us/library/ms537628(v=vs.85).aspx

CSS reload on IE7

It looks like IE7 doesn't reload the latest version of my stylesheet each time I upload a new version on the server.
This is annoying as I am debugging my .css file to make it work on IE...
Tried to empty the browser cache but still not working.
Thanks for your help.
Ctrl-F5 - forcible way to reload in IE
Include your version number in the file name. myfile_v1234.css
When testing, every time you do an update you can just wite "stylesheet.css?r=98123"
As long as the query string is different, it'll be downloaded again.
If you need, you can use javascript to append Math.random(), to get the random number. Not required on production though, when updates would be stable.
2 Questions:
Does IE eventually load with the newer stylesheet?
How are you saving the changes to the server (SSH, Web Interface, etc.)?
I ask because I ran into an issue with a web-based file management system a while back where one browser would show the CSS just fine, the other wouldn't, and we noticed the issue of which browser played nicely depended on which browser we used to upload the CSS.
The reason turned out to be that IE gave the CSS file a different MIME type than Firefox. If you continue to notice the issue even when you've cleared the cache, check the MIME type of the file using Firefox by going to Tools > Page Info.
Also, if it is simply a caching issue, consider turning caching off in IE. I believe this should be an Advanced Option under Internet Options.
Also, you may want to try creating a special developer environment for IE (if it comes down to it.) Perhaps have another machine with IE7 and no caching and any other features turned off (A kiosk mode, perhaps), and then previewing the page on that machine.
Thanks to you all!
I did manage to solve my problem with the "stupid" Ctrl+F5, and by changing the Internet Parameters of Windows to reload content every new visit.

Resources