Send message to cshtml page via RabbitMQ - c#

I have:
ASP.NET MVC site for sellers.
A separate server which uses RabbitMQ to send messages.
How can I get these messages at cshtml page? I can subscribe to RabbitMQ at server side of ASP.NET MVC and use SignalR to send message to client, but it seems ugly.

Related

How to a listen to an HTTP response from iframe?

I have a website where I use Angular for the frontend and Asp.Net Core for the backend. I have an iframe of a different website that I don't own, rendered inside the website. And after a certain amount of time the iframe redirects to the API and sends a POST request to the API. Is there a way to check when the request is completed and perhaps even get the response from the API, so that I can close the iframe or redirect to another page.
When the iframe site makes an API call to your ASP.NET Core backend, send the event to your Angular front-end. Any method of pushing events to a SPA client will work. You could create your own polling process that runs (when the iframe is first opened) or you can setup SignalR and push a server side event to the Angular client using a websocket.
There are some limited ways to communicate between an iframe and its host, but most of those require you to have access to modify the app/site that runs inside of the iframe.

.NET application to get iis headers and redirect

We have a front end application developed in React and have backend services developed in ASP.NET Web API. We are using webseal (EIAM) for authentication and the way we have is we send a request to webseal using React. Webseal authenticates and send a request with user details in iis server and it will not send the request to browser for security reasons. So we could see in iis logs the user details on the request headers but I am not sure how to get those iis headers. Both React and Web Api application are hosted in iis. So do I need to write a separate .NET application to get the headers and if so how can I read the request headers coming to application pool where React is running. So what I want is to read the request sent from webseal to IIS and get the headers.
What I have tried is to use a Default.aspx page React project and I could get the header there but the Default page is called every time. I tried writing URL rewrite and see if I can set to servervariables but I might be doing it wrong it is not working. I tried to have another web api project and have a DelegatingHandler but it only works if there is a request coming to API controller, I cannot have something like check the incoming requests to iis and if the referer is xxxx and if the header iv-user is present then get those headers.

Communicate web app and api project using SignalR & StackExchangeRedis

I'm working with a project built with ASP.NET Core 2.2. The main solution contains multiple projects, which includes API, web and other class libraries.
We've used SignalR to displaying shared messages/notifications between the API project and the web project. For example, adding a new employee record from an API should call SignalR Hub and all the web client should received the notification.
To make it communicate, we have used Radis with SignalR
// SignalR Configuration
services.AddSignalR(option =>
{
option.EnableDetailedErrors = true;
option.KeepAliveInterval = TimeSpan.FromSeconds(3);
}).AddStackExchangeRedis(options =>
{
options.Configuration.ChannelPrefix = "TestChannel";
options.Configuration.EndPoints.Add("127.0.0.1", 6379);
options.Configuration.ClientName = "ClientNameSignalR";
options.Configuration.AllowAdmin = true;
});
When I try to get client list in Radis,
Now, how to sending and receiving messages from web app and API?
The code you share is used to set up a Redis backplane for scaling out your ASP.NET Core SignalR app.
how to sending and receiving messages from web app and API?
To achieve above requirement, you can do:
For your API project and Hub server, you can inject an instance of IHubContext in your API controller, then you can access to an instance of IHubContext in controller action and push message/notification to client(s).
Access a SignalR IHubContext to send notifications to clients from outside a hub
For your web app, you can built and implement SignalR JavaScript client functionality to receive notifications.
SignalR JavaScript client

Using RabbitMQ at ASP.NET MVC

Clients use iOS app + RabbitMQ to send messages on the server.
Sellers use ASP.NET MVC web site.
How can I use RabbitMQ for ASP.NET MVC to get messages from server?
If I subscribe to RabbitMQ channel as consumer inside controller, this doesn't work because controller returns View and EventHanlder doesn't fire.
You can create subscribing and recieving message from rabbitmq in global.asax or startup or program (if this selfhost) or another place which can be initialized on start. ASP.NET mvc in this case doesn't matter.

how to handle event callbacks in jabber.net within ASP.NET MVC

I would like to create a web project using ASP.NET MVC 4 which aims to make use of XMPP for some of its messaging, I have good knowledge of Jabber.net however, what I am a little confused about is the threading model I need to implement to use this type of library with an MVC application.
For example, when a user clicks a button on my page, on the server side, I want to:
connect to the XMPP server
then authenticate
then send an IQ message
then receive a response back
After all this is done, I then want to send the HTTP response message back to the client.
All of this is done using standard event handlers within Jabber.net but this model doesn't traditionally fit with web based threading, unless I am just tired and missing something...
Should I use a WaitHandle to stop the controller thread until the other threads are done with the Jabber.net code, then respond?
Do the async controllers fit here?

Categories