在使用Windows 8而不是Windows 7时,Google Api Redirect在WP7上给出了404错误

cho*_*bo2 8 c# internet-explorer google-api windows-phone-7 internet-explorer-10

我一直在试图弄清楚为什么我有一个项目(我没有碰到的东西)不再工作了.

基本上我试图从谷歌联系人那里获取一些数据.当我在oAuth部分中选择"允许"时,它会继续给我404错误.这一切都在windows phone 7模拟器中完成.

然后我意识到我在我的Windows 8分区上,所以我回到我的Windows 7分区,它的工作原理.

想知道它是否是某些IE 10问题.任何人都有任何关于为什么会这样的理论?

编辑

这是一些快速的示例代码我掀起了可能有人可以尝试并告诉我发生了什么.

 string clientId = "You client id here";

        public MainPage()
        {
            InitializeComponent();

            string url = String.Format("https://accounts.google.com/o/oauth2/auth?scope=https://www.google.com/m8/feeds&redirect_uri=http://localhost&response_type=code&approval_prompt=auto&client_id={0}", clientId);
            webBrowser1.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(webBrowser1_Navigated);



            webBrowser1.Navigate(new Uri(url, UriKind.Absolute));




        }



        void webBrowser1_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
           var queryParmas = e.Uri.ParseQueryString();

           foreach (var item in queryParmas)
           {
               if (item.Key == "code")
               {
                   string test1 = "If you got here then it works";
                   string test2 = "in windows 8";

               }
           }
        }


    }
Run Code Online (Sandbox Code Playgroud)

XAML

 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <phone:WebBrowser HorizontalAlignment="Left" IsScriptEnabled="True" Name="webBrowser1" VerticalAlignment="Top" Height="669" Width="468" />
        </Grid>
Run Code Online (Sandbox Code Playgroud)

EDIT2

他们发布了适用于Windows 7的IE 10,所以我安装了它,它仍可在Windows 7上运行,因此我猜它不是IE问题.必须是Windows 8的东西?也许是吗?

EDIT3

以下是Windows 7中发生的事情

  1. 应用程序启动并加载MainPg.xmal
  2. 导航被触发但是如果语句被跳过
  3. 用户查看Google登录页面并输入信息并点击登录
  4. 导航被触发但是如果语句被跳过
  5. 用户看到"请求页面"并且必须允许应用程序权限
  6. 用户点击允许
  7. 导航被触发并进入"if"语句
  8. 用户看到IIS 7屏幕.

以下是Windows 8中发生的情况

  1. 应用程序启动并加载MainPg.xmal
  2. 导航被触发但是如果语句被跳过
  3. 用户查看Google登录页面并输入信息并点击登录
  4. 导航被触发但是如果语句被跳过
  5. 用户看到"请求页面"并且必须允许应用程序权限
  6. 用户点击允许
  7. 转到404页面未触发导航.

正如您所看到的,在按下允许按钮后,它会出错.在Windows 7中,它返回到Navigated方法,然后显示IIS 7欢迎页面,但是在允许按钮被点击后在Windows 8中,它不会转到导航页面而是显示404.

Jon*_*Jon 0

您应该使用“导航”事件处理程序,而不是“导航”事件处理程序。这将允许您在获取代码值时取消导航。导航处理程序在导航后调用,并且由于回调 url 并不真正存在,因此会抛出 404 错误。它似乎在您的 Windows 8 上运行正常,不知道为什么您在 Windows 7 上没有收到 404,因为您也应该在那里看到它。