Skip to content

ASP.NET MVC 4.5.1 项目在 VS 2022 中无法启动

通过 VS 2022 打开一个 .NET Framework 4.5.1 的 MVC 项目时,编译可以成功,但是启动时始终跳转到 Error 页面,而且连 Global.asax 中的代码都没有执行。

本来以为是 VS 版本太高了导致的,结果用 2017 和 2019 都不行(之前应该是用 2015 开发的,但是没找到安装文件)。

在网上搜了下也没找到类似的文章。

最终在尝试各种操作下项目终于运行起来了,可能相关的操作如下(均在项目属性的 Web 标签下):

  1. 修改过项目启动页面(这个貌似没有效果)
  2. 修改了项目的启动端口
  3. 点击了 项目 URL 傍边的 创建虚拟目录 按钮
  4. 勾选过 覆盖应用程序根 URL

大概率是第 3 个操作修复的这个问题。

本地调试使用的是自带的 IIS Express,不记得以前有操作过 创建虚拟目录

2023-02-18 追记

在另外一台电脑上使用的 VS 2019,将 IIS Express 的位数从 默认 修改为 64 位 后可以正常启动。

附 1. 不支持目标框架

VS 2022 默认不包含 .NET Framework 4.5.1 ,需要额外下载。可以根据弹出的提示,从 Download Visual Studio SDK 页面下载。

如果使用的是 .NET Framework 4.5 貌似已经不提供下载了。可以先改成推荐的版本,然后再在项目属性中改为 4.5.1 或者 4.5.2 。或者尝试直接修改工程文件的 TargetFrameworkVersion 配置。

xml
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.