相关疑难解决方法(0)

如何指定托管ASP.NET Core应用程序的端口?

当使用WebHostBuilder在一个Main入口点,我怎么可以指定它绑定到端口?

默认情况下,它使用5000.

请注意,此问题特定于新的ASP.NET Core API(当前位于1.0.0-RC2中).

.net asp.net-core

137
推荐指数
11
解决办法
11万
查看次数

如何在AWS Linux实例上运行.NET Core MVC站点

我想从AWS Amazon Linux AMI实例运行.NET Core MVC网站.

以下是我到目前为止采取的步骤:

  1. 在Visual Studio 2015中创建模板ASP.NET核心Web应用程序(.NET核心) - C# - MVC Web应用程序项目.在IIS Express中编译并运行应用程序.没有对任何配置进行任何更改(web.confg,project.json等).
  2. 将整个Web应用程序解决方案上传到GitHub.
  3. 启动Amazon Linux AMI(2016.03.2)实例.为简单起见,安全组现在打开"所有流量"访问权限.
  4. 使用PuTTY SSH进入Linux实例.使用ec2-user登录.
  5. 更新实例 sudo yum update -y
  6. 安装libunwind sudo yum install libunwind -y
  7. 安装gettext sudo yum install gettext -y
  8. 安装.NET Core curl -sSL https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview1/scripts/obtain/dotnet-install.sh | bash /dev/stdin --version 1.0.0-preview1-002702 --install-dir ~/dotnet
  9. 链接 sudo ln -s ~/dotnet/dotnet /usr/local/bin
  10. 安装.NET版本管理器(DNVM) curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
  11. 运行命令 source /home/ec2-user/.dnx/dnvm/dnvm.sh
  12. 安装 …

linux amazon-ec2 asp.net-core-mvc kestrel-http-server

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

无法从命令行更改Kestrel监听端口

我有以下入口点:

public static void Main(string[] args)
{
    var config = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("hosting.json", optional: true)
        .AddCommandLine(args)
        .AddEnvironmentVariables()
        .Build();

    var host = new WebHostBuilder()
        .UseConfiguration(config)
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseIISIntegration()
        .UseStartup<Startup>()
        .Build();

    host.Run();
}
Run Code Online (Sandbox Code Playgroud)

如果我添加hosting.json文件,例如

{
  "server.urls": "http://0.0.0.0:5001"
}
Run Code Online (Sandbox Code Playgroud)

或者如果我定义环境变量(在这里找到名称)

SET ASPNETCORE_URLS=https://0.0.0.0:5001
Run Code Online (Sandbox Code Playgroud)

但是,如果我--server.urls http://0.0.0.0:5001作为参数传递,则应用程序将监听默认的5000端口:

> dotnet run --server.urls http://0.0.0.0:5001
...
Now listening on: http://localhost:5000
Run Code Online (Sandbox Code Playgroud)

kestrel-http-server asp.net-core

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

ASP.NET 5 Kestrel在LAN内连接

我想连接到我的Kestrel服务器,其中托管的ASP.NET 5应用程序来自同一网络中的另一台PC.可能吗?我可以从cmd ping我的电脑,但当我尝试从网络浏览器连接时,我得到'连接超时'(我输入:"http:// {my_kestrel_ip}:5000 /").

c# asp.net-mvc kestrel-http-server

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

如何配置IdentityServerAuthenticationOptions.Authority以使用通配符

我成功使用ASP.NET Core设置了IdentityServer4。

作为默认配置,我有这个:

IdentityServerAuthenticationOptions options = new IdentityServerAuthenticationOptions()
{
    Authority = "http://localhost:5000",                
    ScopeName = "scope",
    ScopeSecret = "ScopeSecret",
    AutomaticAuthenticate = true,
    AutomaticChallenge = true,
    RequireHttpsMetadata = false,                
};
Run Code Online (Sandbox Code Playgroud)

现在,使用本指南,我配置为从配置文件中读取数据,因此它们可以是生产中的任何数字。

例如,如果我将API设置为在上运行,http://*:5000则客户端可以通过服务IP地址(例如)连接到它http://192.168.1.100:5000

一旦客户端获得Bearer令牌并尝试使用它,Internal Server Error就会发生此异常:

Unable to obtain configuration from: 
'http://*:5000/.well-known/openid-configuration'. 
---> System.IO.IOException: IDX10804: Unable to retrieve document from: 'http://*:5000/.well-known/openid-configuration'. 
---> System.UriFormatException: Invalid URI: The hostname could not be parsed.
Run Code Online (Sandbox Code Playgroud)

将IdS4配置为具有动态权限的正确方法是什么?

更新资料

看来问题出在发行人身上,对此有什么想法吗?

Microsoft.IdentityModel.Tokens.SecurityTokenInvalidIssuerException: 

IDX10205: Issuer validation failed. Issuer: 'http://192.168.1.100:5000'. Did not match: validationParameters.ValidIssuer: …
Run Code Online (Sandbox Code Playgroud)

identityserver4 asp.net-core-webapi

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