我得到这样的错误类型::

指定的参数超出有效值范围。参数名称:site

而调试任何我的项目。

在重新安装Visual Studio 2012后,我也尝试了一下。但是同样的问题,我在调试时遇到。

我的系统配置如下:

Windows 8: 32位 Visual Studio: 2012

在显示Web页面时抛出异常,

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: site]
   System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +298

[HttpException (0x80004005): Specified argument was out of the range of valid values.
Parameter name: site]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

当前回答

我在VS2017中也遇到了同样的问题。接下来解决了这个问题。

以管理员身份运行命令提示符。 编写以下两个命令来更新注册表。

reg add HKLM\Software\WOW6432Node\Microsoft\InetStp /v MajorVersion /t REG_DWORD /d 10 /f reg add HKLM\Software\Microsoft\InetStp /v MajorVersion /t REG_DWORD 10 /f

这应该能解决你的问题。更多细节请参考此链接。

其他回答

导航到控制面板>程序>程序和功能并修复IIS Express。 重新启动visual studio。

如果您的系统不作为活动服务器使用,则不建议像其他评论所建议的那样打开IIS。对于开发目的,只有IIS Express就足够了。

我在VS2017中也遇到了同样的问题。接下来解决了这个问题。

以管理员身份运行命令提示符。 编写以下两个命令来更新注册表。

reg add HKLM\Software\WOW6432Node\Microsoft\InetStp /v MajorVersion /t REG_DWORD /d 10 /f reg add HKLM\Software\Microsoft\InetStp /v MajorVersion /t REG_DWORD 10 /f

这应该能解决你的问题。更多细节请参考此链接。

我没有安装臃肿的IIS,而是从Windows特性中安装了Internet Information Services Hostable Web Core来解决我的问题

当您在调试项目时从特定页面开始,并且正在使用本地IIS时, 您可能在“特定页面”文本框中填写了错误的值。

(通过项目属性> Web >开始行动>特定页面)

错误的配置:

Specific Page: "http://localhost/MyApplication/Start/SpecificPage.aspx"
Project Url: "http://localhost/MyApplication"

正确的配置:

Specific Page: "/Start/SpecificPage.aspx"
Project Url: "http://localhost/MyApplication"

注意:忽略引号。

如果使用IIS:

控制面板 项目 打开或关闭Windows功能 Tick互联网信息服务 然后重新启动你的视觉工作室

如果使用IIS Express:

从旧的控制面板中打开“添加/删除程序”,并在IIS Express上运行修复 或者你可以打开控制面板->>程序->>程序和功能->>打开或关闭Windows功能->> Internet信息服务 并勾选如下图所示的复选框: