Running MVC6 app on IIS10 throws 500 error - iis

I am trying to deploy a MVC 6 to IIS. I have followed these instructions http://docs.asp.net/en/latest/publishing/iis.html but the app will not run. It throws a 500 error. I then tried the stock standard template MVC 6 app deployed to IIS and that would not run either. No 500 thrown. Just a blank page. In both cases the apps run correctly in IIS express. In both cases I used the File Publish method from VS pointing to the wwwroot folder.
In IIS config editor, I have unlocked the handlers. In the wwwroot web.config I have set CustomerErrors mode to Off.
The DNX version I am using in the File System deployment is dnx-clr-win-x86.1.0.0-rc1-final.

Related

Running multiple ASP.NET Core 2.2 webapps side-by-side in IIS

I'm trying to run 2 ASP.NET Core 2.2 webapps side-by-side on IIS 10. I created CoreTestApp1 & CoreTestApp2 (default VS template, no added code), i.e. both set up for In-Process hosting.
After I restart my server (IIS Mgr), the first webapp that I open in a browser (e.g. CoreTestApp1) runs fine; if I open the second one (CoreTestApp2) I get an error "HTTP Error 500.0 - ANCM In-Process Handler Load Failure".
If I restart my server again and open CoreTestApp2 first, then that runs fine, but now CoreTestApp1 causes the same error.
I tried running 2 ASP.NET Framework apps side by side, and that works fine.
Judging by the info I found (e.g. https://learn.microsoft.com/en-us/dotnet/core/deploying/index), it seems I should be able to run multiple core apps side-by-side?
Is there some extra config stuff that I'm missing?
Not sure if this is relevant, but I used Visual Studio's publish (to folder) with these settings...
Configuration = Debug
Target Framework = netcoreapp2.2
Deployment mode = framework-dependent
Target runtime = portable
Thanks to Lex's suggestion and some more googling, I found the answer to my question here:
The ASP.NET Core module V2 running in InProcess mode has to run in its own dedicated Application Pool. According to the documentation you cannot run multiple sites or virtual directories (Web Applications) using the the ASP.NET Core Module in a single Application Pool. Make sure each ASP.NET Core app on IIS gets its own Application Pool.
Creating extra Application Pools and assigning each ASP.NET Core app its own solved my problem; instructions on how to create App Pools here.

Deploying .Net Core to Linux WebApps on Azure with DevOps

I have a build/release for a .Net Core WebApp that works on windows machines perfectly, however I want to be able to deploy the same codebase to Linux. I set up a build and release and am using the "Web App on Linux" to deploy to my Linux WebApp. I also made sure that the Runtime Stack(s) on BOTH the Build and on the WebApp are set to use .Net Core 2.2:
The builds and the release run perfectly, however once the deployment is complete the website goes to a 404 (replacing the default Azure startup HTML page). I've FTP'd into the WebApp and see that the files are deployed to the machine, however I see that there are multiple "wwwroot" folders:
The top "wwwroot" folder does contain the DLLs for my application so that is a good sign:
Curiously I can get to the static files from my app such as the CSS, JS or the favicon if I navigate to /wwwroot/(filename)
I am pretty sure I have everything set up properly so I am hitting a wall on things to try. I've never had issues like this deploying to Windows WebApps so I am sure there is a setting or something that I am unaware of or is missing from the documentation.
For further details on this issue here is my BUILD:
...and my RELEASE setup:
I had a similar issue and the issue came down to how VS was publishing the zip vs Dev Ops. If you return to the Azure portal you will need to add a startup command specifying where your main DLL is located.
https://learn.microsoft.com/en-us/azure/app-service/containers/app-service-linux-faq#built-in-images

Can host ASP.NET Core site through console but not through IIS

Solution and server configuration:
I have developed a fairly simple ASP.NET Core application. It consists of a core project file, created and built in Visual Studio 2017. The target framework is .NETCoreApp 1.1 and Platform target is x64.
It also contains two class library projects with target frameworks .NETStandard 1.4 and Platform target x64.
Due to a bug in VS2017's Web Deploy, I am publishing to file system, then copying the contents of PublishOutput to my IIS application's directory using FTP.
My server is Windows Server 2012 R2 with all relevant service packs and updates. DotNet Core runtimes have been installed.
The issue:
When I navigate to my site's URL in the browser, I encounter a bland HTML page which indicates the following:
HTTP Error 502.5 - Process Failure
Common causes of this issue: (lists things)
Troubleshooting steps: (lists things)
For more information visit http://go.microsoft.com/fwlink/?linkid=808681
Steps taken to resolve:
Needless to say, I've followed the instructions to resolve. The link given shows my error under the heading of Platform conflicts with RID.
The Event Viewer has an Error entry with the following:
Application 'MACHINE/WEBROOT/APPHOST/MY SITE' with physical root 'C:\inetpub\wwwroot\mysite\' failed to start process with commandline "dotnet" .\MySite.dll', ErrorCode = '0x80070002 : 0.
By opening an instance of cmd.exe at my site's folder, I can execute dotnet mysite.dll and it runs, hosting on http://localhost:5000. I can navigate to the site in a browser, as expected.
My Program.cs is as follows:
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
My Startup.cs is mostly uninteresting. Excepting some service definitions, my pipeline is:
app.UseCookieAuthentication();
app.UseRedditMiddleware(); // authentication middleware, custom
app.UseMvc();
app.UseStaticFiles();
Either the system wide %PATH% to the dotnet folder is not set (IIS runs as a different user) or you did not restart your server after installing ASP.Net Core Server bundle. You can find more some troubleshooting steps in my post about running ASP.NET Core applications with IIS.

IIS does not start .net core 1.0 executable

so after .net core 1.0 got published I started a new console project and imported the code from a small prototype that is supposed to run without IIS. Besides having to use net46 in my project.json due the not-yet updated MongoDB.Driver, that worked fine. When I build the app in Visual Studio a small App.exe with a lot of dll is build and can be run fine locally without IIS.
I then noticed the option to build for IIS Express and thought that I can use the IIS on our server (IIS 6.2, Windows Server 2012 R2) too. It publishes fine with WebDeploy, but nothing happens after that. I was following this official guide. I installed the .NET core Windows Server Hosting bundle and everything appears to be in order, but when I browse to the url, I get a ERR_NAME_NOT_RESOLVED. Theapp.exedoes not appear in the Task Manager and I can't find any log file, although it is enabled in theweb.config. I can execute the app manually, but then it only listens on the defaultlocalhost:5000` address.
If I understood it correctly, the IIS is supposed to act as a reverse-proxy to the dotnet tool which starts a dll, but in my case it's already a compiled exe that works standalone. But I can't figure out how to build a dll from this app..
What am I doing wrong?
If you target full .NET Framework the application will be .exe and not .dll and it is fine. ERR_NAME_NOT_RESOLVED indicates that the url you provided in your browser could not be resolved and the request to the application was not made. AspNet Core Module starts the application on the first request and because the host could not be resolved the request was not made and the application was not started. Once you figure out why the name could not be resolved and you still have issues with making your application work with IIS take a look at my post which explains how things work and how to troubleshoot issues. This, however, only applies after the request can reach your application.

Visual Studio 2013 Asp.net Razor v3 website unable to host to IIS windows 7.5

I am trying to host a asp.net razor v3 website to IIS, but it is not working. I tried multiple options including first creating the website then publishing to IIS, or directly creating a new website under IIS using visual studio 2013. It gives me HTTP Error 503. The service is unavailable.
Methods to reproduce Error:
Option 1
1) Create a new asp.net web site (razor v3) in visual 2013, and click publish to publish to a directory. Then, add that directory as a website in IIS.
Option 2
1) On the new website window, in visual studio 2013, go to browse and select IIS, and create a virtual directory directory under IIS to save the site.
Then, go to the browser and try to access the hosted site: localhost/sitename, it always produces some kind of errors. Like 503. What am I missing? Please help, looks like I am missing some steps or some configuration changes.
Also, I am trying this with the default razor v3 webiste content and without modifying anything. So, I have not touched any files or anything, I am just trying to upload to IIS.
The correct answer I found was that for some reason you must use the IIS Express 8.5 to test/host that site.
Even the installations on the fresh copies of Windows with Full IIS prior to version 8 did not work on my test machines.

Resources