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

How To Store Pages As Trusted From Content Dialog C# uwp webview2 #3672

Closed
jarno9981 opened this issue Jul 30, 2023 · 13 comments
Closed

How To Store Pages As Trusted From Content Dialog C# uwp webview2 #3672

jarno9981 opened this issue Jul 30, 2023 · 13 comments
Assignees

Comments

@jarno9981
Copy link

i made a costum dialog that ask to proceed or ask to not proceed make i want if i click proceed it adds the website to trusted website certificates but i tryed multible options but they didn't work

Webview2 : Latest Pre-Release
Uwp

help

i want to remove default and when clicking in costum that website certificate gets approved and so that unvalid will not trigger c#

C#

@novac42
Copy link
Contributor

novac42 commented Jul 31, 2023

@jarno9981 you mean you are using UWP framework? May you also share Operating System version?

@novac42 novac42 added the status-circle back Check back after requesting general information. label Jul 31, 2023
@jarno9981
Copy link
Author

@jarno9981 you mean you are using UWP framework? May you also share Operating System version?

Yes uwp framework , Windows 11 latest beta

@jarno9981
Copy link
Author

@jarno9981 you mean you are using UWP framework? May you also share Operating System version?

Yes uwp framework , Windows 11 latest beta

@novac42

@novac42 novac42 removed the status-circle back Check back after requesting general information. label Aug 1, 2023
@novac42
Copy link
Contributor

novac42 commented Aug 1, 2023

@jarno9981 Thanks. Do you have sample app you can share to reproduce the issue?

@jarno9981
Copy link
Author

@jarno9981 Thanks. Do you have sample app you can share to reproduce the issue?

Yes buts really big i can send it after i am home from work

@jarno9981
Copy link
Author

project is 450mb total it can throw .pri error can be ignored after building second time it dissepears

drive link here : https://drive.google.com/file/d/1MWDc8Esf4XP68AJiTAfIB5bX-nXtBAn7/view?usp=sharing

here are webview2 located
WebConten.xaml.cs
WebContent.xaml

Code Line = 252 t/m 278

Control located in = Core Folder

@novac42

My expected behaiver is when clicking proceed that you can store the site a trusted

Windows 11 Pro, 22631.1972
Edge Runtime 115.0.1901.188
Microsoft.Ui.Xaml = 2.8.5

@jarno9981
Copy link
Author

navigate any localpage than this will appear

@monica-ch
Copy link
Contributor

@jarno9981 There is a ServerCertificateErrorDetected event you can use to intercept the error page, show the custom dialog and respond to continue/cancel the request.

@jarno9981
Copy link
Author

@jarno9981 There is a ServerCertificateErrorDetected event you can use to intercept the error page, show the custom dialog and respond to continue/cancel the request.

@monica-ch the method did not trigger anything not even safe it to secure or trusted

@monica-ch
Copy link
Contributor

monica-ch commented Aug 10, 2023

@jarno9981 Can you check if it repros after deleting the WV2 user data folder? Also, I'm not able to access the project you shared in the google drive to test it locally

@jarno9981
Copy link
Author

@jarno9981 Can you check if it repros after deleting the WV2 user data folder? Also, I'm not able to access the project you shared in the google drive to test it locally

I will test after deleting it and fixing google drive

@jarno9981
Copy link
Author

@monica-ch i fixed the link for the reproduce repo https://www.dropbox.com/scl/fi/u19sswfs3sxl8zlwfiifq/repo.zip?rlkey=l9zkqu9c24ot3f0369wq6c5qk&dl=1 using dropbox now

@monica-ch
Copy link
Contributor

@jarno9981 I see server certificate event gets fired upon subscribing to ServerCertificateErrorDetected in your app. Also, you must have to move your logic of showing the dialog in the server certificate event callback (not in the navigation completed) and get the deferral object and show the dialog in order to respond to the request.

Example of using deferral in UWP apps https://github.com/MicrosoftEdge/WebView2Samples/blob/main/SampleApps/webview2_sample_uwp/Pages/Browser.xaml.cs#L71

Example of responding to server certificate error detected event.
https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.servercertificateerrordetected?view=webview2-dotnet-1.0.1901.177

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

No branches or pull requests

5 participants