I'm using CefSharp3 to embed a chrome browser into my C#.Net application. Everything loads well and works as would in the chrome browser, but the both the disable-web-security command line setting or BrowserSettings.WebSecurity setting stops the embedded browser from preventing me to load scripts from a different origin.
Error message: "Refused to load script...because it violates CSP (Content Security Policy)..."
I thought disabling the setting above disable CSP.
Here is the chrome://version output from the same window/browser:
CEF 3.2704.1432.g60b3718
Chromium 51.0.2704.103
OS Windows
WebKit 537.36
JavaScript 5.1.281.65
Flash
User Agent Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
Command Line "c:\my_path\documents\visual studio 2015\Projects\My_Solution\My_Project\bin\x64\Debug\My_Project.vshost.exe" --browser-subprocess-path=CefSharp.BrowserSubprocess.exe --no-sandbox --lang=en-US --log-file="c:\my_path\documents\visual studio 2015\Projects\My_Solution\My_Project\bin\x64\Debug\debug.log" --remote-debugging-port=8088 --enable-system-flash=1 --process-per-tab=1 --allow-access-from-files=1 --allow-universal-access-from-files=1 --disable-web-security=1 --no-proxy-server=1
Module Path c:\my_path\documents\visual studio 2015\Projects\My_Solution\My_Project\bin\x64\Debug\libcef.dll
Cache Path cache
From the above, --disable-web-security=1 shows is set, but still CSP is active, how can I make this work to disable CSP?
I've looked at other questions on this forum, but I did not find the case where the setting does not get effected.
Related
I need the driver to work under the specific user-agent. I previously used a
chromedriver v 2.27. Here so installed user-agent:
ChromeOptions options = new ChromeOptions();
options.AddArguments("user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 5_0
like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko)
Version/5.1 Mobile/9A334 Safari/7534.48.3");
But it does not work in chromedriver v 2.32, which is constantly updated by every compiling of Selenium project.
How to set user-agent on chromedriver v2.32 or how to disable auto-update, because disabling the browser update (in several ways) did not help?
Try this:
ChromeOptions options = new ChromeOptions();
options.AddArgument(string.Format("--user-agent={0}", "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"));
You just lose "--".
As a part of build output for a ASP.NET website project we create a bin folder. In order to validate that the build output is actually a functional website we load it into the IIS. And, the browse to it.
Is there a way to automate this in C# ?
I am not looking for a test framework to do this. Just a simple C# light-weight application that can point IIS to this bin folder, test the web application loads thats all.
Make your IIS VirtualDirectory/Application point to your bin folder, or a drop folder that you copy all the bin folders content when you do a Build.
Then do an IISReset:
System.Diagnostics.Process.Start("C:\Windows\System32\iisreset.exe");
Then hit the website using a Webclient:
WebClient client = new WebClient ();
client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
Stream data = client.OpenRead (webUrl);
StreamReader reader = new StreamReader (data);
string s = reader.ReadToEnd ();
Console.WriteLine (s);
data.Close ();
reader.Close ();
C# Browser version get wrong version for windows 11(last windows update v:11.187.14393.0)
HttpBrowserCapabilities browser = Request.Browser;
Console.WriteLine("Result:" + browser.MajorVersion.ToString());
Result:7
Go into Internet Explorer and hit F12. Check the emulation tab.
Document Mode and User Agent string are what determine the browser version.
change both those settings to
Document Mode: Edge (default)
User Agent String: Default
I am working on SignalR. Everything working fine in all browser except IE8.
Here is my code.
<script src="~/Scripts/jquery.signalR-2.2.0.min.js"></script>
<script src="../../signalr/hubs"></script>
$(document).ready(function () {
var templateId = '#Model.TemplateId';
var importNotifier = $.connection.runImport;
importNotifier.client.sendMessage = function (data) {
UpdateChart(data);
};
$.connection.hub.start().done(init);
function init() {
importNotifier.server.import(templateId, $("#hdnServerName").val(), '#ViewBag.ServerUserName', '#ViewBag.ServerPassword', '#ViewBag.AuthenticationType', '#ViewBag.DatabaseName');
}
});
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1;
Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR
3.0.30729; .NET4.0C; .NET4.0E; InfoPath.3) Timestamp: Tue, 22 Sep 2015 07:39:12 UTC
Message: Expected identifier, string or number Line: 88 Char: 13 Code:
0 URI: http://localhost:8092/signalr/hubs
Message: Expected identifier Line: 279 Char: 39 Code: 0 URI:
http://localhost:8092/Graph/Graph/?TemplateId=27&IsUse=0
I am not able to understand why it is not working.
I tried to insert http://localhost:8092/signalr/hubs to browser and its allow me to download.
I websockets are not supported in IE8. First version that works with websockets is IE10.
Here's a list of browsers that support(or not) websockets: http://caniuse.com/#feat=websockets
I finally resolved issue.I follow following steps
uninstall all packages which is required for SignalR.
Install again required packages.
I follow this step. because I was in impression that may there was some dependency issue.
Then also my code was not working
finally I change my method name "Import" to "InsertingData"
and its working now.
So I can not conclude here that only name creates any problem (may be import is keyword in ie8) or there is some issue with dependency also.
I have asp.net 2.0 web application. On my production server I "randlomly" cant reproduce the path error on my page which uses UpdatePanel and RadComboBox telerik control:
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB7.2; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2)
Timestamp: Mon, 14 Nov 2011 10:37:17 UTC
Message: Sys.ScriptLoadFailedException: The script 'http://www.mySite.com/ScriptResource.axd?d=K-bZ_cYro-TWH0gbbmdTlkin59eWVsDQYopNlGtfNYd9aZQqi22u0d_A5dwpqMXbaJR99E08UDAgSF7tPCaP0mpZH35-uv4YYRWnSX0mxLsZPGu-58i2Nrmb8UHNokeftpIW9wTPOvZOJJq4cLYfu3iV8EQ1&t=634475972033675436' could not be loaded.
Line: 5
Char: 36564
Code: 0
URI: http://www.mySite.com/ScriptResource.axd?d=qLp9xu4UQDU3wBn-LSS2bLlqFvY6K78U8bVN8Ado2bzP7ytCoarS92INypIVz4z3TbmYil4Bsu_vW_InD5PMZRw-1WJbZIeVuS8TpTL23g_GrfQ29YBzoTaZWO2T3kxiSZPDfk0zqFyT9qKbsPGSfNc4kjnqG509cXg82kYxOpPDJjpf0&t=634532699342719389
Do You know any cause for this error ? Thanks for help in advance.
I had a similar problem with a stylesheet missing. I added:
string sRequestUrl = Request.Url.ToString();
To my error message to get it to output the file in question. Is this a case of you having a script manager which is consolidating (minifying) stylesheets and JavaScript files into one and you are losing the Request Url in the .axd? If you do turn off the consolidation (minification) and you should get the exact file from the Request Url.
If that is the problem.