不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

时间:2022-06-04 05:30:37
  • Windows 10 Professional
  • Windows 10个专业
  • IIS 10
  • IIS 10
  • Visual Studio 2015 (Running as Administrator)
  • Visual Studio 2015(以管理员身份运行)

I want to run from IIS instead of IIS Express as I have an external IP pointing to my machine and I will be receiving messages from an external source. Ultimately I will be using WebAPI but for testing and setting up IIS I am using a simple ASP.NET MVC 5 Web Application.

我想从IIS运行,而不是IIS Express,因为我有一个外部IP指向我的机器,我将接收来自外部源的消息。最终,我将使用WebAPI,但是对于测试和设置IIS,我使用的是一个简单的ASP。NET MVC 5 Web应用程序。

I created a new ASP.NET MVC 5 Web Application, this is the skeleton Visual Studio 2015 MVC Template, I then ran the application using IIS Express, no issues:

我创建了一个新的ASP。NET MVC 5 Web应用,这是框架Visual Studio 2015 MVC模板,然后我使用IIS Express运行应用,没有问题:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

I then went to IIS 10 and created a new website with "localhost" as the binding:

然后我去了IIS 10,创建了一个新的网站,以“localhost”为绑定:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

The Physical Path for this new website in IIS is C:\inetpub\wwwroot\AspNetMvcTest:

IIS新网站的物理路径是C:\inetpub\wwwroot\AspNetMvcTest:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

I then went to the web application properties and switched to IIS. I was asked if I would like to create a new Virtual Directory:

然后我转到web应用程序属性并切换到IIS。有人问我是否想创建一个新的虚拟目录:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

I clicked Yes, if you click No the operation will be canceled and you unsaved Web Application Properties. You have to click Yes to change to Local IIS Property in Visual Studio.

我点击了Yes,如果你点击No,操作将被取消,你的未保存的Web应用程序属性。您必须单击Yes以更改Visual Studio中的本地IIS属性。

I then was told that IIS "localhost" was mapped to a different folder and would I like to remap:

然后我被告知IIS“localhost”被映射到另一个文件夹,我想要重新映射:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

I clicked Yes. If you click No you will have unsaved Web Application Property changes again and you will not be using Local IIS in Visual Studio.

我点击Yes。如果单击No,您将再次更改未保存的Web应用程序属性,并且不会在Visual Studio中使用本地IIS。

This is interesting Visual Studio is trying to change the "Virtual Directory" because it will actual change the Physical Path of the IIS Website not add a Virtual Directory. A Virtual Directory is a folder, somewhere outside of the Physical Path of the IIS website that IIS will treat as is part of the Physical Path folder. But I digress.

有趣的是,Visual Studio正在尝试更改“虚拟目录”,因为它将实际更改IIS网站的物理路径,而不添加虚拟目录。虚拟目录是一个文件夹,位于IIS网站的物理路径之外,IIS将把它作为物理路径文件夹的一部分。但我离题了。

Now I am told that the "Virtual Directory" was created successfully:

现在我被告知“虚拟目录”已经成功创建:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

Now we can look at the changes Visual Studio 2015 made to IIS 10:

现在我们来看看Visual Studio 2015对IIS 10所做的改变:

We have no Virtual Directories on the website bound to localhost:

我们在网站上没有绑定到本地主机的虚拟目录:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

My Physical Path has been changed by Visual Studio 2015 and it is mapped to my the directory my simple ASP.NET MVC 5 Web Application resides:

我的物理路径被Visual Studio 2015改变了,它被映射到我的目录My simple ASP。NET MVC 5 Web应用驻留:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

So even though Visual Studio 2015 uses the "Virtual Directory" when changing the ASP.NET MVC 5 Web Application Properties, Visual Studio 2015 was only concerned with the Physical Path and that is the only thing it changed in IIS that I can see.

因此,尽管Visual Studio 2015在改变ASP时使用“虚拟目录”。NET MVC 5 Web应用程序属性,Visual Studio 2015只关注物理路径,这是我在IIS中看到的唯一改变。

Now for the Internal Server Error 500 Details

现在查看内部服务器错误500详细信息

I press F5 in Visual Studio 2015 and F12 Tools says there is an Internal Server 500 Error:

