ASP.NET Core 2.2 PWA offline - asp.net-core

I Have ASP.NET Core project and want to make it work also with PWA and it needs to work also offline.
I know there are prefetch and preload options but i'm little bit confused
How to achieve that?
Thanks

First, the PWA and the service worker itself are decouple from the server, which in your case is ASP.NET.
As far as what you cache and how that is all up to you. You need to determine what is best for your user experience.
In a way, the service worker can be thought of as a web server and you have to code the application layer to manage your requests.
DO NOT go nuts and try to recreate your ASP.NET and all the server logic in the service worker. Not what you should do there. Seen that too many times already.
I have an article covering basic service worker caching concepts if that helps.
https://love2dev.com/blog/service-worker-cache/

Related

Slow initial Request .NET Core

Sitting in front of the task to create a new small service, I am wondering if there is some best practice guidelines to ensure a fast response time (including the first 1-3 requests) for that service.
First of all I love to create services with .NET Core and the webapi template (.NET Core 6). But having created some of them I notices the delay for the initial request for the service is very slow and all subsequent request on other endpoints are slow as well.
I was wondering if there is something I can do to prevent this, is there some advice to achieve this without sending requests to all endpoints on service start?
The service is not running on AWS or another lambda service like host. The .NET Core services "feel" slow if you compare to fast starting other services written in e.g. Node. I know the real performance(latency, throughput, ...) is another beast and I am very satisfied with that.
I found the following articles but was not satisfied with the result and/or conclusion.
https://andrewlock.net/reducing-latency-by-pre-building-singletons-in-asp-net-core/
https://blog.markvincze.com/running-asp-net-core-in-auto-scaling-containers-warm-up/
Is there a better way to "warm" the service or reduce the impact of the initial request?

Real Time Notification Using ASP.Net

I want to build a real-time application where user gets notified for each update on the server. User is logged in on site and would be notified in real time(one to one).
What is the best way to achieve this?
I am using ASP.NET MVC 4 for server side and I need a better and reliable option to achieve this.
The best way to achieve this depends on your exact requirements. Without knowing that, an option to do it would be by using SignalR.
Part of the SignalR resource page also contains a demo for using SignalR with MVC 5. Other resources for SignalR are available online.

Azure WebApi vs Azure Mobile Service vs

I've programmed a lot in asp.net mvc web applications. Now I want to write cross-platform mobile applications with cordova for the frontend and azure for the backend.
I am in doubt whether to use azure mobile services or WebAPI, because I want the power and freedom of WebAPI, but the convenience of azure mobile services. I do not understand concepts such as authentication, push notifications, etc.
My main goal is to focus on the application logic, frontend and backend with a significant weight of that logic in the backend. For this I have great doubts.
1st. I see both good mechanisms in AMS and WebAPI for external authentication, but not to manage your own authentication. What is the best way to manage your own authentication? Is Azure Active Directory solution?
2nd My intention is to create a well-defined API methods that return the exact data (json), rather than a rest api queryable (odata).
Wich is te best for this, WebAPI or AMS?
3rd I have experience with SQL Server, its relationships and Entity framework, but I do not care to learn and use NoSQL technologies, which is better? (However, I'm not comfortable with I can not use many to many relationships in NoSql).
Thank you very much.
there is not a real general answer for that, so take these as advices.
At first, keep in mind that AMS and WebApi are not so far. An AMS project IS a WebApi project with some helpers inside to make you comfortable working with related services (push notification, table entities), but you will lose a bit of control on your application.
The choice depends on your needs
Azure Active Directory IS a solution, but there are a lot more. You can use your preferred framework. AMS has got a pretty integrated login with most known social network and azure active directory as well, and is very easy to set up.
I'd suggest AMS. It will be easier to setup and mantain.
AMS is just WebApi castrated. To get all these services easier for you, you cannot for example
Customize startup of your application
Use a dependency injection framework
Run background tasks
And other stuff like that.
Hope it helps!

Can I use ravendb in a javascript SPA

I am developing a application that is using backbone.js for most of the front end logic and was thinking of using sqlite for storage, but i have run into a few complications with it and need to switch to another NoSQL database.
I see on ravendb's site that it was created in C# and you need a .net compiler. Most of the docs are for ASP MVC type application. I can not go this root because we are developing this as a tablet application with no microsoft based technologies on the client side ( because we want it to work with android and apple )
The server however will be .NET and so i figured this might be do able. Just wondering if this is worth pursuing and if anyone has had any experience using ravendb? Or should i go for mongodb?
It is possible to expose RavenDB directly to a JavaScript application, sure. But it's usually not recommended. The main reason is security, but there are many other reasons to have a middle-layer.
For example, you often need a server-side location to perform application logic. Not everything can be done in the database itself, and if you do it all in the application then you will probably send a lot more data to the app than it really needs. Over the internet, that could mean a slow app.
The route many people take, is to use ASP.Net WebAPI, or ServiceStack, or another similar framework. This gives you a way to expose REST endpoints that your JavaScript app can call. You can connect to RavenDB from there.
Also, you seem to have the misconception that if you used ASP.Net MVC on the server that you couldn't target Apple or Android. That's just false. Whether you use a SPA approach or a traditional approach, you are delivering standards-based content, such as HTML, CSS, JSON and JavaScript.
Yes, You can use it. Actually RavenDB's server is a RESTful web service, which means you can work with it with any kinds of HTTP clients. These clients should be able to issue standard HTTP verbs like GET, PUT, DELETE etc.
ASP MVC is server side. I still at a loss as to why you would want to expose your db to a clientside piece. It is completely worth doing in a server side piece, but do not expose something like a db directly to your client.

For a multi platform client end, do I NEED WCF or can I get by with MVC 3?

I have a web application in MVC 3 (3-tier with a Data Access Layer) that I'd like to extend to native iPhone and Android etc... as presentation devices.
Can I just use the same controllers with some modifications or is it better to organize the access logic into a WCF service?
What are you recommendations in terms of good scalability and performance?
For scalability, it would be better to have your business logic in a service that your UI (MVC site, iPhone app, android app) simply calls. I personally suggest using ServiceStack over WCF, as it simplifies your calls down to POCO objects. This will help for scalability, as well as maintenance as it separates your concerns much clearer (I suggest you read up on the SOLID principles). If you need to make changes to your UI, those changes will not affect your business logic (which would have caused your iPhone app to change possibly)
It all depends. You can certainly go the route Justin recommends. There's a lot of work in that, though.
MVC4 has WebAPI, which gives you RESTful services from within an MVC controller-like environment. This allows you to add a service layer to your MVC app with minimal effort.
For anything large scale, you should probably go with a full WCF implementation.
FYI, MVC4 is in beta, but there is a go-live license, and you can install WebAPI without installing MVC4, it's availble via nuget.