简体   繁体   English

ASP.NET核心部署应用程序失败

[英]ASP.NET Core Deploying App Fails with Apache

I'm currently trying to learn ASP.NET Core it's really awesome so far :) I've installed the Core Runtime and everything else needed to run a WebApp, what I'm struggling the last couple hours is, that I only can access the WebApp when I use the Port in the URL like http://ip:5000 but when I try it like this http://ip/WebApp I'm getting a 404 Error. 我目前正在尝试学习ASP.NET Core它到目前为止真的棒极了:)我已经安装了Core Runtime以及运行WebApp所需的一切,我在过去几个小时里遇到的困难是,我只能访问当我在URL中使用像http://ip:5000这样的端口时的WebApp但是当我像这样尝试它时http://ip/WebApp我得到了404错误。

Ubuntu 16.04 with Apache 使用Apache的Ubuntu 16.04

I'm pretty sure that I've configured everything in Apache to make it work. 我很确定我已经在Apache中配置了所有内容以使其工作。 This is my conf file in /etc/apache2/sites-available/proxy-host.conf 这是我在/etc/apache2/sites-available/proxy-host.conf conf文件

<VirtualHost *:80>
  DocumentRoot /var/www/WebApp/
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  ProxyPreserveHost On
  ProxyPass /WebApp http://localhost:5000
  ProxyPassReverse /WebApp http://localhost:5000
  ServerName localhost
</VirtualHost>

and my little sample app 和我的小样本应用程序

public static void Main(string[] args)
        {

            var config = new ConfigurationBuilder()
               .SetBasePath(Directory.GetCurrentDirectory())
               .AddJsonFile("hosting.json", optional: true)
               .Build();

            var host = new WebHostBuilder()
                .UseKestrel()
                .UseUrls("http://*:5000")
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .UseApplicationInsights()
                .Build();

            host.Run();
        }

What am I missing here? 我在这里错过了什么? I'm pretty sure that this is a noob question but bare in mind that I'm trying to learn :=) 我很确定这是一个noob问题,但我记得我正在努力学习:=)

I was able to Fix this issue by changing both the config and my code in the Main Method to: 通过将主方法中的配置和我的代码更改为:我能够解决此问题:

 var host = new WebHostBuilder()
                .UseKestrel()
                .UseUrls("http://*:5000/WebApp")
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseStartup<Startup>()
                .UseApplicationInsights()
                .Build();

    host.Run();

and in the Config file 并在Config文件中

<VirtualHost *:80>
  DocumentRoot /var/www/WebApp
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  ProxyPreserveHost On
  ProxyPass /WebApp http://localhost:5000/WebApp
  ProxyPassReverse /WebApp http://localhost:5000/WebApp
  ServerName localhost
</VirtualHost>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从存储库部署ASP.NET Core Web App + SQL - Deploying ASP.NET Core Web App + SQL from a repository 将 ASP.NET CORE 3.1 MVC 应用程序部署到 azure 时出现问题 - Problem deploying ASP.NET CORE 3.1 MVC app to azure 将 ASP.NET Core 应用程序部署到 Azure 会导致空白页 - Deploying ASP.NET Core App to Azure results in blank pages NPOI 在 ASP.NET Core 应用程序中第二次读取时失败 - NPOI fails on second read in ASP.NET Core app 部署Angular 6 ASP.NET Core应用程序 - Deploying Angular 6 ASP.NET Core application 部署多项目 ASP.NET 核心 web 应用程序到 Azure 应用程序服务使用 ZE1ADBCBB92C622D0B3E Actions61 - Deploying multi-project ASP.NET Core web app to Azure App Service using Github Actions 将ASP.NET Core应用程序本地部署到IIS后出现错误500.21 - Error 500.21 after deploying ASP.NET Core app locally to IIS 使用 Web Deploy 在 Azure 中部署普通的 ASP.NET Core 2.2 Web 应用程序引发错误 - Deploying a plain ASP.NET Core 2.2 Web App in Azure using Web Deploy is throwing an error ASP.NET Core 2.0 Web 应用程序在将项目部署到 Azure Web 服务时失败并出现 SQLite 错误,但在本地环境中运行良好 - ASP.NET Core 2.0 Web Application fails with a SQLite error when deploying the project to Azure Web Service but runs fine in local environment 使用 docker 容器上的数据库部署 ASP.NET Core 应用程序 - Deploying an ASP.NET Core Application with a database that is on a docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM