How to run Blazor Web Assembly locally - blazor-webassembly

Is it possible to run a Blazor Webassembly app after publishing from the file system, invoking the index.htm in wwwroot? If I do this, the app doesn’t run. The console shows the following errors:
How can I fix this? Or is it not possible to execute the app in this way?
(For info, this is the .Net 6 Blazor Wasm template without any changes, just created and published the template.)

You can use any number of web servers to do that - this is my opinionated answer
https://www.nuget.org/packages/dotnet-serve/#readme-body-tab
Get started
Install .NET 5 or newer and run this command:
dotnet tool install --global dotnet-serve
Start a simple server and open the browser by running
dotnet serve -o
..and with HTTPS.
dotnet serve -o -S

Related

Where to find coredump on Azure App Service using Linux?

I am using Azure App Service hosted on linux to use a .Net Core 6.0 app.
I have a null pointer error that is resulting in a segfault, that in turn is taking down the app service. I have had a few errors that result in segfaults so while I can fix the null pointer I really want to find why the container is crashing.
I can see the the following in AppServiceConsoleLogs:
/opt/startup/startup.sh: line 17: 65 Segmentation fault (core dumped) dotnet xxx.dll
I am hoping if I can find the dumped core I might figure out the segmentation fault.
I have looked around the folders by going into the SSH console, but I cannot find anything that looks like memory dump.
Where to find coredump on Azure App Service using Linux?
I have deployed the .NET Core 6 App to Azure App service.
Navigate to Azure portal => your Deployed App Service => Advanced Tools => Go .
Click on - Site wwwroot.
Deployed files will be compiled into dll files.
Click on the file, you can see the content.
We can also check the files in Bash.
In Bash, Navigate to the Application root directory and run ls.You can see the deployed files.
In Configuration section => General Settings, check the startup command.
It has to be
dotnet YourAppName.dll
Make sure the dll is available in Bash or SSH.
Update:
We can find the core dumps in LogFiles/core folder.
But initially, it is disabled.
To enable it, we need to add the below command in Startup of the deployed app service.
ulimit -c unlimited
Thanks #Sourabh Edake for the command.
Restart the app. Whenever there is an exception, the core dump will be created in the mentioned LogFiles/core folder.

Unable to publish the artifact for .NET Core on Azure Devops (pipeline)

Unable to publish the artifact for .NET Core, I can able to build but can't publish on Azure Devops.
Frontend: Angular
Backend: .NET Core 6
SQl : MSSQL server
Front code : Angular,
Back end : dotnet 6,
Sql : MSsql Server
Given that your project could be restored correctly, I suppose that you could add a --no-restore to your dotnet publish argument and test again.
Updated on 1/2
======================================================
I suppose there are multiple possible caused for your current issue of https 500.30. You could visit this doc to troubleshoot.
Additionally,
1.Check your hosting model. Confirm that whether it's IN Of Process or Out of Process. You can check the configuration in you csproj file. if you using In of Process, try to change it to
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
2.If you are deploying win-x64 app and try to have it published using an Application Pool that supports 32-bit apps, you will need to make them match-up.
3.Check in portal.azure.com for your web-app whether it is running correctly.
4.Go to portal.azure.com check you app console, and try to manually start your project with dotnet ServerApp.dll.
==========================================================
Updated on 1/9
Hi devendar
Check this doc Bad Gateway errors in Application Gateway for further troubleshoot.

How dotnet.exe serves blazor web assembly files

Can someone explain or refer to a document on how a blazor web assembly app is served by dotnet.exe process?
So here is what I have done and what I know.
Scaffolded a new blazor web assembly project using the command dotnet new blazorwasm -o BlazorTest.
Ran the project using the command dotnet run and it runs as expected.
Remember I am not using the --hosted parameter to include ASP.NET Core server.
As far as my understanding goes, the output of blazor web assembly project are set of static files which run inside of a browser process. In order for these files to run inside of a browser we need a web server like kestrel/iis or a cdn to serve these files.
Now my question is, in the current setup where is that webserver or cdn present which is required to serve the files?
The dotnet CLI is reading your Properties\launchSettings.json file.
The default profile launches the app using IIS Express.
If you want use the other Kestrel launch profile that is included in the template, you can use:
dotnet run --launch-profile "BlazorTest"
Note: The "project" profile will be scaffolded as the name of the app you specified in dotnet new

ASP.NET MVC project to push to a remote server

I have a ASP.NET MVC project locally, but want to push to a remote server so that others can use that website. I have login access to the remote server.
Is this what i need to do?
1) add a folder to IIS in the remote server
2) copy my files to the folder on remote server. If so, which files should i copy?
If you're using Visual Studio (not code) then right click on the project and select publish, then select the options to publish to a local folder. Copy all files in your published folder to your server.
If you're using ASP.NET Core then you can also navigate to the project folder and use the following command
dotnet publish -c Release -o PUBLISH_PATH_HERE
You will need to ensure that the server has your version of .NET runtime installed.
Create a release publish profile, publish, grab the files from the directory it published to. This is the simplest way. You can automate this process if you have many releases. For example publishing directly to the server or checking code into a source control of some kind and having it publish to the server.

Deploy asp.net react template without nodejs dependency on IIS server

I'm having problems with deploying and running the ReactRedux template on an IIS server which doesn't has nodejs. The app was created using AspNetCore.SpaTemplates' "reactredux" option:
https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/
The app is the same as the template, no changes were made. We first tried to host it on IIS with nodejs installed on the IIS server, everything works fine:
screenshot with nodejs
But when we uninstalled nodejs from the server and restarted IIS, it wasn't working anymore:
screenshot without nodejs
We couldn't figure out what the error is because running it in development mode requires nodejs and when we run it with dotnet run in development mode the error message complains about node.js not being installed, as expected.
We tried to deploy the app running:
$Env:ASPNETCORE_ENVIRONMENT = "Production"
dotnet publish -c Release
and using Visual Studios build>publish interface.
Acording to the docs here, the app shouldn't need nodejs when its deployed for production:
https://learn.microsoft.com/en-us/aspnet/core/spa/react?tabs=visual-studio
Unlike the development build, the production build doesn't require
Node.js to be installed on the server.
I'm new to asp.net and deploying apps on IIS, maybe the solution is trivial but we couldn't manage to solve this, thanks in advance.
If you don't want any nodejs dependency, make sure you disabled server-side prerendering:
https://github.com/aspnet/JavaScriptServices/issues/932
If you're not doing server-side prerendering, then you will not need
Node.js on your production server, because all the JS will be executed
on the client side.
If you are doing server-side prerendering (which is the default in the
React-Redux template in this repo), then you do need Node.js on your
production server, because the prerendering process involves executing
your JavaScript code on the server.
To disable server-side prerendering do the following:
Remove asp-prerender-module="ClientApp/dist/main-server" from Views>Home>Index.cshtml
Remove #addtaghelper "*, Microsoft.AspNetCore.SpaServices" from Views/_ViewImports.cshtml

Resources