I'm having issue deploying ASP.NET MVC app with precompiled views. Until now I was not precompiling views and app has worked for years flawlessly. If I precompile them, the site works on first start just as you'd expect. If I however restart it from IIS, I start getting 404.0 errors. The funny part is: if I change app's non-essential configuration in IIS, IIS restarts app by itself and it comes to life. If it gets recycled or restarted, then it goes back to 404.0s.
I noticed error page describes incorrect physical path. In the screenshot below the physical path is C:\wwwsites\workpal\settings. In fact 'settings' is controller name and is a folder at path: C:\wwwsites\workpal\views\settings which contains index.cshtml. Also, should StaticFile be used here? I'm a newb, but to me it looks like IIS doesn't have a clue how to resolve URLs.
The error
Application is running .NET 4.7.2
IIS 8.5
Application has worked for years without precompiled views, no issues. We used .NET 4.5 earlier, but I doubt it's the reason. I get same results with 4.5.
The only change is turning on precompiled views in VS publish settings. I have tried every 'Advanced Precompile Settings' configuration - same results.
Application with precompiled views works on first start, when IIS detects change in app's directory or when I change non-essential app setting in IIS.
Application doesn't work when recycled or when restarted manually.
I've tried fresh AppPool and fresh Site - to no avail.
Tested on two unrelated servers (physical machines).
Related
I am trying to get my Asp.Net Core 3.1 project running from inside Visual Studio on IIS.
I ran through the steps and it seems to run my Swashbuckle Swagger page, but it hits an error on finding the swagger.json file. When I look at the dev tools, I see I got a 404 when trying to load the swagger.json file. The physical path it is trying to load from is:
C:\inetpub\wwwroot\swagger\v1\swagger.json
But my code is not in inetpub, it is in my development folder. What is even more odd, is I tried this on another machine and it works. So it seems like it should be something to do with how IIS is setup.
I checked my IIS Site settings and the physical path is set to my development folder (not inetpub). And when I hit the "Explore" option in IIS it loads my development folder.
I copied swagger.json into C:\inetpub\wwwroot\swagger\v1\ and it worked (though I then encountered other errors).
Why is IIS trying to use inetpub to find the swagger.json file instead of my development folder?
I have almost no experience with MVC, so hoping someone can help me. I have already spent hours trying to configure IIS to run the applications.
The application runs fine in Visual Studio 2010. MVC2. I can configure the publish and publish output seems to work fine. I have configured IIS as I have many times, but more for a non-mvc .net application.
When uploading the application to the IIS directory I only receive 500 errors. The IIS log doesn't give me much info to work with.
For grins, I created a new MVC project and uploaded that started app up to IIS and received same IIS 500 error. This leads me to believe I've configured IIS incorrectly. The only thing I'm confident of is I've screwed up somewher.
Any and all help is very appreciated!
Screenshot for Trace:
click here to see screen shot of trace error.
Detailed trace Image
I assume the problem is you are hosting your web app in a folder by mistake. You didn't set in the root web.config of your web-application or website. It looks just like you are hosting your application in a virtual directory or a sub-folder.
As you can see its only <modules runAllManagedModulesForAllRequests="true" /> is only supported by root web.config or applicationhost.config.
Modules section is not listed in folder(Vdir) level's web.config.
So please ensure you are publishing your application to a site's root folder or a sub application.
https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/application/
Windows 10 Professional
IIS 10
Visual Studio 2015 (Running as Administrator)
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:
I uninstalled IIS via Control Panel -> Programs and Features ->
Windows Features.
Restarted my computer
Installed IIS for Windows 10 following this document
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)
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")
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.
That was it, I was all set, ASP.NET MVC Website started working from IIS immediately upon refreshing my browser (localhost in Location bar).
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.
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
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.
I am attempting to publish our web api to IIS 7.5. I have it deployed as an application "api". I am able to successfully deploy the application and it runs. I can access it at /api/api/. I believe this was due to having "api" in the routing config of the api controllers as well as having it hosted in the "api" application in IIS. I have removed the "api" portion of the route path in web api and it works correctly if I launch it from visual studio. I would like to access it from /api instead of /api/api but IIS doesn't recognize this change. What could be causing this in IIS? I am fairly new to IIS and I have googled around but I have not found anything useful.
TL;DR
I updated routes in my web api application but IIS is not recognizing those changes.How can I force IIS to update?
After playing with this for some time I found that the problem was that I pointing the physical directory of IIS to the deployment package from VS and because I was building the project directly on the machine. This caused VS to quietly fail when it couldn't update the files because they were locked by IIS. After deploying to a new path and then replacing the contents of the application the new routing works as expected.
I'm trying to deploy an ASP.NET application to localhost using IIS, I've been reading a LOT of tutorials and following them step by step but I just can't seem to make it work...
I created an Application Pool(TestPool) with .NET version 4.0 and gave it every permission to the folder where the application is at.
I then added an application to the Default Web Site and tried to run it at
http://localhost/TestApplication/
But I keep getting:
Any idea what is wrong and how can I solve this?
Versions:
IIS version: 6.2
OS: Windows 8.1
VS 2013 Ultimate: 12.0
VS .NET: 4.6
PS: It's my first attempt at deploying an ASP.NET application so if you need any further information just leave a comment.
EDIT:
It is now running at least thanks to Julian and Marge, but when I run it using VS it has the default view, why isn't it showing when I run it through IIS? When running through IIS it just lists the files:
This error is because your website, in the IIS Server, does not have the Directory Browsing enabled and the default document (default page of the site ex: Default.aspx) configured.
Go to IIS Server IIS > Default Documents and check if the default page of your site is listed, if no, add the page.
Check the related link:
https://support.microsoft.com/en-us/kb/942062
Generally speaking, you do not need to access IIS manager at all to run your webpage on localhost. All what you need to do is right click on the project and then choose properties. In the Web tab you will find Servers section. Make sure the Project Url is something like http://localhost/myproj or simply http://localhost/ then hit Create Virtual Directory. Your webpage should be up by then, and you can access it either in debug mode, or simply by navigating your browser to the Project Url you have chosen.
When you add web application in IIS ex.
That your hostname should be to add in host file which is C:\Windows\System32\drivers\etc"\hosts
ex.
127.0.0.1 test.pln