C# WPF WebBrowser控件未正确呈现App.net
我刚刚完成了一个库来访问App.net的所有方法,并且已经开始将它添加到我的客户端 但为了授权用户,我需要打开一个指向子页面的WebBrowser。但是app.net域中的每个url在我使用的WebBrowser控件中都呈现错误(我认为这主要是因为缺少CSS和一些JavaScript),因此我无法继续 有人知道我可以改变什么吗(已经玩过FullTrust)?在Internet Explorer中打开相同的页面效果很好 以下是我的简单测试窗口代码:C# WPF WebBrowser控件未正确呈现App.net,c#,css,wpf,browser,rendering,C#,Css,Wpf,Browser,Rendering,我刚刚完成了一个库来访问App.net的所有方法,并且已经开始将它添加到我的客户端 但为了授权用户,我需要打开一个指向子页面的WebBrowser。但是app.net域中的每个url在我使用的WebBrowser控件中都呈现错误(我认为这主要是因为缺少CSS和一些JavaScript),因此我无法继续 有人知道我可以改变什么吗(已经玩过FullTrust)?在Internet Explorer中打开相同的页面效果很好 以下是我的简单测试窗口代码: using System; using Syst
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Security.Permissions;
namespace NymphAppNetTester
{
/// <summary>
/// Interaction logic for BrowserTest.xaml
/// </summary>
///
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public partial class BrowserTest : Window
{
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public BrowserTest()
{
InitializeComponent();
buttonGo_Click_1(null, null);
}
private void buttonGo_Click_1(object sender, RoutedEventArgs e)
{
webbrowserTest.Navigate(textboxUrl.Text);
}
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Shapes;
使用System.Security.Permissions;
名称空间NymphAppNetTester
{
///
///BrowserTest.xaml的交互逻辑
///
///
[权限集(SecurityAction.Demand,Name=“FullTrust”)]
公共部分类BrowserTest:窗口
{
[权限集(SecurityAction.Demand,Name=“FullTrust”)]
公共浏览器测试()
{
初始化组件();
按钮单击按钮1(空,空);
}
私有无效按钮单击1(对象发送者,路由目标)
{
webbrowserTest.Navigate(textboxUrl.Text);
}
}
}
还有XAML
<Window x:Class="NymphAppNetTester.BrowserTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="BrowserTest" Height="478.723" Width="565.35">
<Grid>
<TextBox x:Name="textboxUrl" Height="23" Margin="10,10,58.2,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="http://www.app.net/"/>
<WebBrowser x:Name="webbrowserTest" Margin="10,38,10.2,10.4"/>
<Button x:Name="buttonGo" Content="Go" HorizontalAlignment="Right" Margin="0,11,10.2,0" VerticalAlignment="Top" Width="43" Click="buttonGo_Click_1"/>
</Grid>
</Window>
哦,安装了64位Windows 7和Internet Explorer 8(公司机器,无法升级到Internet Explorer 9)好的,在IE中找到了“怪癖模式”按钮,如果我按下它,Internet Explorer也会将其显示为错误。那么WebBrowser控件默认处于quirks模式!?即使像这里描述的那样戳注册表也不能正确地呈现给我:(好的,我有答案,但我自己不能把它作为答案发布。)(对于那些搜索相同答案的人:最终是解决方案-所以你需要在你的注册表中添加这样一个条目。我发现很多评论对此感到不安(为什么不在控件上设置属性!?)但这是唯一的解决方案。谢谢Microsoft。。。