admin管理员组

文章数量:1123379

How do you pass (POST-)data to a physical webpage from within a NET MAUI application?

I would like to navigate to a webpage. The website is of the same origin as the app, meaning users can log into the website using the same credentials they use in the app. For a seamless user experience I would like to automatically authenticate the user on this website, so they don't have to enter their credentials again. After all, I already have the credentials/token/key in the app.

Using HttpClient I can authenticate users through an API, but this client doesn't have graphical components to physically present a website. Therefore, I have to either open the browser or use MAUI WebView instead to display the website.

For example, I have to open the webpage in a browser:

await Browser.Default.OpenAsync(
    new Uri(";), 
    BrowserLaunchMode.SystemPreferred);

Or create a WebView to display the webpage there:

<WebView 
    Source="; />

But how would I go about automatically authenticating the user there? Is there a way to POST data to the browser or to the MAUI WebView? Or can I somehow use HttpClient to create a session and use this session in the browser/Webview? Is there any accepted workflow for this?

本文标签: cHow to pass data to a physical webpage from NET MAUI applicationStack Overflow