'Bad Gateway' error when loading aspnetcore RC2 default website project - asp.net-core

I am attempting to run the default ASP.NET Core Web Application (Web Application Template in VS 2015) via IIS.
I have followed the instructions from the docs here eg setting up a 'No Managed Code' application pool and pointing the Physical Path at the location of the web.config file.
When I attempt to browse to the website root, http://localhost I am getting this error:
HTTP Error 502.3 - Bad Gateway There was a connection error while trying to route the request.
Most likely causes: The CGI application did not return a valid set of
HTTP errors. A server acting as a proxy or gateway was unable to
process the request due to an error in a parent gateway.
The event viewer states:
Failed to start process with commandline 'dotnet ./bin/Debug/netcoreapp1.0/WebApplication2.dll', Error Code = '0x80004005'.
This error shows I have replaced the placeholders
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%"
in web.config with the required values
<aspNetCore processPath="dotnet" arguments="./bin/Debug/netcoreapp1.0/WebApplication2.dll"
(update: these placeholders are replaced when you publish)
As per the troubleshooting instructions I have installed .NET Core Windows Server Hosting Bundle and restarted the server.
Running from the command line via dotnet works
Wondering what to try now.

Ok I figured my issue out. I am pointing the physical path in IIS to the unpublished Visual Studio project root directory. This works in previous versions of .net (ie non dotnet core aspnet projects) but doesnt now.
If you really want this to work then you have to publish your app to a temporary folder and copy the Microsoft.AspNetCore.* binaries back into the bin\Debug\ folder along with the refs and runtimes folders

This is a generic error for when IIS can't find the specified .NET Core components ,and doesn't know where to forward requests. In addition to following the official IIS publishing guide, make sure you have:
Installed the correct versions from the download page for latest .NET Core releases
Specified the correct library versions (explicitly or with wildcards) in your project.json
Included a web.config file (preferably using the publish-iis tool), and that the <aspNetCore> key values have been replaced with local values (source, with examples)
I ran into this while setting up a Core 1.0.0 (final) website on a new Windows 2008 Server. Turns out I had mixed up some of the installers from my dev machine with newer versions, and had mismatched library versions (RC2 vs final). Reinstalling the Server Hosting package fixed the problem.
The key to troubleshooting was to get into the console and use the dotnet commands (and resulting error messages) to iterate until I had my site running from the console, since the IIS error page in the browser was useless. I also found some benefit in a few entries in the system Error logs, but not much.

Related

Blazor .NET Core app not deploying on IIS

