我有一个ASP。NET MVC 4解决方案。当我尝试使用Visual Studio 2012打开它时,我得到以下错误:

Microsoft Visual Studio 为ASP配置Web https://localhost:。NET 4.5失败。你必须 手动配置此站点的ASP。NET 4.5才能使站点 正确地运行。无法在https://localhost:44300/上找到服务器 本地机器。确保已配置本地IIS服务器 支持安全通信。

尽管解打开了。此外,当我试图从调试菜单运行它时,我得到以下错误:

无法启动IIS Express Web服务器。 指定的起始URL无效。https://localhost:44300/

我无法调试代码。如何摆脱这些错误和调试/运行网站从VS 2012?


当前回答

不需要删除C:\Users[you]\Documents\IISExpress目录下的整个IISExpress文件夹。

评论:

<binding protocol="https" bindingInformation="*:8090:localhost" />

在applicationhost中。IISExpress文件夹下的config文件。

其他回答

@roblll说对了。但对于那些不想挖掘答案的人来说,这就是:

Close Visual Studio (might not be necessary, but it won't hurt). Navigate to your Documents folder. This is where my IISExpress configuration directory was. In the config folder, there is a file called the application host. Open that. Search for the name of your project. It should have been added in there by Visual Studio when it bombed in your previous attempts. Note that there's a binding for HTTP with the port you intend to use for https. //Change this: <binding protocol="http" bindingInformation="*:44300:localhost" /> //to this: <binding protocol="https" bindingInformation="*:44300:localhost" />

请记住,Visual Studio可能提供了与您期望的不同的端口。只需确保绑定中的端口对应于项目属性的Web选项卡中的端口。

http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx

不需要删除C:\Users[you]\Documents\IISExpress目录下的整个IISExpress文件夹。

评论:

<binding protocol="https" bindingInformation="*:8090:localhost" />

在applicationhost中。IISExpress文件夹下的config文件。

在我的情况下,IIS Express应用程序主机。配置文件中几个元素的managedRuntimeVersion属性有一个拼写错误。这是发生在Visual Studio 2012和Visual Studio 2013。我只收到了邮件的第一部分,内容是:

无法启动IIS Express Web服务器。

它在事件日志中记录了一个错误,消息如下:

工作进程未能预加载. net Runtime版本v4.030319。

正确的运行时版本是v4.0.30319(注意第二个周期)。

我采取的纠正措施:

导航到C:\Users\ Documents\IISExpress\config 编辑applicationhost.config 查找配置部分 将任何引用“v4.030319”的内容更正为“v4.0.30319”

在我下次调试web应用程序时,Visual Studio成功启动了IIS Express。

这里介绍的方法对我都不起作用。最后的工作是在.csproj文件中将DevelopmentServerPort设置为0:

    <WebProjectProperties>
      <UseIIS>True</UseIIS>
      <AutoAssignPort>True</AutoAssignPort>
      <DevelopmentServerPort>0</DevelopmentServerPort>
      <DevelopmentServerVPath>/</DevelopmentServerVPath>
      <IISUrl>http://localhost:52973/</IISUrl>
      <NTLMAuthentication>False</NTLMAuthentication>
      <UseCustomServer>False</UseCustomServer>
      <CustomServerUrl>
      </CustomServerUrl>
      <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
    </WebProjectProperties>

我也有同样的问题。 原因是IIS配置文件不好。

尝试删除自动创建的IISExpress文件夹,该文件夹通常位于%userprofile%/Documents,例如C:\Users\[you]\Documents\IISExpress。

别担心,一旦你再次运行你的解决方案,VS应该再次创建它——这次是正确的。


EDIT:删除文件夹的命令行:

rmdir /s /q "%userprofile%\Documents\IISExpress"