Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何远程访问Asp.net core Mvc 5中的Kestrel?_C#_Asp.net Core_Networking_Localhost_Kestrel Http Server - Fatal编程技术网

C# 如何远程访问Asp.net core Mvc 5中的Kestrel?

C# 如何远程访问Asp.net core Mvc 5中的Kestrel?,c#,asp.net-core,networking,localhost,kestrel-http-server,C#,Asp.net Core,Networking,Localhost,Kestrel Http Server,我是asp.net核心的新手,最近我用这个框架创建了一个新项目 我的问题是我无法使用另一台机器的ip地址访问应用程序。我在防火墙中创建了规则,在计算机中打开了5001端口,并在路由器设置中定义了DMZ 当我使用ApacheWeb服务器处理来自internet和局域网的请求时,请求会发送到我的计算机,但如果我使用kestrel,我无法打开我的webapp的简介页面 例如,我的静态ip地址和端口是:123.234.456.567:5001 当我运行ApacheWeb服务器并在手机浏览器中键入此地址时

我是asp.net核心的新手,最近我用这个框架创建了一个新项目

我的问题是我无法使用另一台机器的ip地址访问应用程序。我在防火墙中创建了规则,在计算机中打开了5001端口,并在路由器设置中定义了DMZ

当我使用ApacheWeb服务器处理来自internet和局域网的请求时,请求会发送到我的计算机,但如果我使用kestrel,我无法打开我的webapp的简介页面 例如,我的静态ip地址和端口是:123.234.456.567:5001 当我运行ApacheWeb服务器并在手机浏览器中键入此地址时,我可以看到xampp的简介页面 但当我运行kesterl服务器时,页面不会加载

这是我的应用程序中的代码: 这是program.cs中的代码:

    public class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseKestrel();
                webBuilder.UseContentRoot(Directory.GetCurrentDirectory());
                webBuilder.UseIISIntegration();
                webBuilder.UseUrls("http://*:5001");
                webBuilder.ConfigureKestrel(options => { options.ListenAnyIP(5001);});
                webBuilder.UseStartup<Startup>();
            });
}
下面是launchSetting.json文件:

{
“iisSettings”:{

},, “概况”:{

您可以检查以下内容:
{
"windowsAuthentication": false,

"anonymousAuthentication": false,

"iisExpress": {

  "applicationUrl": "http://localhost:54405",

  "sslPort": 0

}
"IIS Express": {

  "commandName": "Project",

  "launchBrowser": true,

  "environmentVariables": {

    "ASPNETCORE_ENVIRONMENT": "Development"

  },

  "ancmHostingModel": "InProcess"

},
"Event_Creator": {

  "commandName": "Project",

  "launchBrowser": true,

  "environmentVariables": {

    "ASPNETCORE_ENVIRONMENT": "Development"

  },

  "dotnetRunMessages": "true",

  "applicationUrl": "http://0.0.0.0:5001/"
}}}