I'm trying to deploy a blazor app on IIS following the article below
https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-5.0&tabs=visual-studio
I've installed IIS version 10.0 using the following settings:
I then created the site and changed the application pool to No Managed Code
I created a new Blazor app and deployed it immediately without changing a thing (so I know there's not a problem with the code). Looking in the project properties it's using .NET Core 3.1
I noticed there was no web.config file when I built the Release version.
I copied the Release version to the website directory.
Browsing to the site gives me a 403.14 - Forbidden error.
I read in another article to try configuring the Mapping Handlers this was the current state of the handlers:
I added a module mapping like so:
I now get a 500 error:
The web.config file currently looks like this:
I then read to add this aspCore line to the configuration file:
After that it looks like it loads but with none of the formatting.
I assumed hosting a Blazor site on IIS would be a simple thing to do, would someone be able to point me to where I am going wrong?

Deploying Asp.net Core 3.1 does not work on Windows server

I have this Asp.net Core 3.1 developed on VS2019 preview.
basically it is a blazor server-side app with referenced assemblies and some nugets.
it runs fine on VS2019 and on my IIS after publishing to folder..
problem is when i move that folder to windows server machine with IIS installed and everything.
an error with 500 code appears.
one thing i noticed here..the log_error.txt file in the server it points out an exception
,and that exception -what ever it is- showing the error line of the startup.cs file with my laptop directory path !
i mean it shows this C:/mrmeeez/..../Startup.cs line 411
but this path does not exists in the windows server machine
it supposed to be F:/.... somthing/Startup.cs line 411
i don't know if it has something too do with the problem anyway..or maybe my assemblies and nugets not shipping correctly to the server
windows server machine is working fine , i tried blazor app template and it ran perfectly.
i need your help guys , Thanks !
Ok , i found it
i don't know for sure is this related to asp.net core 3.1
because i deployed asp.net core 2.1 months ago and it was fine
anyway i used the development exception page in the final publish to see what causing the error and showed this
UnauthorizedAccessException: Access to the path 'C:\Windows\system32\config\systemprofile\AppData\Local\ASP.NET\DataProtection-Keys' is denied.
and after searching for that i found the answer from a guy in github
it seems that the user IIS_IUSRS for this application pool -by default- does not have permissions to access that path
to solve this problem,either one of the two below:
1-Give IIS_IUSRS permissions to access the system files -NOT RECOMANDED-
2-Change the user of the your application pool to LocalSystem account in IIS by going to Application Pools -> Right-Click your app -> Advance Settings -> Process Model section then change Identity
Reference: https://github.com/dotnet/aspnetcore/issues/1983
Thanks!

Publish .NET Code application to Arvixe Host

I have a ASP.NET Core with Blazor website and I want to deploy it to Arvixe host. The website is very simple and contains only UI elements no database required. I published the website to a local file system and uploaded it using FTP to the Plesk.
When I am visiting the website, I receive this error:
500 - Internal server error. There is a problem with the resource you
are looking for, and it cannot be displayed.
I have tried to run it on the IIS and I received more details:
Configuration The configuration file cannot be read due to
insufficient permissions.
I tried to add IIS_IUSRS to the group and users for web.config but I am not able to find it because I am using a windows 10 connected to active directory.
Besides, I still don't know how to solve this problem at Arvixe. Does anyone know tips might help?
500 internal error is generic issue. Please kindly check the error message on the server and paste it here. Make sure that your provider has installed .net core bundled on their server and here are tutorial about publsih .net core using plesk https://windowswebhostingreview.com/how-to-publish-using-web-deploy-with-plesk-control-panel/. It should be working fine.
You need to give Full Trust permission (Read-Write-Execute) to your application folder and also to Application Pool and also check if the Runtime version supported by Arvixe matches with your Asp.net Core version.
Also enable the logs in web.config file by setting stdoutLogEnabled="true" to get detailed error so that you can investigate more about the error.

ASP.NET Core web app response with 502 error

I'm investigating an issue with the asp.net core 1.1 web app.
We had to install the latest VS 2017 on the build server. And straight after that, all the deployed builds return 502 responses. Nothing changed in the app code or the referenced packages, however, many binaries are different after VS 2017 install. The deployment is done via FTP.
I also noticed there is now a small difference in Http response headers. API Response Headers used to have Server: Kestrel. But now, after installing VS2017, the deployed builds return Server: Microsoft-IIS/10.0. This probably explains 502 error, but why would the Server now switch to IIS?
Managed to fix it. The error is caused because IIS server (proxy) can't access AspNetCoreModule, the process that hosts kestrel. Usually, the reason is because kestrel in some trouble.
The solution starts with checking Application logs in Event Viewer on the server.
In my case it was:
Application 'MACHINE/WEBROOT/APPHOST/MyApp.API' with physical root '\servername\c$\inetpub\wwwroot\MyApp.Api\' failed to start process with commandline '"dotnet" .\MyApp.Api.Web.dll', ErrorCode = '0x80004005 : 80008083.
So, by googling the error code I've realised that the server didn't have the right asp.net core version (for some reason).
Downloaded the installer, works fine now! :)

Deploying MVC 4 application on IIS 7.5 Error HTTP 500.19

I am trying to deploy my asp.net mvc4 web app on IIS 7.5 under Windows 7 professional.
I have copied all the necessary files using publish method from Visual Studio 2010 express into folder D:\IIS\MyWebsite
This folder contains the typical structue MVC 4: folders App_Data, Content, Images, Views, Controllers, bin, App_GlobalResources, Scripts and some files at root like: Global.asax, Web.config.
I create a website with a name, let's me say as an example, MyFirstMVC on port 81 and associated to a custom app pool, let's say, MyAppPool (using ApplicationPoolIdentity) which is in integrated mode and using NET Framework 4 as my web app is developed in NET Framework 4.
When I run it below error is raised:
Error HTTP 500.19 - Internal Server Error
and above the example I can see in configuration source section below messages:
49: <modules runAllManagedModulesForAllRequests="true" />
50: <handlers>
51: <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
I have tried to add IIS_IUSRS to my root folder 'MyWebsite' and give it full control permissions but it does not work. I have tried some things discussed here:
How do I resolve "HTTP Error 500.19 - Internal Server Error" on IIS7.0
Also I have observed that once opened inetmgr when I select the root node of the Connection tree on the left, then in the panel on the right, there is no ASP.NET group, only IIS and management so I am not sure it is normal, maybe is there something wrong with ASP.NET¿?
SOLUTION:
Finally, I have solved it by running following command as in internet information services ASP.NET was missed:
%windir%\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_regiis.exe -i
%windir%\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
in my case the path is pointing to Framework64 because I am running on a Windows 7 professional x86_64.
I had same issue. MVC4 application with IIS7 under VS 2012 (windows 7 with 64 bit).I solved the issue with below command.
Run -> CMD (administration mode)
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis.exe -i
I had a similar situation but was receiving a 404 error. I'm running VS 4.5, IIS 7.5 and the website is MVC 4.5. I ran only the one line above which resolved my problem as well. thanks!
%windir%\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
NOTE: i figured it was something like this since I received an error when trying to review ".NET Complication" within the webapp of IIS.