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.
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:
I then went to IIS 10 and created a new website with "localhost" as the binding:
The Physical Path for this new website in IIS is C:\inetpub\wwwroot\AspNetMvcTest
:
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:
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.
I then was told that IIS "localhost" was mapped to a different folder and would I like to remap:
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.
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.
Now I am told that the "Virtual Directory" was created successfully:
Now we can look at the changes Visual Studio 2015 made to IIS 10:
We have no Virtual Directories on the website bound to localhost:
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:
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.
Now for the Internal Server Error 500 Details
I press F5 in Visual Studio 2015 and F12 Tools says there is an Internal Server 500 Error:
If we inspect the request and response in Fiddler, there 500 Error has a Content Length = 0
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:
I added "catch all" exceptions handling to Global.asax, no breakpoint hit:
Here is my Call Stack, which is empty and neither breakpoint in screenshot is ever hit:
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:
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:
I thought the issue is folder permissions after Visual Studio changed the Physical Path
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:
My ApplicationPoolIndentity is Framework v4.0 and ApplicationPoolIdentity The ApplicationPoolIdentity is assigned membership of the Users group as well as the IIS_IUSRS group:
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:
I added "DefaultAppPool" and my IIS Application Pool "IIS APPPOOL\AspNetMvcTest" to the Physical folder Security.
I added index.html to the Web Application Physical Folder and that does not work:
<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
So now I am stuck and do not know what else to do.
TL;DR
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.
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.
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
Steps I took for fix:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With