小编Jor*_*dan的帖子

错误请求仅在远程计算机上使用IE 11返回,用于传递凭据的XHR

我一直在试图弄清楚在将XHR制作成需要Windows身份验证的MS Web API时我缺少的部分.

此请求适用于Chrome和IE 11以及远程控制台(不是服务器)上的Chrome.问题是远程盒子上的IE 11.

根据开发工具,IE提出了3个请求.前两个请求通过授权:Negotiate标头并返回401s(CORS的预检?).但是,第三个返回400.它似乎无法以我不理解的方式进行身份验证,特别是因为其他浏览器和本地测试工作.

API是一个自托管的OWIN控制台应用程序.这是创业公司:

public void Configuration(IAppBuilder appBuilder)
{
    appBuilder.UseCors(CorsOptions.AllowAll);

    var listener = (HttpListener)appBuilder.Properties["System.Net.HttpListener"];

    if (listener != null)
    {
        listener.AuthenticationSchemeSelectorDelegate = request =>
        {
            if (string.Compare(request.HttpMethod, "OPTIONS", StringComparison.OrdinalIgnoreCase) == 0)
            {
                return AuthenticationSchemes.Anonymous;
            }
            else
            {
                return AuthenticationSchemes.IntegratedWindowsAuthentication;
            }
        };
    }

    var config = new HttpConfiguration();
    config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{action}/{id}", new { id = RouteParameter.Optional });
    appBuilder.UseWebApi(config);
}
Run Code Online (Sandbox Code Playgroud)

这是客户端XHR调用:

var request = new XMLHttpRequest();
request.open('GET', 'http://xxxx:9000/api/test/something', true);
request.timeout = 10000;
request.withCredentials = true;
request.onload = function() {
    if …
Run Code Online (Sandbox Code Playgroud)

c# ajax internet-explorer

6
推荐指数
1
解决办法
642
查看次数

AutomationElement.FindAll() 性能问题

我们一直在使用 MS UIA 框架,并注意到在 Windows 10 / .NET 4.6 中查找对象集合时出现的明显放缓。

在 Windows 10 / .NET 4.6 机器上测试 AutomationElement.FindAll() 时,与在 Windows 8.1 / .NET 4.5.1 机器上查找完全相同的元素相比,我们查找元素集合的平均时间大约长 3 到 5 倍. 我的测试是针对 WPF DataGrid 进行虚拟化(使用回收)并获取 DataGrid 每一行内的所有单元格。

在我们的 Win10 机器上,每次 FindAll 调用获取每行中的单元格大约需要 30 - 50 毫秒甚至更长的时间。在 Win8.1 机器上,大约需要 5 - 10 毫秒。我不知道为什么,但我不认为这个问题仅限于 DataGrid,因为我们的 FindAll() 调用没有什么特别之处。

        //get grid
    AutomationElement gridElement = AutomationElement.RootElement.FindFirst(TreeScope.Descendants,
           new PropertyCondition(AutomationElement.AutomationIdProperty, "dataGridAutomationId"));

    //get all visible rows
    AutomationElementCollection dataItems = gridElement.FindAll(TreeScope.Descendants,
                       new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem));

 foreach (AutomationElement dataItem in dataItems)
 {
    if …
Run Code Online (Sandbox Code Playgroud)

c# ui-automation microsoft-ui-automation

5
推荐指数
1
解决办法
5825
查看次数

在javascript中访问ASP HiddenField

我一直在这里搜索和谷歌几天,试图弄清楚为什么我不能在javascript中获得隐藏字段变量的值.访问时,该值将返回undefined.
我在UpdatePanel中有一个ASP HiddenField,它是.aspx网页中自定义用户控件的一部分(标准问题).

在我的用户控件中,我需要在C#中设置后在javascript中获取HiddenField(hdnServer)的.Value.但由于某种原因,以下内容没有得到正确的值.

C#代码中的MessageBox返回正确的值(此处的代码具有测试值),但是在javascript中访问时未定义.

userControl.ascx:

//this function is called when the timer created in document.ready() elapses
//returns the correct hdnServer value in the check. 
    var checkHdn = function () {
        var temp = document.getElementById("<%=hdnServer.ClientID%>").value;
        temp = temp.toString();
        if (temp != "") {
            $('#LoadingViewer').hide();
            clearInterval(checkSrv);

            //enable start button
            $('#startBtn').attr("Enabled", "true");
        }
    };

  function RdpConnect() {

                //serverName = undefined here.  should be ip address when set in c# 
                var serverName = document.getElementById("<%= hdnServer.ClientID %>").value;
                alert(serverName);
                if (serverName != "") {
                    MsRdpClient.Server …
Run Code Online (Sandbox Code Playgroud)

javascript c# asp.net

3
推荐指数
1
解决办法
2万
查看次数

LongListSelector - 值不在预期范围内

我已经将应用程序从wp7升级到8,现在正在获取System.ArgumentException"值不在预期范围内." 应用程序在退出为LongListSelector控件设置ItemsSource的方法后抛出异常.ExceptionObject中没有StackTrace,这在wp7中没有任何问题.

作为测试,我在应用程序的Loaded事件中完成了以下操作:

 private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
        {
            List<string> test = new List<string>();
            test.Add("hi");
            BrowseListBox.ItemsSource = test;
        }
Run Code Online (Sandbox Code Playgroud)

方法完成后,抛出异常.

这是我的LongListSelector的XAML.TextBlock Text属性以前是Binding,但已被静态值替换,直到我开始工作.

<phone:LongListSelector Name="BrowseListBox" IsGroupingEnabled="True" LayoutMode="Grid">
                    <phone:LongListSelector.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Margin="0,0,0,17">
                                <TextBlock Text="test" TextWrapping="Wrap" FontSize="29" Tap="TextBlock_Tap_1" />
                            </StackPanel>
                        </DataTemplate>
                    </phone:LongListSelector.ItemTemplate>
                    <phone:LongListSelector.GroupHeaderTemplate>
                        <DataTemplate>
                            <Border>
                                <TextBlock Text="test" FontSize="32" Foreground="White"  />
                            </Border>
                        </DataTemplate>
                    </phone:LongListSelector.GroupHeaderTemplate>
                    <phone:LongListSelector.JumpListStyle>
                        <Style TargetType="phone:LongListSelector">
                            <Setter Property="ItemTemplate">
                                <Setter.Value>
                                    <DataTemplate>
                                        <Border Name="JumpListBorder" BorderThickness="0,0,0,1">
                                            <TextBlock Text="test" FontSize="50" Foreground="White"  />
                                        </Border>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </phone:LongListSelector.JumpListStyle>
                </phone:LongListSelector>
Run Code Online (Sandbox Code Playgroud)

谁看过这个吗?

windows-phone-7 longlistselector windows-phone-8

2
推荐指数
1
解决办法
2117
查看次数

论证从右到左阅读

我正在学习缓冲区溢出是如何工作的,并且遇到了我不理解的事情.

我试图通过缓冲区溢出更改函数指针的地址,并将参数传递给从Perl脚本运行的可执行文件.我的问题是,为什么Perl似乎从右到左阅读我的地址论点?

Perl的:

$arg = "AAAAAAAAAA"."\x40\x11\xc4";  //string with address to malicious test function
$cmd = "./bo_test ".$arg;
system($cmd);
Run Code Online (Sandbox Code Playgroud)

输入的地址是打印输出时该功能的确切地址.但是,为了通过溢出调用测试函数,我需要输入"\ xc4\x11\x40".

如果我指向C中的地址,它会接受我期望的输入:

//call function based on address pointer_fn
desired_fn = ( void (*)())0x4011c4; //when run desired_fn runs the malicious test method
Run Code Online (Sandbox Code Playgroud)

有人可以解释为什么Perl这样做(或者我做错了导致它)?

如果它有帮助,我使用strcopy()来复制参数并在我的exe中启动溢出.

c perl

2
推荐指数
1
解决办法
74
查看次数

C - char*为空?

这可能很简单,但我无法弄清楚为什么我无法从这个char*中获取值.

这是我的问题:

static char* DIR_ENTRY_PATH = NULL;
Run Code Online (Sandbox Code Playgroud)

...

while (1) // infinite loop

    {

      // accept a client connection 

      clientFd = accept (serverFd, clientSockAddrPtr, &clientLen);

      if (fork() == 0) // Create child proc to get dir entry info 

        {

          //read dir entry info     
readInfo(clientFd);
printf("dpath: %s\n", DIR_ENTRY_PATH); //prints out the the correct value (DIR_ENTRY_PATH set in readInfo)
int test = 1;
      //get dir entry info and write back
      DIR *dir;
      struct dirent *entry; //pointer to dir entry
      struct stat stbuf; …
Run Code Online (Sandbox Code Playgroud)

c

1
推荐指数
1
解决办法
253
查看次数