how refresh/reload web page from another browser - c#

I want open this web app on different browsers then do some actions in one of them (ex run some post request) next I want that in all other browsers page will be reloaded
I'm not completely sure, but, perhaps, "signalR javascript client" will help me?

open this web app on different browsers then do some actions in one of them (ex run some post request) next I want that in all other browsers page will be reloaded
perhaps, "signalR javascript client" will help me?
Yes, you can achieve it by integrating ASP.NET Core SignalR functionality into your project to push specific notification to connected SignalR JavaScript clients, then the JavaScript client can update DOM content or refresh current page once received that specific notification message.
Besides, if it requires sending notification message from controller action(s) in your development scenario, you can inject an instance of IHubContext in your controller, then use that instance to send message(s) to client(s) as if you were in the hub itself.
For detailed information about "Send messages from outside a hub", please check this doc:
https://learn.microsoft.com/en-us/aspnet/core/signalr/hubcontext?view=aspnetcore-5.0#inject-an-instance-of-ihubcontext-in-a-controller

You can do that using the tech you mention. There are many options. Do you know anything about asp.net core/ Signalr? I ask because you have different SDKs available meaning you can do the same thing in C#, javascript, javaa, etc, using the same platform, a static web app for example.
You really do have a lot of choice. Also, have a look at FluidFramework, it's microsoft open source and pretty cool.
https://fluidframework.com/

Related

Reading POST request in Blazor

Here is the problem I have.
We have a server-side Blazor web application in which we want to register new users. The users come to us from another web site. When the users subscribe to our application through this web site a POST request is sent, and the user is redirected to a page of our Blazor application. The problem is we have no clue how to then get the form data contained in the POST. We can see it using the tools in the browser, but we can't use it in my code.
We have tried creating a controller with an HTTP endpoint, but the method we have set up does not get called. My colleague and I are at a loss with what to do or what resource would be helpful and comprehensive in showing us how to set this up. Instead we keep finding little bits of information that don't lead us to a successful implementation.
Any help would be amazing.

Get notification in view when a web API called from an external system in c# MVC

I'm developing a website in C# MVC including WEB API. When an API URL in my project is called from an external system, I want to show a message (not a push message, only show a text in a div) in one of my view that the API function is executing.Is this possible?
First Of All its possible yes,
you need To use SignalR To notify the Views:
YouTube totrual Here
Github : Here
Then You use the Signal R to push a Notification when a cross origin request happen
using action filters
the signalR subscribers can be view pages using Jquery.
SignalR on Client
full exmaple :here
Yes it is posssible. One (pretty easy) way is to use the awesome SignalR or SignalR core framework. Check this for differences. Real-time web functionality enables server-side code to push content to clients instantly.
Basically you will create a Hub on the server that clients connect to. In your WebApi method, you can then call the client method. Then in the client you will use javascript to respond to the server call and then you will set the div content from this method.
See the docs.
Hope it helps!
I think Signal R is best choise too. But maybe you want to another alternative. You can look at Node Js.
Node js.org
General Tutorial
General Tutorial 2
For .NET Tutorial

People picker control implementation in asp.net mvc application

I want to include the Sharepoint people picker control type in my application, My app is developed in asp.net MVC. is there a way so that i can include the GAL feature in my asp.net application. This should work even if the outlook is not installed in user pc.
Taken from this page dated March 1 2013
"SP controls can only be used on SP hosted pages. Currently the only control designed from the ground up to be consumed on all page types (provider-hosted, auto-hosted or sp hosted) is the chrome control."
and another post from an MSFT
"I've consulted with several colleagues and the consensus seems to be that SharePoint's client side people picker, which is JavaScript, cannot be used in a provider-hosted app. The reason is that there's no way to get a client context on a remote web page. You mention the TokenHelper.cs which is managed code, not JavaScript. I have a question pending with the product team to see if there's anyway to get the context with managed code and pass it to JavaScript. I didn't want you to have to wait any longer for an answer."
I would suggest writing a plugin. (Although I have never had the requirement to implement it YET)
How :
you write a controller that loads users from AD, and then send a JSON object of these to your client via AJAX and then use jquery auto complete to filter names as the user types.
Or
Simulate the "check User " button by making AJAX calls to that controller and check if name exist on click of that button. then write appropriate error messages if false.
I would still be on the lookout for other solutions though

