Open another webpage, logging in through code Asp.Net MVC - c#

I want to be able to login to an external domain webpage through code, and give the resultant page to user.
Tried using HttpWebRequest,
The user agent that makes the request must support JavaScript. The HttpWebRequest doesn’t support JavaScript.
Also found some suggestions about using WebBrowser Control, but that is for Forms apps.
Need some solution for ASP.NET MVC.

Related

Web browser in C# windows application form without using web browser class

I am trying to do C# web browser(navigate, favorites, display, GUI, history, sending the HTTP request, receiving http the response, bulk download) without using web browser class but I can't find anything related to that could anyone please help me with this concept code. I created the design in the C# windows application form.
Downloading files can be done with the WebClient class, but if you want an actual browser and the webbrowser object isn't good enough then I recommend using something like CefSharp.

How to use one angularjs app in a different web application?

I have made an angularjs app and I want to use it in another web application (eg. C# .Net,JAVA). I have another web app (which does not use angularjs) and when I click a button it should be redirected to my angularjs app to use the functionalities. How can I achieve this? Thanks!
IMO, for C# Web App, you can use RedirectPermanent("<AngularJsApplicationFeaturePageUrl>"); spend time in AngularJs application and when it completes, AngularJs Web Application is responsible for redirecting us to appropriate page in C# Web App.
For Example,
You might have experienced it in e-commerce apps. For buying\ checking-out items, you will be redirected to Bank's fund transfer page. When you are done, Bank website will redirect you to original e-commerce app.
You are seeing in Identity Module Providers like Azure Active Directory, Google Single Sign On,.. redirects you to its login page to challenge your identity and posts you back to original website.
You can find a ton of examples for above use cases.

ASP.Net MVC Get more information from external logins

I have an asp.net MVC web application and i try to add some fields from the external login providers, so that i would make it easier for my users to register for the first time.
How can i receive more information like birth-date, languages, etc?
(For now, everything works fine. My question is only about how to receive more information.)
You can perform external login using Google OAuth2 Sign-on.
https://learn.microsoft.com/en-us/aspnet/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

OAuth User-Agent Flow with C# Desktop App

I'm currently attempting to use the OAuth 2.0 User-Agent Flow with a clientside C# application, and I'm running into some confusion relating to the redirect URI.
Because I'm working with a clientside application, I cannot supply a standard redirect URL to a web server. However, according to the people I'm trying to authenticate with (Salesforce, in this instance), the User-Agent Flow is the correct one to use for a clientside application.
My question is, what can I do to catch the access token in this situation? Apparently I can create a "local resource accessible to the client," but I'm unfamiliar with the mechanics behind this, and I can't find any resources on the topic (partly because I don't know what to look for).
Any pointers as to where I should start looking would be greatly appreciated.
Edit: Some more digging has revealed the following stackoverflow question:
How do I develop against OAuth locally?
I'm doing some more investigating with what they suggested, but any other suggestions would be great as well.
Edit: Some more searching revealed this article:
http://sarangasl.blogspot.com/2010/09/create-simple-web-service-in-visual.html
Still feels like I'm poking around in the dark without an understanding of the larger picture, but I believe I need to set up a local web service using localhost and point my redirect URI there. I'll then use my web service to unwrap the response from the OAuth server and have my application respond appropriately. More updates to come.
Ooookay. So from what I've been able to gather, I need to set up a local web service to supply as the callback for OAuth. I need to listen on said web service myself and catch the callback to pass it to my app. However, the default ASP.NET web service provided by VS2010 does not support URL parameters, just API calls, so I apparently need to use the WCF Rest starter kit instead.
I am completely foreign to all of this, so any tips would be a godsend at this point. In general, I'm thinking I set up a local WCF Rest service, supply that local URI to OAuth as the callback, and then catch the callback URL using the Rest service. Then I parse the URL and extract the access token. At this point, does my app request the access token, or can my web service "give" the token to my app? I.e., where should the locus of control be?
Figured out a clever way to work around this. Instead of setting up a service to listen for OAuth's redirect URL, I embedded a WebBrowser control inside my Windows form.
I pointed this embedded WebBrowser to the authentication URL and let the user log in and authenticate with Salesforce and grant permissions to my app. Then, I let Salesforce redirect my embedded browser to a dummy redirect URL that I supply. This redirect never actually goes anywhere, it just shows up as a 404.
However, by monitoring WebBrowser.Url, I can pick up the entire URL that my embedded WebBrowser control is directed to, including the access token that is appended by Salesforce. Basically, after the user authenticates and grants permissions, the embedded browser is redirected to "http://www.dummyurl.com." Salesforce appends the access token, so WebBrowser.Url ends up looking something like this:
http://www.dummyurl.com#access_token=ABCDEF&instance_url=ABCDEF
From here, I can just parse the URL and go on my way. No third-party web server or local web service required. :)
The call the Authorization type you need Authonomous Client http://wiki.developerforce.com/page/Digging_Deeper_into_OAuth_2.0_on_Force.com#Obtaining_a_Token_in_an_Autonomous_Client_.28Username-Password_Flow.29. Read about the URL you have to send there.
grant_type=password&client_id=<your_client_id>&client_secret=<your_client_secret>&username=<your_username>&password=<your_password>
You can use DotNetOpenAuth library. There's an example using WPF, where it uses a winforms control called ClientAuthorizationView provided by DotNetOpenAuth library.
It is a control that hosts a browser allowing the user to authorize the client without leaving the application.
Hope this help.
Regards

C# - Logging into this website?

How can I make my C# app log in to a website that requires username/password authentication? The page uses Apache Struts, if it matters.
You need to send data to the web server to simulate a form submission.
There are a few questions that already address this:
Fake a form submission with C# WebClient
How to submit http form using C#
Hopefully now you have a more clear idea of what you are looking for.

Categories