我在Visual Studio 2015中按F5, F12工具说有一个内部服务器500错误:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

If we inspect the request and response in Fiddler, there 500 Error has a Content Length = 0

如果我们检查Fiddler中的请求和响应,有500个错误的内容长度为0

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

To try and get more details of the 500 error I have turned Custom Errors off in my Web.Config and also added httpErrors Detailed and PassThrough:

为了获得更多关于500错误的细节,我关闭了我的Web中的自定义错误。配置并添加详细的httpErrors并进行传递:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

I added "catch all" exceptions handling to Global.asax, no breakpoint hit不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500):

我向全局添加了“捕获所有”异常处理。asax,没有断点打击:

Here is my Call Stack, which is empty and neither breakpoint in screenshot is ever hit:

这是我的调用堆栈,它是空的,屏幕快照中没有断点会被击中:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

I added a Console Application to my solution as "Set As Startup Project" and here is my Call Stack proving a break point can be hit:

我在我的解决方案中添加了一个控制台应用程序“设置为启动项目”,这是我的调用堆栈,证明可以命中断点:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

Here is a screenshot of Event Viewer -> Application, I cleared the Application log, pressed F5 in Visual Studio 2015, refreshed the Application log and it is empty still:

这里是事件查看器->应用程序的屏幕截图,我清空了应用程序日志,在Visual Studio 2015中按下F5,刷新了应用程序日志,它仍然是空的:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

I thought the issue is folder permissions after Visual Studio changed the Physical Path

我认为问题是Visual Studio更改物理路径后的文件夹权限

So I added IIS_IUSRS and gave Full Control even though the Account does not need that high of a level of permission to the Physical Path directory:

因此,我添加了IIS_IUSRS并提供了完全的控制,即使该帐户不需要对物理路径目录有那么高的权限级别:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

My ApplicationPoolIndentity is Framework v4.0 and ApplicationPoolIdentity The ApplicationPoolIdentity is assigned membership of the Users group as well as the IIS_IUSRS group:

我的ApplicationPoolIndentity是v4.0框架,applicationpoolity是用户组和IIS_IUSRS组的成员:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

I tried adding the specific Application Pool to the Security properties of ASP.NET MVC app Physical Directory, so first I found the process Visual Studio F5 was attached to:

我尝试将特定的应用程序池添加到ASP的安全性属性中。NET MVC app物理目录,所以首先我发现Visual Studio F5的流程附件为:

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

I added "DefaultAppPool" and my IIS Application Pool "IIS APPPOOL\AspNetMvcTest" to the Physical folder Security.

我在物理文件夹安全性中添加了“DefaultAppPool”和IIS应用程序池“IIS APPPOOL\AspNetMvcTest”。

I added index.html to the Web Application Physical Folder and that does not work:

我添加了索引。html到Web应用程序的物理文件夹,那是不工作的:

<html>
<head>
</head>
<body>
<h4 style="color: black">hello world</h4>
</body>
</html>

I have moved the IIS website Physical Path to inetpub/wwwroot back to the directory I created when I created the website, I cannot even browse to a simple HTML file, I get the same empty 500 error

我已经将IIS网站的物理路径移动到inetpub/wwwroot回到我创建网站时创建的目录,我甚至不能浏览到一个简单的HTML文件,我得到相同的空500错误

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

So now I am stuck and do not know what else to do.

所以现在我被困住了,不知道还能做什么。

2 个解决方案

#1


7  

TL;DR

博士TL;

Before reading the rest of answer it is likely you just need to run aspnet_regiis which you can do from cmd or via a cool tool in Web Platform Installer, if you search "ASP.NET" there is a handy "Execute ASP.NET IIS Registration tool" you can install.

在阅读剩下的答案之前,您可能只需要运行aspnet_regiis,如果您搜索“ASP”,您可以从cmd或通过Web平台安装程序中的一个很酷的工具来执行。NET“there is a handy”执行ASP。NET IIS注册工具“您可以安装。

Original Answer:

最初的回答:

Thanks for all the help from everyone, first thing I should have done was taken a step back and tested an index.html "Hello World" test file from a IIS Website with c:\inetpub\wwwroot as the Physical Path of the IIS website.

