NullReferenceException throws on Windows when setting Cookies on .NET MAUI WebView#24846
Merged
jfversluis merged 18 commits intodotnet:mainfrom Nov 26, 2024
Merged
NullReferenceException throws on Windows when setting Cookies on .NET MAUI WebView#24846jfversluis merged 18 commits intodotnet:mainfrom
jfversluis merged 18 commits intodotnet:mainfrom
Conversation
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
PureWeen
requested changes
Sep 23, 2024
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Member
|
/rebase |
7fa653b to
e767611
Compare
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Azure Pipelines successfully started running 3 pipeline(s). |
1 similar comment
|
Azure Pipelines successfully started running 3 pipeline(s). |
Member
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
PureWeen
requested changes
Oct 3, 2024
PureWeen
requested changes
Oct 4, 2024
Member
PureWeen
left a comment
There was a problem hiding this comment.
Apologies
By under I just meant switch the place of the call here
So change the code to be
UpdateUserAgent
webViewHandler.SyncPlatformCookies(platformWebView.CoreWebView2.Source).FireAndForget();vs
webViewHandler.SyncPlatformCookies(platformWebView.CoreWebView2.Source).FireAndForget();
UpdateUserAgent
PureWeen
requested changes
Oct 7, 2024
| if (Handler is WebViewHandler handler && handler.VirtualView is not null) | ||
| { | ||
| sender.UpdateUserAgent(handler.VirtualView); | ||
| handler.SyncPlatformCookies(sender.CoreWebView2.Source).FireAndForget(); |
Member
Contributor
Author
There was a problem hiding this comment.
We've added cookie validation to the UI test as per your suggestion. Could you please verify once?
|
Azure Pipelines successfully started running 3 pipeline(s). |
Member
|
/azp run |
Contributor
Author
|
/rebase |
…er platform view.
84e03cf to
25cd0be
Compare
Contributor
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
jsuarezruiz
approved these changes
Nov 26, 2024
jfversluis
approved these changes
Nov 26, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Root Cause
While setting a cookie in MAUI WebView, CoreWebView2 is null before the CoreWebView2Initialized event triggered.
Description of Change
Added the null condition for CoreWebView2 property while sync platform cookie method.
Issues Fixed
Fixes #18452
Validated the behaviour in the following platforms
Output images

Before changes
After changes
