小编Jez*_*Jez的帖子

将IIS Web应用程序发布到网站根目录?

我正在尝试使用Web Deploy将Web应用程序导入IIS7.我使用Visual Studio的"发布Web"功能将其打包成ZIP文件,当我选择zip时,我会进入"应用程序包信息"屏幕.

它要求我的一个设置是"应用程序路径".如果我把它留空(所以它基本上只是说"我的网站/"),并尝试继续,IIS给我的消息:

此应用程序将安装到"我的网站"中.大多数应用程序通常安装在根目录下的文件夹中,例如"我的网站/博客".你确定吗?

我不明白为什么它会发出这个警告.我很想对这个对话框说"OK",但我想先检查一下 - 有什么明显我做错了吗?当然,如果我想我的web应用程序是整个网站,我将它安装到根或否则用户将始终具有访问http://host/MyAppDirectory/,而不只是http://host/-我为什么希望有不必要的后缀MyAppDirectory/?更好的做法是将应用程序安装到MyAppDirectory某个目录并以某种方式将其映射到网站根目录,或者只是将应用程序安装到网站根目录是否可以,尽管有警告?

另外,假设尽管有警告可以将应用程序安装到网站根目录,有没有办法从"应用程序包信息"屏幕中完全删除"应用程序路径"设置(和相关警告),并始终假设该应用程序应该安装到网站根目录?

deployment iis-7 web-applications visual-studio web

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

自定义与非自定义属性?

实现ICustomAttributeProvider接口的东西将允许您获取已通过该GetCustomAttributes方法应用于它的自定义属性.据我所知,自定义属性基本上是一个特殊的类(以"属性"结尾并扩展Attribute类),它是使用适当的语法([FooAttribute]在方法/类/等之前)应用于类似方法或类的类.例如,在C#中.但如果这是一个自定义属性,那么什么是非自定义属性?我曾经认为与.NET捆绑在一起的属性是非自定义的,但是GetCustomAttributes甚至会返回我的属性System.ThreadStaticAttribute,这些属性是.NET框架的核心.

是否存在非自定义属性,或者"自定义属性"只是一个重言式?

.net c# custom-attributes

8
推荐指数
2
解决办法
1106
查看次数

使用没有值的ng-app

通常,您会看到Angular在具有指令的页面上初始化ng-app="myModule",但它只对使用有效ng-app.但是,正如注册控制器这样的东西myModule,它是否真的有用ng-app呢?如果没有指定模块,有没有办法注册控制器等ng-app="..."

angularjs

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

HtmlHelper 的“ViewContext.Controller”发生了什么?

在我的旧 ASP.NET Web 应用程序中,我编写了一个 HTML 帮助程序,以通过访问以下内容来访问执行当前视图的控制器的上下文ViewContext.Controller

public static string GetControllerString(this HtmlHelper htmlHelper) {
    string controllerString = htmlHelper.ViewContext.Controller.ToString();
    return ".NET Controller: " + controllerString;
}
Run Code Online (Sandbox Code Playgroud)

然而,这似乎不再存在于 ASP.NET Core 的 HTML 帮助器对象中:

public static string GetControllerString(this IHtmlHelper htmlHelper) {
    string controllerString = htmlHelper.ViewContext.Controller.ToString(); // Doesn't exist!
    return ".NET Core Controller: " + controllerString;
}
Run Code Online (Sandbox Code Playgroud)

发生什么事了ViewContext.Controller?现在是否无法从 HTML 帮助器对象获取控制器上下文?

c# asp.net html-helper .net-core asp.net-core

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

如何在实体框架中设置两个一对多关系?

假设我们正在使用实体框架代码优先方法,并且我们有两个与两个一对多关系链接的对象(一个Person可以拥有多个Cars,但每个汽车都有一个所有者和'主驱动') .以下是两个实体:

public class Person {
    #region Persisted fields
    [Required]
    public int PersonId { get; set; }
    [Required]
    public string FirstName { get; set; }
    [Required]
    public string Surname { get; set; }
    #endregion

    #region Navigation properties
    public virtual ICollection<Car> CarsOwned { get; set; }
    #endregion
}