Listening for http requests in a windows forms application

I've got to write a .net windows forms application that will open a webpage and then be able to react to the user clicking on certain links on the webpage. The specification I've been given has the links on the webpage just being http links.
Is there a way for my .net application to have a minimal web server on it which will allow it to handle http requests on a given port?
Use an HttpListener.
http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
If all you need is to show a webpage, and you don't have any restrictions on the browser used, then the WebBrowser control will do the trick.
Drag it on to your form
Set the Url property to the page you need to display
Attach to the Navigating event
You can now respond to clicks, cancel them, do whatever you like. If it's just responding to client-side clicks you need, you don't need a web server. If you DO need a webserver, WinForms shouldn't have anything to do with it.
webBrowser1.Navigating += new WebBrowserNavigatingEventHandler(webBrowser1_Navigating);
private void webBrowser1_Navigating(object sender,
WebBrowserNavigatingEventArgs e)
{
//Do your thing... maybe set e.Cancel if you don't to navigate
}
Please look at the WebBrowser control and specifically the "ObjectForScripting" property. If you set it to the parent form you can actually handle javascript events from the page loaded in the webbrowser in your c# code!!!
I hope that helps!
There are different ways to do this depending on what functionality you need. If all you need to do is respond to click events, and you don't need "full" http protocol support, you can just open a socket and parse what comes in from the browser.
Alternatively, you can use HttpListener, which takes care of the http protocol parsing for you and is relatively easy to use. For what I think you need, this is probably the preferred approach. Simple, non-compiling example here: https://gist.github.com/1770645.
The "holy grail" is hosting the ASP.NET runtime in your windows forms application. I've done this and it is pretty involved. The runtime has to be hosted in a separate AppDomain, so you end up jumping through a lot of hoops to get everything running and hooked up. It also involves writing an implementation of HttpWorkerRequest that is more full featured that the framework provided SimpleWorkerRequest. Incidentally, this also works for windows services, which gives you a great way to provide service management and monitoring through a browser without having a dependency on IIS.
I have interpreted the question differently to other users, so maybe I am way off but, I read it as he is trying to render web pages from the web and react to a user clicking on a link within the web page.
The only way I can think of doing this is by using some form of renderer ie webkit and hooking into that to intercept the clicks a user makes.
You can use Nancy
Site of project: https://www.codeproject.com/Articles/694907/Embed-a-web-server-in-a-windows-service

ASP.NET how to update a page upon a click event of another page

I know the question sounds too vague so let me explain exactly what I want to implement.
I have a WebApplication that many users log into to submit a request, Request in my project is a form that accepts some information from the user and when he click submit, it reflects on the administrator page. then the admin can grant or decline this request. and of course the result need to be sent to the user's 'Pending Requests' page.
this process is all about time so I need a clean and efficient way to show the admin the requests instantly and for the user to see the admin's response instantly. (kind of like facebook notification system).
I hope my problem is know clear. I understand that there are many ways to implement this and I have a very small knowledge about them. But I just want you guys to recommend an effecient way because I'm sure that the good ways to do this is limited.
Thanks in advance everybody :)
I will suggest you take a look at SignalR (https://github.com/SignalR/SignalR). It is a framework developed by a few MS developers for doing long polling/notifications from the server.
Link for webforms walkthrough - http://www.infinitelooping.com/blog/2011/10/17/using-signalr/.
You could also look into using a Timer control. It's a client side control that will cause a postback for ASP.NET AJAX applications. Here's a simple tutorial
http://ajax.net-tutorials.com/controls/timer-control/
What you're talking about is a 'push' notification, where the server would pass a notification to the client (a browser) without the client requesting anything.
This isnt something which HTTP is naturally capable of, however have a read about Comet - this will let you know the current state of what is possible.
You may opt for creating a 'heartbeat' on the client side - a polling mechanism which requests from the server every x seconds, and updates the page when new content is found.
I need a clean and efficient way to show the admin the requests instantly and for the user to see the admin's response instantly.
Instantly is a very strong term and isn't usually very scalable.
For some ideas on how you might implement this I'd recommend you take a look at Wikipedia's Comet Programming page
When a user submit requests I assume that his request is first stored in the database. So on the admin & user part you use ajax which periodically update data from database (for un-approved data), do some google search on ajax auto-update or Javascript's timeout or similar function. The same process will be involved in user part.

Categories

Resources