Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS 10 on Windows Server 2016 not running my ASP.NET MVC website

I just bought a new Cloud based Virtual machine with Windows server 2016 installed. I also make sure IIS 10 has .NET Framework 4.6 and ASP.NET 4.6 installed.

enter image description here

My ASP.NET MVC application targets .NET 4.5 and is successfully published to the 'Default Web Site' on this server using Web deploy. (You can see all the asp.net mvc published files here)

enter image description here

'Default Web Site' uses 'DefaultAppPool' which has a v4.0 .NET CLR Version.

But when I open the web page in my browser, I received a '403 - Forbidden: Access is denied.' error. I did my research, to me it looks like the IIS never tried to open it as a ASP.NET MVC application. It simply tries to find a physical file with the same name as 'controller/Action'.html and of course it couldn't find it. Solutions I have tried with:

  1. There's another post mentioning the 'UrlRoutingModule-4.0' in IIS Modules configuration. In my case, the routing module is not there for some reason. I added it, but nothing changes. Furthermore, every time I republish the website from VS, the module disappears after the deployment succeeds.

  2. I also tried adding <modules runAllManagedModulesForAllRequests="true"/> to my webconfig file, no luck either.

  3. Run aspnet_regiis -ir on the server. It says the command can't be run on this operating system but still run it anyway. However, the problem is still there.

like image 341
NJUHOBBY Avatar asked Oct 29 '18 09:10

NJUHOBBY


People also ask

How do you deploy ASP.NET application in IIS 10?

First open your ASP.Net web application in Visual Studio. Now in the top we have the option Build. Click on that and under Build you will find Publish Website. Click on Publish Website.

How do I enable .NET in IIS?

In Control Panel, click Programs, and then click Turn Windows features on or off. In the Windows Features dialog box, click Internet Information Services to install the default features. Expand the Application Development Features node and click ASP.NET 4.5 to add the features that support ASP.NET. (If you installed .


1 Answers

I finally got it work!!!

The solution is go to control panel and then click 'Turn windows feature on and off', then go to 'Server Roles' -> 'Web Server (IIS)' -> 'Web Server' -> 'Application Development', here you need to make sure both '.NET Extensability 4.6' and 'ASP.NET 4.6' are installed.

Apparently when IIS 10 is installed, these will not be installed by default. Thanks guys for all the help.

like image 110
NJUHOBBY Avatar answered Oct 13 '22 14:10

NJUHOBBY