public class Car {
    #region Persisted fields
    [Required]
    public int CarId { get; set; }
    [Required]
    public string Make { get; set; }
    [Required]
    public string Manufacturer { get; …
Run Code Online (Sandbox Code Playgroud)

c# database entity-framework ef-code-first

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

cluster.fork()是否保证使用不同的CPU核心?

我已经看过一些关于在node.js中使用集群来使用所有CPU内核的教程,但它们似乎都暗示运行cluster.fork()将使用新的CPU内核; 例如:

if (cluster.isMaster) {
    cluster.setupMaster({
        exec: 'bin/www'
    });

    // Fork workers
    for (var i = 0; i < numCPUs; i++) {
        cluster.fork();
    }

    Object.keys(cluster.workers).forEach(function (id) {
        console.log('Worker id: ' + id + ' with pid: ' + cluster.workers[id].process.pid);
    });
}
Run Code Online (Sandbox Code Playgroud)

Node.js的文档是出奇的糟糕,并给出了很少的信息cluster.fork([env]):

产生一个新的工人流程.

这只能从主进程调用.

所以它说的是它产生了一个新的工人流程.我们怎么知道,这将在一个新的CPU核心来催生,如果我们产卵额外的过程,当我们已经有了对我们每个CPU核心中的至少一个过程中,会发生什么?

multithreading multicore node.js

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

在LINQ to Entities查询中调用自定义标量数据库函数?

有没有办法可以将自定义标量数据库函数称为LINQ to Entities查询的一部分?我在网上唯一能找到的就是这个页面:

https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ef/language-reference/how-to-call-custom-database-functions

但是,此处给出的说明似乎假设您使用的是DB-first方法并讨论修改.edmx文件.如果您使用代码优先方法呢?我希望能够写出这样的东西:

var result = await (
    from itm in _itemDataContext.Items
    where
        itm.QryGroup1 == "Y" &&
        _itemDataContext.Dbo_MyCustomScalarIntFn(itm.QryGroup2) > 0
).ToArrayAsync();
Run Code Online (Sandbox Code Playgroud)

c# linq sql-server entity-framework ef-code-first

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

System.Net.Http 的绑定重定向不起作用 - 为什么?

根据 NuGet 的说法,我正在处理的项目安装了 System.Net.Http 版本 4.3.3。它在 Web.config 文件中有一个绑定重定向,可以将其重定向到 4.2.0.0 版,这出于某种原因起作用:

<dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)

我将其更改为指向 4.3.3.0,这是 NuGet 所说的已安装版本:

<dependentAssembly>
    <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.3.3.0" newVersion="4.3.3.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)

...但现在当我尝试调试 ASP.NET 站点时出现此错误:

Could not load file or assembly 'System.Net.Http' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

=== Pre-bind state information ===
LOG: DisplayName = System.Net.Http
 (Partial)
WRN: Partial binding information …
Run Code Online (Sandbox Code Playgroud)

c# asp.net nuget

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

ENC1003 C# Changes made in project will not be applied while the application is running

I am getting this incredibly annoying warning for every C# file in my ASP.NET Core project when I debug it after hitting F5:

警告截图

Because this error appears only during runtime (not during build), I can't even suppress it using the "Suppress warnings" box in the project properties. I've tried putting 1003 and ENC1003 in there and it still appears, cluttering up my warnings window. Does anyone know why this thing is appearing and how I can get rid of it? …

c# warnings visual-studio asp.net-core visual-studio-2019

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

Visual Studio 如何加密 .pubxml.user 文件中的密码?

当您告诉 Visual Studio 保存发布配置文件的密码时,它会.pubxml.user在您的发布文件旁边创建一个文件,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <TimeStampOfAssociatedLegacyPublishXmlFile />
    <EncryptedPassword>AQAAANC[...]</EncryptedPassword>
  </PropertyGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)

Visual Studio 实际上如何加密元素中的密码EncryptedPassword?我想解密它,因为我忘记了密码......现在它只是加密存储在这个文件中!

encryption passwords visual-studio webdeploy visual-studio-2019

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