Blazor WebAssembly deployment failed to IIS localhost - c#

I am trying to deploy my blazor WebAssembly project to IIS localhost. However, it does not load in the browser with the following errors:
So far I have tried to resolve this issue by setting "PublishTrimmed" to false. This did not resolve my issue. I have seen other people online have a similar problem and recommended the fix just mentioned (which did not resolve the issue for me). Thanks.

The fix for me was to delete the bin and obj folders in, both, the server and client projects with "PublishTrimmed" set to false in the csproj of the server project. Then use dotnet publish -o "location" -c release in powershell (in the server project directory) to publish to the target location set in IIS. Now everything works as expected.

Related

Blazor webassembly publish to local folder failing

I am trying to publish my site to a local folder so I can upload it to Github Pages. I first created the site as a Blazor Server app and that worked without errors. I then made this into a Blazor webassembly and am now getting this error:
Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(614, 5): [MSB6006] "C:\Program Files\dotnet" exited with code 1.
I have tried using Visual Studio, Jetbrains Rider and command prompt and all of them have returned the same error. I have tried with PWA enabled and disabled but nothing has worked. Can someone help?
There is a bug in the last asp.net core which prevents projects from building if they are located in a folder with spaces (Program Files in your case).
Can you try moving the project to another folder (for example C:) and try again?

Razor pages always gives 404 unless using dotnet run

I have a razor pages project that until recently worked fine, and on a colleagues computer works fine. On mine however, when running from Visual Studio or publishing to Azure via Visual studio it returns 404 for every page. Everything works as expected if I bypass Visual Studio and use dotnet run instead. Interestingly, previous commits that worked fine for me also now have the same problem. Which leads me to think its something environmental, but I can't track the cause down.
I also faced the same issue .
Try to use dotnet build instead of dotnet run.
Also check you map the path in azure configuration for your application in the azure app service

Docker-Compose Connection Refused with ASP-NET Core 5

I've been using ASP.NET Core 5.0 for a project and running it via docker-compose inside VS2017 Community.
Previously when I ran the project it would connect to a port automatically published by Visual Studio and load the web application (see image 1). However, similarly to another project, it simply refuses connection when debugging starts (see image 2).
Even when manually publishing the ports via the ports: portion of the docker-compose.yml file it still refuses connection.
After trying to find a solution to no avail, I've turned to asking here. I've tried all of the following:
Restarting Visual Studio
Deleting the .vs folder and restarting.
Restarting computer.
Exposing ports 80 and 443 explicitly in docker-compose.yml
Checking out to previous, known working commits.
As mentioned before this behavior has also started occurring on a university assignment which is running ASP.NET Core 3.1, which I prefer to have working before it's due.
I did Clean/Purge Data on Docker Desktop for Windows, restarted and it seems to be working now. I really wish I knew what actually causes this problem so I can avoid in in the future....

HTTP Error 500.19 when publish .net core project into iis with 0x80070005

