6

Hi I am Working on a WPF application where in i have a WPF Browser control which navigates to url "http:...." which takes windows credentials.

Issue Is: when i copy paste the URL it simply performs authentication and works fine. But when naviating from WPF Web browser it is not picking up the Windows creds.

 public void StartNavigation()
        {
            if (!String.IsNullOrEmpty(URL) && webBrowser.Source == null)
                webBrowser.Navigate(new Uri(URL));
        }

<UserControl x:Class="Slb.iDistrict.Prism.Module.JobEmbeddedBrowser.View.JobEmbeddedBrowserView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d" Loaded="UserControl_Loaded"
         d:DesignHeight="300" d:DesignWidth="300">
<Grid>
    <WebBrowser Name="webBrowser"/>
</Grid>

UserControl_Loaded> Event will call the StartNavigation() method. my Url looks like this: "http://www.test.cmp.com/App/Login/SingleSignon.aspx?Screen=sample&BL=cc&JN=12345" When i Do Navigate my Browser.Source is reset to some default.aspx page of the site. I assume that it is because of failure in getting Windows authentication information. I tried to find some help online but not found appropriate results.

What and Where is the issue?

Maverik
  • 5,619
  • 35
  • 48
WPFKK
  • 1,419
  • 3
  • 20
  • 42
  • Provide code, otherwise we cannot tell you "What and Where the issue is" – Dom Sep 17 '13 at 02:11
  • There is no much Code Dom except that the requested Uri and on UserControl Loaded event I call WebBrowser.NavigateUri() – WPFKK Sep 17 '13 at 02:18
  • I don't understand why you have all sorts of conflicting tags on this? Judging by code, this is clearly WPF. I'm removing other tags but feel free to drop a comment if you have a reason to have the change reverted. – Maverik Sep 19 '13 at 15:51
  • @Maverik Code is WPF but the underlying browser control is same as winforms browser. Hence added those tags in case if somebody have faced similar issue in other environment – WPFKK Sep 20 '13 at 15:55
  • Does the same page work in IE (if possible to test at all)? – noseratio Sep 22 '13 at 13:32
  • Noseratio: yes it works simply fine in IE. Also I ran a test using Winforms browser in WPF it works perfectly fine. What could be the reason for WPF browser to fail? – WPFKK Sep 22 '13 at 23:44
  • 1
    @user841612 yes I'm aware of it but chances of a winforms solution applying to wpf are very slim. Is it a requirement to use this wrapper? Have you considered Awesomium (.net wrapper around chromium)? – Maverik Sep 23 '13 at 10:23
  • I am not familiar about awesomium, Also the wrapper is the temp solution for now. But should fix it permanantly – WPFKK Sep 23 '13 at 17:24
  • @user841612, try implementing [WebBrowser Feature Control](http://stackoverflow.com/a/18802626/1768303). – noseratio Sep 24 '13 at 01:59
  • Noseratio: I implemented the feature but no use. Actually i was looking at all the features/keys given there but none reflects my setting or I am not sure what to set. One thing i found is Web socket Authentication prompt which doesnot work fine. I am using IE 8 and the site says about IE 10 will it still work? – WPFKK Sep 24 '13 at 14:51
  • Use `8000` for `FEATURE_BROWSER_EMULATION` under IE8. Also, have you tried it with IE9/10? It could be just an IE8 bug, after all. – noseratio Sep 25 '13 at 03:51
  • 4
    Try to set principal in the UI thead. Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent()) – jlvaquero Sep 25 '13 at 12:37
  • 1
    WPF WebBrowser may be the worst built in WPF control. I'll second Maverik and suggest using a real control like the Awesomium web browser. – Sisyphe Sep 26 '13 at 11:41

1 Answers1

0

WPF Web Browser has bug: it ignores URL part after '#'. Maybe auth service redirects you to the page with '#' in url and this redirection fails. For example authentication in vk.com is not working.

Mikhail Gubanov
  • 420
  • 6
  • 13