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.
Related
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/
I've been searching for hours and couldn't find any solution to this problem.
I'm developing a UWP App and I have a WebView that goes to a website (where the user authenticates) and I should be able to get the access_token after he logs in.
Is there a way to get the response header from the page?
Or do I have to do everything manually (create the HttpClient, send the POST with the login info, and get the header response that way?)
First and foremost, the latest guidance is that authentication should not be done inside a web view, the modern approach is to open external browser window, where the user authenticates and is then redirected back to the app using a custom URI scheme. See a detailed post on this here on SO.
Now, the unfortunate answer is that WebView does not offer a built-in way to access the HTTP response and its headers. This has been requested (see for example this blog post by Martin Suchan), but was not implemented so far. If you have control over the web page, then you could store the authentication info in cookies, which are accessible. Not even injecting custom JavaScript can help here, because getting the HTTP headers is possible if you initiate an AJAX request in JS, but you can't get headers for a page that is already loaded.
As mentioned in comments above, the better solution would be to code the login manually using HttpClient or see if the service support a proper OAuth2/OpenID Connect flow in which case you could use a library like IdentityModel.OidcClient2 which can handle most of the heavy lifting for you.
You can also use the built-in WebAuthenticationBroker, see docs here.
I have an app written in asp.net mvc on domain-A.com and there is an other external service on domain-B.com that will eventually redirect user to my app. But since i have some performance issues i want my app to be ready before redirection to my site and cache some data. So domain-B call one endpoint from domain-A.com and domain-A.com sets a session cookie or any other cookie for itself(not for domain-B.com this is important) and when redirection happens domain-A.com reads cookie for itself and does its staff. Is this possible and if it is what is the method for it.
You can't set cookies via AJAX on other domains.
What you can do is to render some page from "domain-a" in hidden IFrame and let it set cookies/cache whatever you want.
Note: this will likely simply double time needed for your site to render. Solving actual performance problems will likely provide better user experience.
Your question isn't very clear.
If you are trying to cache some static data for your application in the browser, then I suggest you look into using local storage:
Here are just a few pointers for the start:
http://www.w3schools.com/html/html5_webstorage.asp
https://www.smashingmagazine.com/2010/10/local-storage-and-how-to-use-it/
On the other hand, you can easily set cookies using javascript code, so I don't understand what you are struggling with.
There are a couple of words that you have used in your post, which makes me wonder... first one is 'Session cookie'. Now 'Session' is a different story. Are you referring to browser session? Application session? Are you trying to share the same session between different domains?
The second questionable phrase is "one endpoint from domain A". What exactly is this endpoint? Are you referring to a WCF endpoint? A web page?
I think you need to provide more details on your post to get proper answer :)
I have made a new project using the ASP.NET Web Application template in Visual Studio 2015. Then I selected MVC and Individual User Accounts to specify the template further. The solution I got is complete in that it offers me all the web pages you need for account management such as registering and logging in.
However, now I want to hook in a Xamarin.Forms mobile client to this account management scheme. I am making a native UI to register users, instead of redirecting them to a webpage or webview. I want to send user registration data, such as username and password, from this UI to the server so it will create an account. This means that I don't want to use the webpages offered by my MVC app, but rather send the registration data to the server and have it create an account, notfifying me of succes or failure.
I am anticipating that I would need to either use HTTP POSTs to login and registration endpoints in the AccountController or implement a public API. However, doing a post will return a webpage, and my client is not interested in a webpage.
I think one of the above should be possible to implement quite easily, but I am having a hard time searching for answers or methods, since I don't know how to phrase my problem properly, and with the abundance of guides on MVC, all my results are muddied.
Is my idea of this being possible flawed or have I missed a fundamental concept of MVC? What are the steps I should take in order to make this possible?
One misconception is that doing a POST will return a webpage. You can return any type of content from an MVC controller. But your account registration endpoints should be Web API controllers that return JSON. That JSON can be as simple as containing a boolean that indicates if the action was successful or not.
You do not need to use MVC at all. You can completely do away with the account controllers and views that the template created for you. Just copy the code that you need from the MVC controllers into your Web API methods.
You're right, this is quite easy to do.
I think, You can use ASP.NET Web API for doing this task. On server, you host your API for registering the users as well as logging into some client application.
Now, You need to consume this API in a client application. The client application could be a Console application, Windows application or a Web application. There are lots of tutorials about making an Web API on official ASP.NET site.
I have a WPF application that redirects to a payment system and then starts pooling a database to see if the transaction reference was posted back via a different channel.
I had a chat with one of my programmer friends and he said that there was no need for pooling and I could have simply tracked Url to which payment system redirects after successful payment and react accordingly.
Code to open window and redirect agent to payments system is as follows:
var process = Process.Start(new ProcessStartInfo(url));
Is there a way to get the Url of the Browser Window?
I would recommend to use a web browser control inside your application. There are very good ones and a built-in version (called WebBrowser). Process.Start is a problem since you never know which browser (and version) is loaded. You have support a lot of different ways to get the URL.
The benefit of using a web browser control in your application is that you have absolute control of the web browser, you can handle events like loading of pages, which enables you to perform checks on the URL. I use this myself to do OAuth authentication on a client and get the token back from the URL and parse the token out of it.