I want to publish a sample .net core web application on my pc's IIS manager but I failed. I am using Microsoft guidance but it doesn't work for me, if you have reasonable experience to fix this problem I would be grateful to see your suggestions.
I was missing the AspNetCoreModule from IIS->Modules. After I installed that I no longer had the 500.19 error.
To find out more this blog was great: https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS
Here is the page from Microsoft to find the download: https://learn.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x
You have to install the "Hosting Bundle Installer". Without this, IIS doesn't understand routing and cannot host your application.
Go to microsoft site "https://www.microsoft.com/net/download/dotnet-core/runtime-2.1.0-rc1" and install "Hosting Bundle Installer":
Before installing this you have to install the right version of runtime:
https://www.microsoft.com/net/download/dotnet-core/runtime-2.1.0-rc1
Than install the right version of "Hosting Bundle Installer".
"Hosting Bundle Installer" is:
.NET Core Windows Server Hosting bundle installs the .NET Core Runtime, .NET Core Library,
and the ASP.NET Core Module. The module creates a reverse proxy between IIS and the Kestrel server on Windows platforms.
The identity under which your web application runs in IIS doesn't have full access to the folder in which the web.config file is found.
Which version of IIS are you using? Assuming 7, you can view/change the identity through the 'Advanced Settings' of the application pool that hosts your application. Folder permissions can be granted via Windows Explorer in the usual way.
Sure, you have to follow this tutorial to deploy to IIS:
https://learn.microsoft.com/en-us/aspnet/core/publishing/iis
I would suggest you to do this:
Publish your web application to desktop.
Copy the folder to the server.
Open cmd and run cd
In cmd run
dotnet webapplication.dll
You should see that application is run and waiting for responses on localhost:port.
Open browser and navigate there. It should work.
Otherwise, you will be able to see all the errors in the cmd window.
OR
Go to microsoft site "https://www.microsoft.com/net/download/dotnet-core/runtime-2.1.0-rc1" and install "Hosting Bundle Installer":
In my case I was getting the same error.
It was nothing to do with the permissions.
I had to install the followings
1- Microsoft .NET Core Runtime
2- Microsoft ASP.NET Core Runtime
3- Microsoft ASP.NET Core Hosting Bundle
from the below location. (Please chose the relevant version)
https://dotnet.microsoft.com/download/archives
Then I had to execute the following commands as well.
net stop was /y
net start w3svc
You can either restart the machine.
That fixed for me.
Try to edit/open any configuration for the site.
If you can't access the configuration options for the site under IIS Manager, check commenting the tag < aspNetCore >, if problem solve, uncomment it and install.
ASP.NET Core Hosting Bundle.
ASP.NET Core 3.1 Runtime (v3.1.3) - Windows Hosting Bundle Installer.
Write dotnet --info in your command prompt to see your SDK versions. (after words .NET SDKs installed:)
Find your equal Hosting Bundle version and install it.
For example : SDK 3.1.408 needs Hosting Bundle 3.1.14.
https://karthiktechblog.com/aspnetcore/how-to-solve-http-error-500-19-internal-server-error-in-windows-server-iis-for-dotnet-core-application
We've observed this problem on our server even though Hosting Bundle was already installed. The problem was, the hosting bundle was installed BEFORE IIS feature was enabled. The fix was to Repair hosting bundle install by running the installer again.
Very good, in my case a module called "urlrewrite" was missing.
You install it with the "Microsoft Web Platform Installer" application.
I also had this problem and the problem was solved by installing the Hosting Bundle Installer.
You can install from url:
https://dotnet.microsoft.com/download/dotnet
We had a slightly different issue at my work. We had a publish profile in Visual Studio set to delete all files upon publishing, and this was a problem for us because we manually gave our IIS service account filesystem permissions to that one, explicit folder beforehand.
So with that publish flag enabled, it zapped the folder and its permissions alongside it and caused a filesystem permissions issue after.
We just disabled this flag in the Visual Studio publish profile and it was fine after that.

ASP.NET 5 RC1 Deploy To IIS Hangs

I installed the RC1 version of ASP.NET 5.0 on a Windows 2012 Server running IIS. After publishing my ASP.NET 5 application to the server, I try to access the default web page and the web browser hangs (it just clocks indefinitely). Everything runs correctly within Visual Studio. It only does this when I publish it to an IIS server.
I followed the instructions in this lunch to publish and deploy to the IIS server: http://docs.asp.net/en/latest/publishing/iis.html.
Has anyone else experienced this and resolved the issue? If so, what did you do to fix it?
Joel,
I ran across the same issue today, trying to deploy ASP.NET 5 applications to IIS on Azure VMs.
You might not be deploying the DNX runtime with your application, or something is preventing/killing the Kestrel or WebListener process. From what I found, the request hangs because Kestrel (or whatever listener you're running with dnx web) doesn't start, or crashes during the request.
For me, this happened because I wasn't publishing the application properly with dnu publish.
Check the ../approot folder and ensure it has the following directory structures:
../approot
/packages // NuGet Packages
/runtimes // DNX lives here
/src // Your code
If you're missing /runtimes, you'll see the request hang.
To add them, I used the following command:
dnu publish --out <output directory> --configuration <build configuration> --wwwroot <web root name> --wwwroot-out <web root output name> --runtime <either "active" or current runtime> --iis-command web
If this doesn't fix the issue, something may be crashing the application process.
What helped me is to run
dnu restore
command after copying files to the server.
It appeared, that IIS couldn't start approot\web.cmd, I've found that after running web.cmd manually. Then I googled the error and came to this answer

Categories

Resources