小编Muh*_*eed的帖子

"B类不能是C的超级接口;超级接口必须是接口"错误

我们假设我有这个界面A:

interface A
{
    void doThis();
    String doThat();
}
Run Code Online (Sandbox Code Playgroud)

所以,我想要一些抽象类来实现方法doThis()而不是doThat()方法:

abstract class B implements A
{
    public void doThis()
    {
        System.out.println("do this and then "+ doThat());
    }

}

abstract class B2 implements A
{
    public void doThis()
    {
        System.out.println(doThat() + "and then do this");
    }
}
Run Code Online (Sandbox Code Playgroud)

当你最终决定在常规类中实现de doThat方法时会出现错误:

public class C implements B
{
    public String doThat()
    {
        return "do that";
    }
}
Run Code Online (Sandbox Code Playgroud)

这个课让我看到上面提到的错误:

"B类不能是C的超级接口;超级接口必须是接口"

如果这个类的层次结构有效或者我应该采取其他方式,那么现在任何人都可以吗?

java

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

ASP.NET Web API MVC 4中具有特殊字符的自定义参数名称

我需要创建一个Get方法,该方法在URL中采用以下参数名称:

ms-scale ms-contrast ms-lang

正如您所看到的,所有名称都有一个破折号,这在C#中是不可能的.如何将我的方法映射到这些参数名称?

public HttpResponseMessage Get(int scale, string contrast string lang)
Run Code Online (Sandbox Code Playgroud)

.net c# rest asp.net-mvc asp.net-web-api

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

Azure Active Directory应用程序密钥续订

在Azure Active Directory中配置应用程序时,您可以创建有效期为1年或2年的密钥.在拥有许多服务和客户的组织中,您如何管理密钥续订?

Azure Active Directory是否会在密钥到期时告诉您?有没有办法生成具有更长寿命甚至无限期寿命的密钥?

Azure Active Directory密钥持续时间

azure azure-active-directory

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

如何为所有用户静默安装 NSIS 可执行文件

我有一个 NSIS 安装程序可执行文件,我想为所有用户静默安装它。我知道我可以传递/S参数来进行静默安装。问题是安装程序的默认选项是仅为当前用户安装。如何从命令行更改此选项:

installer.exe /S
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

installation command-line windows-installer nsis silent-installer

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

筛选出ASP.NET Core API中的属性

我想在我的API中提供以下JSON:

{
  "id": 1
  "name": "Muhammad Rehan Saeed",
  "phone": "123456789",
  "address": {
    "address": "Main Street",
    "postCode": "AB1 2CD"
  }
}
Run Code Online (Sandbox Code Playgroud)

我想赋予客户端过滤掉他们不感兴趣的属性的能力。因此,以下URL返回JSON的子集:

