Hosted Blazor WebAssembly with Admin Pages - .net-core

I have a Blazor WebAssembly application that is being hosted by an ASP.NET Core backend. In addition to serving the Blazor application, the backend also has a few API endpoints used within the Blazor application along with some pages that serve as an admin dashboard.
During local development, all was working correctly and I could navigate from inside the Blazor application to an admin page and back again. Once I published this setup to a development server the Blazor app seems to be blocking any requests to the admin pages. I know this is possible as that is what the built-in identity system does. Whenever I try to access my /admin page the Blazor application stays open and shows the message: Sorry, there's nothing at this address.
What do I need to adjust to have things operate as they do locally?

After further research, I discovered that my problem is because of how the service-worker.published.js handles requests. I have this application setup using the PWA feature for better offline support.
For more information on this subject check out the documentation Microsoft provides here: Support server-rendered pages

Related

How to fix problem of mixed content https & http with angular and ASP.NET Core Web API?

I have deployed my backend app made with ASP.NET Core Web API to Smarter Asp and my API is at http://smartapi.com/..... .
I have deployed my frontend app written in Angular to Netlify and my site is: https://astonishing-speculoos-d0b898.netlify.app/
Now, I have a problem that netlify doesn't accept requests with http in its website. How to fix this problem to make my API backend requests work in netlify website?
If you have a look at SmarterAsp's website, it actually seems to be possible to get a free Let's Encrypt certificate.
Link:
https://www.smarterasp.net/free_lets_encrypt_ssl_hosting
When you've added the Let's Encrypt to your hosting plan, you should go ahead and change the URL's for your API calls to include "https://" rather than "http://"

How to configure Blazor Webassembly Core Hosted app to serve an index homepage from the server prior to loading the app

I have a made an application using the Core Hosted Blazor Webassembly template provided with VS 2022 using .Net 6.
When you start up the server and navigate to the base url it immediately loads up the whole webassembly application - then checks the authentication - sees that the user is not logged in - then redirects to the Identity page for login. Once logged in the user is navigated back to the webassembly application and it goes through the whole load and boot a second time. (It uses the cached app files, so it's not quite so slow, but it's still slow.)
I would like instead to serve an index page directly from the server - this could include a login but also some brochure introduction information - the user could then login and potetially be directed to other server side apages before being routed to the webassembly application.
I can't seem to figure out quite how the server side project decides to boot the webassembly application - I've tried changing the root path using:
app.UseBlazorFrameworkFiles("/UI");
but this still loads the webassembly directly.
I tried adding a wwwroot folder to the server side and adding an index.html there for the server to load - but this results in a conflict with the one that's in the client project (so this is getting copied into the root by reference, I think. IS this done by convention alone or is this configured somewhere in one (or both) of the projects? CAn I move the webassembly to be in an Area or subfolder of the server side without breaking the Identity Server authentication and routing? If so, how would I go about it?

What role does a web sever play in hosting of single page applications

As per my understanding, when user visits a url of a SPA application, the whole application is downloaded including any static html,assets and javascript. Can someone please clarify what role does the host web server play from there on? If after download of all the assets, I turn off the web server the application does not work. But ideally, it should work because now all the code to create any views is with the client already in form of javascript files. Let's assume there are no API calls for data.
Yeah it will work
If the application is fully loaded in browser it will work even after you turned off or disconnect the web server
Web Server No Need after the client has downloaded all the assets

Auth0 Authorization Stops Working When API is Published (.Net Web API / Angular)

I am currently using Auth0 with Loc7 in Angular and an ASP .Net Web API v2.
The project works fine locally. The user can log in using the widget and the API sees the User as authorised with no issue.
When the app is published the API returns 401 unauthorised when a call is made.
There is no issue with Angular app no matter where on the web space it is placed so I do not believe it is an issue with the Allowed Callback URLs in the Auth0 dashboard.
The config works fine locally and there are no major changes when being published except the database connection string.
The database is an exact copy of the local database.
The API MVC Template works fine but does not do anything aside from load and show routes. I have not changed the template since it was generated.
There are no errors on the server.
The API is in a newly created app directory on the server.
Auth0 Dash reports the login from the Angular code successful. The profile is returned with a valid token viewed through the dev console.
Has anyone else had a similar issue? Could this be an issue with how the hosting is set up?
Happy to post more info, I am not really sure what to post it is a fair amount of code.

Any modification necessary to web api project web.config when web api project is created as a web application under an asp.net web site?

I have an asp.net web site which runs on port 443 which is https. I also have a asp.net web api which also needs to run on port 443. Because of that, I decided to create a new web application under asp.net web site. I also created a new application pool for that. The problem is that when I try to run web api project, I keep getting configuration file errors. For example it says Default Connection is already added since asp.net web site web.config adds Default Connection already before web api project does. Are there any special steps to take in order to make this work?

Resources