首页 > 解决方案 > 如何设置 Web.config:MVC

问题描述

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

我按照本指南添加了一个:如何:创建 Web.config 文件。这是由微软提供的。

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

这些是文件的当前内容:

<?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>

我要的是一些关于我需要做什么的方向,以及为什么这不包括在网站上。

标签: htmlasp.net-mvcweb-config

解决方案


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

此外,web.config 与经典的 ASP.NET 框架相关,而不是与 ASP.NET Core 相关。尝试在 Visual Studio 中使用任何 .NET 版本 4.x 创建应用程序。在模板中,您将看到 web.config。

如果您仍想使用 .net 核心,它使用稍微不同的配置机制。您可以在 asp.net core 的www.asp.net教程部分阅读更多信息


推荐阅读