如何设置Web.config:MVC

How to set up Web.config: MVC

当我尝试访问我使用 MVC 构建的网站时,遇到错误 500。我联系了我的托管服务提供商,他们说问题出在我的 web.config 文件上。问题是当我通过 Visual Studio 创建它时,项目中没有一个。

我按照本指南添加了一个:How to: Create Web.config Files。这是微软提供的。

我在这里完全不知所措,因为我不知道需要什么样的信息或如何配置它才能正常工作。

这些是文件的当前内容:

<?xml version="1.0" encoding="utf-8"?>
<configuration>    
  <!-- To customize the asp.net core module uncomment and edit the following section. 
  For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
  <!--
  <system.webServer>
    <handlers>
      <remove name="aspNetCore"/>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
  -->
</configuration>

我要的是关于我需要做什么的一些指导,以及为什么网站一开始就没有包含这些内容。

您需要向您的提供商说明他们是否支持 asp.net 核心,因为它有自己的运行时库。

另外 web.config 与经典 ASP.NET 框架相关,不适用于 ASP.NET 核心。 尝试在 visual studio 中使用任何 .NET 版本 4.x 创建应用程序。在模板中,您会看到 web.config。

如果您仍想使用 .net 核心,它使用的配置机制略有不同。您可以在 asp.net 核心

www.asp.net 教程部分阅读更多相关信息