Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using LoadFromBrowser, a popup window appears if the content is in json. #457

Closed
ogosengi opened this issue Dec 2, 2021 · 8 comments
Assignees

Comments

@ogosengi
Copy link

ogosengi commented Dec 2, 2021

When using LoadFromBrowser, a popup window appears if the content is in json.
Can I disable the pop-up window?
Language: C#
HtmlAgilityPack ver: 1.11.38
Point of Popup

HtmlAgilityPack.HtmlDocument doc = web.LoadFromBrowser(strurl);

json

@JonathanMagnan JonathanMagnan self-assigned this Dec 2, 2021
@JonathanMagnan
Copy link
Member

Hello @ogosengi ,

Thank you for reporting, we will look at it.

Best Regards,

Jon


Sponsorship
Help us improve this library

Performance Libraries
context.BulkInsert(list, options => options.BatchSize = 1000);
Entity Framework ExtensionsBulk OperationsDapper Plus

Runtime Evaluation
Eval.Execute("x + y", new {x = 1, y = 2}); // return 3
C# Eval FunctionSQL Eval Function

@JonathanMagnan
Copy link
Member

Hello @ogosengi ,

The v1.11.39 has been released.

Could you try it and let me know if everything is fixed


Is this library useful to you? Please help us by becoming a sponsor to keep it alive and supported.

@ogosengi
Copy link
Author

ogosengi commented Dec 3, 2021

Thank you for Your fast reply.
But It hasn't been fixed yet.

I am coding in VisualStudio2019(WindowsForm, .NET Framework 4.7.2)
example code:
string str1 = "https://infuser.odcloud.kr/oas/docs?namespace=15074473/v1";
HtmlWeb web = new HtmlWeb();
HtmlAgilityPack.HtmlDocument doc = web.LoadFromBrowser(str1);

The pop-up window still appears.

@JonathanMagnan
Copy link
Member

Hello @ogosengi ,

Unfortunately, I don't get a popup anymore on my side even with the URL and config you provided. So that makes it pretty much impossible to fix it on my side.

Could you check if you still get the popup with this code:

string str1 = "https://infuser.odcloud.kr/oas/docs?namespace=15074473/v1";

var webBrowser = new WebBrowser();
webBrowser.ScriptErrorsSuppressed = true;
webBrowser.NewWindow += WebBrowser_NewWindow;
webBrowser.Navigate(str1);

private void WebBrowser_NewWindow(object sender, CancelEventArgs e)
{
	e.Cancel = true;
}

If yes, try to fix it if you can and we will apply your change. As said, we cannot reproduce it so we cannot go anything more on our side.

Best Regards,

Jon

@ogosengi
Copy link
Author

ogosengi commented Dec 6, 2021

Hello @JonathanMagnan

It is same problem.
From googling, It seems that it is probably a problem with IE Setting on my computer.
Perhaps htmlagilityPack was made based on IE.

If I try the URL in IE, it will try to download the file in the same way.
json2

I Try Selenium Chrome Driver (very slow ㅜㅜ)

private void button2_Click(object sender, EventArgs e)
{
ChromeOptions options = new ChromeOptions();
ChromeDriverService driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;

options.AddArgument("headless");  
ChromeDriver driver = new ChromeDriver(driverService, options);

driver.Navigate().GoToUrl("https://infuser.odcloud.kr/oas/docs?namespace=15074473/v1");
textBox1.Text = driver.PageSource;

}

It is not Popup

@JonathanMagnan
Copy link
Member

Hello @ogosengi ,

Unfortunately, we cannot add a reference to selenium to our project.

@ogosengi
Copy link
Author

ogosengi commented Dec 9, 2021

I solved it in another way.
https://stackoverflow.com/questions/6114360/ie-prompts-to-open-or-save-json-result-from-server

I try Registry Update, It work.

JSON mime type


Windows Registry Editor Version 5.00
;
; Tell IE to open JSON documents in the browser (rather than always demanding that it saves
; the JSON data into an external file first).
; 25336920-03F9-11cf-8FD0-00AA00686F13 is the CLSID for the "Browse in place" .
;
; Taken from:
; http://stackoverflow.com/questions/2483771/how-can-i-convince-ie-to-simply-display-application-json-rather-than-offer-to-do

[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00

[HKEY_CLASSES_ROOT\MIME\Database\Content Type\text/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00

@tewuapple

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants