Skip to content

Web View in Windows Form not loading #5

@altafJebran

Description

@altafJebran

Hi Team,
I am trying to open webview in windows forms and i am using below versions of

image

and below code to load ADFS Url in webview so that user can key in username,password to authorize
Hi,

I am trying to load windows forms app if the user is succesfully logged into AD, For the same i am using
.NetCore3 preview 4

In Windows forms

var authResult = authContext.AcquireTokenAsync(resourceURI, clientID,
new Uri(clientReturnURI),
new PlatformParameters(PromptBehavior.Always, new CustomWebUi(SynchronizationContext.Current))); //Dispatcher.CurrentDispatcher

In

CustomWebUI Class

class CustomWebUi : ICustomWebUi
{

private readonly SynchronizationContext _dispatcher;
    public CustomWebUi(SynchronizationContext dispatcher)
    {
        _dispatcher = dispatcher ?? throw new ArgumentNullException(nameof(dispatcher));
    }

public Task AcquireAuthorizationCodeAsync(Uri authorizationUri, Uri redirectUr)
{
var tcs = new TaskCompletionSource();

        _dispatcher.Send(_ =>
        {
            //anything you wish.
            var webView = new WebView();
            webView.
            var w = new Window
            {
                Title = "Auth",
                WindowStyle = WindowStyle.ToolWindow,
                Content = webView,
            };
             w.Loaded += (sender, args) => webView.Navigate(authorizationUri);
	w.Loaded += (sender, args) => webView.NavigateToString("<title>sfsdf</title>");
            

	if (w.ShowDialog() != true && !tcs.Task.IsCompleted)
            {
                tcs.SetException(new Exception("canceled"));
            }
        }, null);

}
}

When i load it, It gives me below error. Can you please let me know where am i going wrong.

image

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions