小编Rop*_*tah的帖子

.NET Application_BeginRequest - 如何获取用户参考?

我正在尝试在Global.asax文件中获取对用户对象的引用Application_BeginRequest.我正在使用该物业,Context.User但我得到了NullReferenceException.是否可以在Application_BeginRequest中获取用户对象引用?

asp.net global-asax

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

jQuery javascript自定义排序程序在Firefox中有效,但IE似乎没有得到它...(复制粘贴示例代码)

我根据应用程序中的实际问题构建了此示例代码.我有一个自定义排序过程来排序jQuery数组.容器包含具有特殊属性的项列表.

用于分类:

  1. 加载临时数组中的所有项目
  2. 清除容器
  3. 将临时数组排序为新数组
  4. 将已排序的项目附加到容器

不知何故,Firefox知道如何排序,但IE不知道.有人能告诉我什么不能正常工作吗?

(你可以将下面的html复制粘贴到一个空的.html文件中,它应该立即工作)

<html>
<head>
<script type="text/javascript" 
    src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
    jQuery.fn.sort = function() {  
        return this.pushStack( [].sort.apply( this, arguments ), []);  
    } 

    function DoTheSort() {
        //Fetch elements in jQueryElement
        var sortableArray = $('#sortables').find('div.sortable');

        //Clear the sortables container
        $('#sortables').empty();

        //Sort the array
        var sortedArray = $(sortableArray).sort(sortProcedure);

        //Append sorted items
        jQuery.each(sortedArray, function() {
            alert($(this).attr("sortvalue"));
            $('#sortables').append(this);                
        });
    }

    function sortProcedure(a, b) {
    var value1 = parseInt($(a).attr("sortvalue"));
    var value2 = parseInt($(b).attr("sortvalue"));
        return value1 > value2;
    }


    </script>
</head> …
Run Code Online (Sandbox Code Playgroud)

javascript sorting jquery cross-browser

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

我应该在变量中缓存document.getElementById()还是每次都调用它?

我有很多次生成和引用的元素(鼠标悬停,点击,位置变化).

我手头有这些元素的ID.将document.getElementById(ID)调用存储在变量中是否明智,还是更快/ document.getElementById()每次调用更快/更慢?

var app = [];
var app.elements = []; 
//i can store ['id1', 'id2', 'id3']
//OR ['id1' => document.getElementById('id1'), 'id2' => document.getElementById('id2'), 'id3' => document.getElementById('id3')]
Run Code Online (Sandbox Code Playgroud)

javascript memory performance caching

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

无法在Windows Server 2016上运行.NET Core 2.1(.1)应用程序

我正在尝试在Windows Server 2016实例上运行.NET Core应用程序.它在我的Windows 10机器上构建/运行良好.

首先,我正在做dotnet publish,我将发布的网站复制到Windows Server实例.我按照本指南安装了主机软件包以及最新的SDK(2.1.3).

但是当我尝试dotnet myapp.dll收到以下错误消息时:

It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.All', version '2.1.1' was not found.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet\
  - Installing .NET Core prerequisites might help resolve this problem:
      http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
  - The following …
Run Code Online (Sandbox Code Playgroud)

windows-server-2016 asp.net-core asp.net-core-2.1

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

Visual Studio项目模板$ safeitemname $无法按预期工作

我正在创建一个Visual Studio Item模板来创建一些依赖于'容器'文件的文件.

最后一个文件<ProjectItem SubType="Code" TargetFileName="$fileinputname$\I$fileinputname$ View.cs" ReplaceParameters="true">Container View.cs</ProjectItem>创建一个需要特定模型类型的视图接口.但是$safeitemname$参数没有像我预期的那样工作.

输出容器View.cs文件:

public interface IIMy_Triplet_View : IView<IMy_Triplet_View_Model>
{
}
Run Code Online (Sandbox Code Playgroud)

预期:

public interface IMy_Triplet_View : IView<My_Triplet_Model>
{
}
Run Code Online (Sandbox Code Playgroud)

这是Container View.cs模板的源代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebFormsMvp;

namespace $rootnamespace$
{
    public interface $safeitemname$_View : IView<$safeitemname$_Model>
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

和.vstemplate文件

    <VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
      <TemplateData>
        <DefaultName>Model-View-Presenter</DefaultName>
        <Name>Model-View-Presenter</Name>
        <Description>Creates a model-view-presenter triplet</Description>
        <ProjectType>CSharp</ProjectType>
        <SortOrder>10</SortOrder>
        <Icon>__TemplateIcon.png</Icon>
        <PreviewImage>__PreviewImage.png</PreviewImage>
      </TemplateData>
      <TemplateContent>
        <References>
          <Reference>
            <Assembly>WebFormsMvp</Assembly>
          </Reference>
        </References>
        <ProjectItem SubType="Code" …
Run Code Online (Sandbox Code Playgroud)

c# parameters visual-studio visual-studio-templates

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

ASP.NET成员资格 - 使用哪个RoleProvider User.IsInRole()检查ActiveDirectory组?

实际上很简单的问题:

我目前禁用了IIS匿名访问,用户使用Windows登录自动登录.但是,调用User.IsInRole("Role name")将返回false.我仔细检查了User.Identity.Name()和"角色名称",它应该返回true.

我目前在我的Web.Config中有这个:

更新
我正在调用User.IsInRole("角色名称"),我应该调用User.IsInRole("DOMAIN\Role name")

但是我仍然想知道是否需要<membership>条目?

我应该改变什么?(是否需要<membership>条目?)

  <authentication mode="Windows">
      <forms
      name=".ADAuthCookie"
      timeout="10" />
  </authentication>


<membership defaultProvider="ADMembershipProvider">
  <providers>
    <clear/>
      <add
         name="ADMembershipProvider"
         type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
         connectionStringName="ADConnectionString"
         connectionUsername="XXX\specialAdUser"
         connectionPassword="xx"
         />
  </providers>
</membership>

<roleManager enabled="true" defaultProvider="WindowsProvider">
  <providers>
    <clear />
      <add name="WindowsProvider" type="System.Web.Security.WindowsTokenRoleProvider" />
  </providers>
</roleManager>
Run Code Online (Sandbox Code Playgroud)

asp.net authentication roles active-directory active-directory-group

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

如何让SQL Server找到与提供的名称匹配的登录名?

我刚刚将数据库备份恢复到本地SQL Server Express实例.

  1. 在服务器实例节点下的管理工作室中,我去了:安全 - >登录 - >新登录...
  2. 然后我填写了登录名,密码并选择了SQL Server身份验证.在底部,我选择新恢复的数据库作为默认数据库.
  3. 在左侧的User Mapping'选项卡'中,我将用户映射到新恢复的数据库并赋予其"db_owner"角色.

当我尝试登录时,日志中给出了以下错误:

用户'用户名'登录失败.原因:找不到与提供的名称相匹配的登录信息.[客户:]

如何让SQL Server找到与我提供的名称相匹配的登录名?

其他信息:

  • 命名管道已启用
  • TCP/IP已启用
  • 允许远程连接

login sql-server-express sql-server-2008

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

为什么在此运算符定义中抛出stackoverflowexception?

请在下面的代码中查看我的评论.我应该如何检查参数null?它看起来像null被转换为Foo基本上使递归调用==操作符.为什么会这样?

public class Foo
{
    public static bool operator ==(Foo f1, Foo f2)
    {
        if (f1 == null) //This throw a StackOverflowException
            return f2 == null;
        if (f2 == null)
            return f1 == null;
        else
            return f1.Equals((object)f2);
    }

    public static bool operator !=(Foo f1, Foo f2)
    {
        return !(f1 == f2);
    }

    public override bool Equals(object obj)
    {
        Foo f = obj as Foo;
        if (f == (Foo)null)
            return false;

        return false; …
Run Code Online (Sandbox Code Playgroud)

.net c# stack-overflow operator-overloading

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

PHP - rand(1,1000)= 1000可能与rand(1,1000)= rand(1,1000)?

这是PHP实现随机数生成的方式吗?

说我想计算是或否.每次我有一定的概率百分比(例如:这个例子为0,05%).

我做:

$possibilities = 100 / $probabilityPercentage; //$possibilities = 2000
$yes = rand(1,$possibilities);

$yesCheck = $possiblities;            //OPTION 1
$yesCheck = rand(1,$possibilities);   //OPTION 2


($yesCheck == $yes) ? return true : return false;
Run Code Online (Sandbox Code Playgroud)

两种选择都能给出相同的结果吗?

php random

7
推荐指数
2
解决办法
2300
查看次数

什么是iPad2 User-Agent字符串?

有谁知道刚刚发布的iPad2的用户代理字符串?

user-agent ipad ipad-2

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