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

Web View in Windows Form not loading #5

Open
altafJebran opened this issue May 17, 2019 · 0 comments
Open

Web View in Windows Form not loading #5

altafJebran opened this issue May 17, 2019 · 0 comments

Comments

@altafJebran
Copy link

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!

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

1 participant