谢谢大家的帮助,我应该做的第一件事就是后退一步,测试一个指数。来自IIS网站的html“Hello World”测试文件,使用c:\inetpub\wwwroot作为IIS网站的物理路径。

When you first install IIS you have a default website, browse to it and make sure that works. Is a great first start to a new machine. But I just deleted that IIS site after installing IIS

当你第一次安装IIS,你有一个默认的网站,浏览它,并确保它工作。是新机器的良好开端。但是我只是在安装IIS后删除了IIS站点

Steps I took for fix:

我为修复所采取的步骤:

  1. I uninstalled IIS via Control Panel -> Programs and Features -> Windows Features.
  2. 我通过控制面板卸载IIS ->程序和功能-> Windows功能。
  3. Restarted my computer
  4. 重新启动我的电脑
  5. Installed IIS for Windows 10 following this document
  6. 在此文档之后安装了Windows 10的IIS。
  7. Tested IIS by creating a Website, using the DefaultAppPool and then browsing localhost, and that worked (again when you first install IIS you have this website but I deleted it on mine a couple days ago)
  8. 通过创建一个网站来测试IIS,使用DefaultAppPool,然后浏览localhost,这是有效的(当你第一次安装IIS时,你有这个网站,但是几天前我把它删除了)
  9. I Found that my simple ASP.NET Website still did not work though and it was published to c:\inetpub\wwwroot\AspNetMvcTest so it was not a potential folders permission issue. When browsing, instead of loading my ASP.NET Website IIS redirected to the root c:\inetpub\wwwroot and displayed its IIS Welcome page ("iisstart.htm")
  10. 我发现我的简单ASP。NET网站仍然无法运行,它被发布到c:\inetpub\wwwroot\AspNetMvcTest,因此它不是一个潜在的文件夹权限问题。当浏览时,而不是加载我的ASP。NET网站IIS重定向到根c:\inetpub\wwwroot并显示其IIS欢迎页面(“iisstart.htm”)
  11. This means I needed to run aspnet_regiis, which I did, via cool tool in Web Platform Installer, if you search "ASP.NET" there is a handy "Execute ASP.NET IIS Registration tool" you can install.
  12. 这意味着我需要运行aspnet_regiis,如果您搜索“ASP”,我是通过Web平台安装程序中的cool工具运行的。NET“there is a handy”执行ASP。NET IIS注册工具“您可以安装。
  13. That was it, I was all set, ASP.NET MVC Website started working from IIS immediately upon refreshing my browser (localhost in Location bar).
  14. 就是这样,我已经准备好了,ASP。NET MVC网站在刷新我的浏览器(位置栏中的localhost)后立即从IIS开始工作。

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

#2


0  

I think the main problem is that ASP.NET MVC 5 web requires .NET Framework 4.5 at least. From your provided information, the application pool of your web application was using .NET 4.0. It look like you've not registerd ASP.NET 4.5 with your IIS yet.

我认为主要的问题是ASP。NET MVC 5 web至少需要。NET Framework 4.5。根据您提供的信息,web应用程序的应用程序池使用。net 4.0。看起来你还没有注册ASP。NET 4.5与您的IIS。

To register ASP.NET 4.5 with IIS, you could use using Visual Studio's command prompt (as an Administrator), go to the following directory and run the commmand aspnet_regiis.exe -i

登记ASP。使用IIS,您可以使用Visual Studio的命令提示符(作为管理员),转到以下目录并运行commmand aspnet_regiis。exe -我

C:\Windows\Microsoft.NET\Framework64\v4.5.<version>

After successfully register ASP.NET 4.5 with IIS, change your web application to use .NET 4.5 application pool.

成功注册后ASP。使用IIS,将web应用程序更改为使用。NET 4.5应用程序池。

#1


7  

TL;DR

博士TL;

Before reading the rest of answer it is likely you just need to run aspnet_regiis which you can do from cmd or via a cool tool in Web Platform Installer, if you search "ASP.NET" there is a handy "Execute ASP.NET IIS Registration tool" you can install.

在阅读剩下的答案之前,您可能只需要运行aspnet_regiis,如果您搜索“ASP”,您可以从cmd或通过Web平台安装程序中的一个很酷的工具来执行。NET“there is a handy”执行ASP。NET IIS注册工具“您可以安装。

