Using SignalR Without an ASP.Net Core Server - c#

After my research SignalR is a middleware I can use in ASP. Is it possible to host the server part in for example a console application or a dll?
I've read about SignalR webhost, but the guide is for .Net Framework: https://learn.microsoft.com/de-de/aspnet/signalr/overview/deployment/tutorial-signalr-self-host

Not 100% sure what you are asking.
SignalR is built into ASP.NET core, you can reference and use it within the same application, which can be running in IIS, or self hosted, even asp.net core web apps are basically console apps, but there will need to be a web (internet aspect to your application.
There are also specific Azure services to handle signal R if that helps
https://azure.microsoft.com/en-gb/services/signalr-service/

Related

Why does the official Microsoft tutorial have me push two copies of the same dotnet core app as the "frontend" and "backend"?

I'm pretty new to Azure, and I wanted to get familiar with using Azure AD auth as an authentication provider for a dotnet core web app.
I followed this tutorial: https://learn.microsoft.com/en-us/azure/app-service/tutorial-auth-aad?pivots=platform-linux
It worked as described, but I have to be missing something, because the way it's deployed doesn't make any sense to me.
The "starting point" tutorial code is this repo, here: https://github.com/Azure-Samples/dotnet-core-api
It's a simple dotnet core web app that hosts an Angular frontend. Through the course of the tutorial, you make some changes to get the "frontend" to talk to the "backend", and you add two remotes to your Git repo - frontend and backend - but they're on the same repo.
As I understand it, at the end of this tutorial, I have two nearly-identical Azure App Service instances running in my Azure resource group. They are both running the same code. Both include the full-stack application - both are hosting a Kestrel or HTTP.sys (or whatever) instance on port 443 at their respective .azurewebsites.net URL - both show my index.html page - but one is supposed to be the "frontend" and the other is supposed to be the "backend". The only thing different about the "frontend" and "backend" is that the "backend" has an identity provider configured, and the "frontend" has API permissions granted to it from the "frontend".
Is it really necessary to have the whole service running in both places? Is there a way to host the actual dotnet core API service as an App Service, host the HTML / JS / CSS separately as an Azure Static Page (or something similar), and still configure the identity provider? Or does it have to be like this? It seems like overkill, from a technical standpoint, as well as from a billing standpoint.
As #Caius Jard mentioned, we can include both of them in a single solution. We can actually use MVC Web Application in this case where we can create a frontend in view and write the actual code in control. If we are using a core application then we can create the backend and frontend in two environments such as Angular for Frontend and .Net core for Backend and integrate them.
REFERENCES:
Azure AD Authentication For MVC Web Application (c-sharpcorner.com)
Angular and .Net core - Azure AD authentication | The-worst.dev

How to Access WCF service in Blazor Server App

I am learning about Blazor server apps. We have an existing asp.net MVC application that communicates with a WCF service via netTcpBindings. We are now thinking about moving our development into .net Core so based on that Blazor Server seems very cool to start with.
My question is, how can I consume the existing WCF netTcpBindings service on any new Blazor Server application? I have tried googling this but could not find much on the subject. Is it even possible to consume a WCF service in .Net core (because from what it seems WCF is not brought into .Net core)?
It is still possible to consume WCF from a .Net Core application. Bear in mind that it is nothing else than a communication protocol, so it doesn't really matter what "language" you are using as long as you are able to connect to the server providing the service and you implement the protocol.
Luckily the Microsoft people have that in .Net Core so
Say you have the following service:
on your Server on the Startup.cs file you can then do something like this:
Done, you may now invoke your WCF service from your .Net Core server

SignalR in ASP.Net Core self host

Is it still possible to self-host a SignalR Hub (server) without using IIS / Kestrel?
MS does not have any information as though if it is still possible (using asp.net core migration) to achieve this.
My use case for this would be to be able to deploy both the client and the server to local machines and then be able to easily switch to remote servers at a later stage. Ideally, the client would host the server for now.
ASP.NET Core implies using Kestrel as its web server. That means that in order to host a SignalR hub (server), you will need to use Kestrel and basically build an ASP.NET Core application.
You will however not need to use IIS or some other web server to host the application. Kestrel on its own already is a full web server, so you can use it directly without needing anything else.
The ASP.NET Core application hosting your SignalR hub also doesn’t need to do any other web-stuff. It would be totally fine for it to just contain the single hub and host just that. So you usually don’t need to worry about it too much.
So, to address your use case: Yes, you could have a separate ASP.NET Core application hosting the hub and start that directly on the client and the client could connect to it. And then later you could have another ASP.NET Core application hosting the hub running elsewhere and reconfigure the client to use that one then.
Yes, you can self host .NET Core SignalR.
A SignalR server is usually hosted in an ASP.NET application in IIS, but it can also be self-hosted (such as in a console application or Windows service) using the self-host library.
You can read more about it here.

How to provide RESTful web service(s) from WPF application?

Typically a WPF application is a consumer/client of a RESTful service(s) on a web server. I would like to have it reversed - WPF application should be able to expose an web API. This would be consumed by an web app.
The flow:
web app ---sends a command to--> WPF app
** WPF app makes a 'long running job' until its user decides to stop **
WPF app ---passes data back to--> web app
The communication should be in Json format. I have prepared OpenAPI (in YAML) schema for it at the http://editor.swagger.io/. In the future it could be used to make changes to the WPF app's web API.
It allows to generate ASP.NET Core server c# code stub. What would be the requirements to run ASP.NET Core server in WPF and weither it would be light weight enough for use?
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
// somewhere in the WPF app: BuildWebHost(args).Run();
The code is auto-generated by https://github.com/swagger-api/swagger-codegen.
There is a post which failed to integrate ASP.NET Core 2.x into WPF application. Unfortunatelly, ASP.NET Core 3.0 and later will only run on .NET Core.
I have some bits here and there but not a working concept. My options could be:
Use a 3rd party framework or library. Should be able to use OpenAPI/YAML schema or Swagger generated server stub code etc.
Could ServiceStack be the missing piece here?
Integrate ASP.NET Core into WPF. Is it is even possible?
Launch a separate web server (not a self-hosting) with web services from the WPF application. Sounds bad.
Implement WCF web service(s) and requests.
...
How to implement the web server/service(s) at WPF side? Maybe there is an existing 3rd party framework which could save me from reinventing the wheel?
PS. There is a similar question how to expose a restful service inside a WPF project but it is outdated.
This sounds like your requirement:
WPF application should be able to expose an web API. This would be consumed by an web app.
But then you're against the only solution that would make it possible:
Launch a web server with web services from the WPF application. Sounds bad.
I'm not sure how else you're expecting being able to expose a Web API without launching a web server? Inside a UI App you'd want to launch a self-hosted Service.
Self Hosting
In ServiceStack you can just start a self-hosted Service in your WPF App which can either be a self-hosted .NET Framework HTTP Listener or an ASP.NET Core on .NET Framework App. Both options Microsoft have said are going to be supported indefinitely, but .NET Framework is being phased out with ASP.NET Core 3.0 only going to run on .NET Core and .NET Framework stopping development at v4.x as .NET 5 is just going to be the next version of .NET Core.
But that shouldn't change what solutions are available to you now, if you need to run a Web Service in a WPF .NET Framework App you'll need to run a self-hosted .NET Framework HTTP Server which can either be a self-hosted HTTP Listener or ASP.NET Core (on .NET FX) App.

API written in C# using nancyfx running on WampServer

I am still relatively new to writing API's and web services, so bear with me if I use incorrect terminology.
I want to know if it is possible to create an API in C# using nancyfx (or any other framework) or even just a simple web app and then set it up as a continually running web service using WampServer. I'm pretty new to Wamp, all I have done so far is create a few rudimentary pages with php; but I can't seem to find any information about running a web service with Wamp using a different back end language other than php.
WAMP is stand for Windows Apache MySQL PHP. As I can say, you can't run a C# web service with it base configuration. However, you actually don't need this. If you are on .net Core, there is a Kestrel web server. You can use it to serve your app. On a .net framework you have a HttpListener which can help you to implement self-hosted web service (for example, a windows service which hosts your application).
There are many other options, btw. Try google for some kind of "Hosting .net web application" or "Self-hosted .net web application"

Categories

Resources