`/api/contact/1?include=name,address.postcode

{
  "name": "Muhammad Rehan Saeed",
  "address": {
    "postCode": "AB1 2CD"
  }
}
Run Code Online (Sandbox Code Playgroud)

在ASP.NET Core中实现此功能的最佳方法是什么,以便:

  1. 该解决方案可以全局应用,也可以应用于单个控制器或类似过滤器的操作。
  2. 如果该解决方案使用反射,则还必须有一种方法可以通过为其提供一些代码以出于性能原因手动滤除属性来优化特定的控制器动作。
  3. 它应该支持JSON,但是很好地支持XML等其他序列化格式。

我发现这个解决方案,它使用了自定义JSON.Net ContractResolver。可以通过将合同解析器添加到ASP.Net Core使用的默认合同解析器中来全局应用该合同解析器,也可以将其手动添加到此代码示例之类的单个操作中,而不是添加到控制器中。另外,这是JSON特定的实现。

asp.net json json.net asp.net-core asp.net-core-1.0

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

在 ASP.NET Core 中注册子 IOptions

我有以下配置设置:

public void ConfigureServices(IServiceCollection services)
{
    var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
    services.Configure<AppSettings>(configuration);
}

public class AppSettings
{
    public ChildSettings Child { get; set; }

    public string Property { get; set; }
}

public class ChildSettings
{
    public string ChildProperty { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我的 appSettings.json 如下所示:

{
    "Child": {
        "ChildProperty": "Value"
    }
    "Property": "Value"
}
Run Code Online (Sandbox Code Playgroud)

我可以IOptions<AppSettings>很好地注入我的控制器:

public class MyController : Controller
{
    public MyController(IOptions<AppSettings> options)
    {
        ChildSettings appSettings = options.Value;
    }
}
Run Code Online (Sandbox Code Playgroud)

它有点旧了,必须下降几个级别才能到达您想要的设置对象。有没有一种方法可以IOptions<ChildSettings>像这样使用:

public class …
Run Code Online (Sandbox Code Playgroud)

asp.net configuration asp.net-core-mvc asp.net-core

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

如何阻止Azure IIS附加错误状态代码查询字符串

我在web.config文件中进行了以下设置来处理错误:

<httpErrors errorMode="Custom" existingResponse="Replace">
  <remove statusCode="500" />
  <error statusCode="500" responseMode="ExecuteURL" path="/error/internalservererror/" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)

当我在我的应用程序中抛出异常时,它在本地工作正常,但它重定向到azure中错误页面中的以下URL(请注意,我抛出异常的页面位于URL的末尾:

https://example.com/error/internalservererror/?500;https://example.com/error/internalservererror/?500;https://example.com/error/internalservererror/?500;https://example的.com /错误/ internalservererror/500; HTTPS:?//example.com/error/internalservererror/ 500; HTTPS:?//example.com/error/internalservererror/ 500; HTTPS:?//example.com/error/ ?internalservererror/500; HTTPS://example.com/error/internalservererror/ 500; HTTPS:?//example.com/error/internalservererror/ 500; HTTPS:?//example.com/error/internalservererror/ 500; https://example.com/error/internalservererror/?500;https://example.com/error/internalservererror/?500;https://example.com/error/internalservererror/?500;https://example的.com /错误/ internalservererror/500; HTTPS:?//example.com/error/internalservererror/ 500; HTTPS:?//example.com/error/internalservererror/ 500; HTTPS:?//example.com/error/ ?internalservererror/500; HTTPS://example.com/error/internalservererror/ 500; HTTPS:?//example.com/error/internalservererror/ 500; HTTPS:?//example.com/error/inter ?nalservererror/500; HTTPS://example.com/error/internalservererror/ 500; HTTPS:?//example.com/about/

如何阻止IIS在Azure中检测此行为?

iis asp.net-mvc azure http-error azure-web-sites

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

使用 .NET Core csproj VS 2017 工具最小化引用

我有发布到 NuGet 的 .NET Core 类库。将它们升级到 VS 2017 csproj 格式后,它们具有以下签名。

<Project Sdk="Microsoft.NET.Sdk">
  ...
</Project>
Run Code Online (Sandbox Code Playgroud)

添加Microsoft.NET.Sdk似乎添加了对一组基本库的引用。但是,作为图书馆作者本人,我可能只想引用最少的引用集。这是否仍然正确,如果是,如何实现?

看看 ASP.NET Core 和 Entity Framework Core 项目,它们似乎使用Microsoft.NET.Sdk而不是单独选择它们需要的包。

更新

我在 GitHub 上提出了问题dotnet/cli #5994,@davidfowl 说:

新指南是始终作为包作者引用 NETStandard.Library。

但是,他没有详细说明为什么?

msbuild csproj .net-core asp.net-core visual-studio-2017

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

在Azure Active Directory中删除应用程序的AppRole

从应用程序清单中删除AppRole会产生400错误请求,并显示错误消息

除非先禁用属性值,否则不能将其删除。

当我将isEnabled属性设置为false并单击保存时,通过查看浏览器开发人员工具,可以得到200 OK的成功保存:

之前

重新加载“编辑清单”屏幕后,该isEnabled属性仍然true保持不变,如果您在浏览器开发人员工具中查看PUT响应,则该属性也将返回true

后

如何删除一个appRole,而不必删除并重新创建整个应用程序?

更新资料

我提出了以下错误

azure azure-active-directory azure-ad-graph-api azure-ad-powershell-v2

5
推荐指数
3
解决办法
3525
查看次数

为什么 ASP.NET Core Multi-Stage Dockerfile 使用 4 Stages

当您在 ASP.NET Core 站点上的 Visual Studio 中单击“添加 Docker 支持”时,这是默认的多阶段 Dockerfile。

FROM microsoft/aspnetcore:2.0 AS base
WORKDIR /app
EXPOSE 80

FROM microsoft/aspnetcore-build:2.0 AS build
WORKDIR /src
COPY WebApplication1.sln ./
COPY WebApplication1/WebApplication1.csproj WebApplication1/
RUN dotnet restore
COPY . .
WORKDIR /src/WebApplication1
RUN dotnet build -c Release -o /app

FROM build AS publish
RUN dotnet publish -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "WebApplication1.dll"]
Run Code Online (Sandbox Code Playgroud)

为什么他们选择使用四个阶段,开始和结束base阶段。另外,为什么要publish使用相同的build基本图像创建舞台。为什么 Dockerfile 看起来不像三个阶段:

FROM microsoft/aspnetcore-build:2.0 …
Run Code Online (Sandbox Code Playgroud)

docker dockerfile asp.net-core docker-multi-stage-build

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