Original Answer:

最初的回答:

Thanks for all the help from everyone, first thing I should have done was taken a step back and tested an index.html "Hello World" test file from a IIS Website with c:\inetpub\wwwroot as the Physical Path of the IIS website.

谢谢大家的帮助,我应该做的第一件事就是后退一步,测试一个指数。来自IIS网站的html“Hello World”测试文件,使用c:\inetpub\wwwroot作为IIS网站的物理路径。

When you first install IIS you have a default website, browse to it and make sure that works. Is a great first start to a new machine. But I just deleted that IIS site after installing IIS

当你第一次安装IIS,你有一个默认的网站,浏览它,并确保它工作。是新机器的良好开端。但是我只是在安装IIS后删除了IIS站点

Steps I took for fix:

我为修复所采取的步骤:

  1. I uninstalled IIS via Control Panel -> Programs and Features -> Windows Features.
  2. 我通过控制面板卸载IIS ->程序和功能-> Windows功能。
  3. Restarted my computer
  4. 重新启动我的电脑
  5. Installed IIS for Windows 10 following this document
  6. 在此文档之后安装了Windows 10的IIS。
  7. Tested IIS by creating a Website, using the DefaultAppPool and then browsing localhost, and that worked (again when you first install IIS you have this website but I deleted it on mine a couple days ago)
  8. 通过创建一个网站来测试IIS,使用DefaultAppPool,然后浏览localhost,这是有效的(当你第一次安装IIS时,你有这个网站,但是几天前我把它删除了)
  9. I Found that my simple ASP.NET Website still did not work though and it was published to c:\inetpub\wwwroot\AspNetMvcTest so it was not a potential folders permission issue. When browsing, instead of loading my ASP.NET Website IIS redirected to the root c:\inetpub\wwwroot and displayed its IIS Welcome page ("iisstart.htm")
  10. 我发现我的简单ASP。NET网站仍然无法运行,它被发布到c:\inetpub\wwwroot\AspNetMvcTest,因此它不是一个潜在的文件夹权限问题。当浏览时,而不是加载我的ASP。NET网站IIS重定向到根c:\inetpub\wwwroot并显示其IIS欢迎页面(“iisstart.htm”)
  11. This means I needed to run aspnet_regiis, which I did, via cool tool in Web Platform Installer, if you search "ASP.NET" there is a handy "Execute ASP.NET IIS Registration tool" you can install.
  12. 这意味着我需要运行aspnet_regiis,如果您搜索“ASP”,我是通过Web平台安装程序中的cool工具运行的。NET“there is a handy”执行ASP。NET IIS注册工具“您可以安装。
  13. That was it, I was all set, ASP.NET MVC Website started working from IIS immediately upon refreshing my browser (localhost in Location bar).
  14. 就是这样,我已经准备好了,ASP。NET MVC网站在刷新我的浏览器(位置栏中的localhost)后立即从IIS开始工作。

不能运行简单的ASP。NET MVC应用与Visual Studio 2015来自IIS(内部服务器500)

#2


0  

I think the main problem is that ASP.NET MVC 5 web requires .NET Framework 4.5 at least. From your provided information, the application pool of your web application was using .NET 4.0. It look like you've not registerd ASP.NET 4.5 with your IIS yet.

我认为主要的问题是ASP。NET MVC 5 web至少需要。NET Framework 4.5。根据您提供的信息,web应用程序的应用程序池使用。net 4.0。看起来你还没有注册ASP。NET 4.5与您的IIS。

To register ASP.NET 4.5 with IIS, you could use using Visual Studio's command prompt (as an Administrator), go to the following directory and run the commmand aspnet_regiis.exe -i

登记ASP。使用IIS,您可以使用Visual Studio的命令提示符(作为管理员),转到以下目录并运行commmand aspnet_regiis。exe -我

C:\Windows\Microsoft.NET\Framework64\v4.5.<version>

After successfully register ASP.NET 4.5 with IIS, change your web application to use .NET 4.5 application pool.

成功注册后ASP。使用IIS,将web应用程序更改为使用。NET 4.5应用程序池。