0

I would like to create a Windows Forms client where users write Username and Password and gets authenticated with my website. Users that should authenticate on client should have already an account on my website.

How can i do that? Where should i start? Can't find any guide about that.

X.Otano
  • 2,079
  • 1
  • 22
  • 40
Oper
  • 339
  • 3
  • 16

1 Answers1

0

Within your WinForms project use the HttpClient / WebRequest method to setup a request to send a POST with the credentials (ideally over the HTTPS protocol). You should be able to analyse the response back to determine if authentication was successful. This might help for this approach https://lookonmyworks.co.uk/2011/08/22/making-a-post-request-in-c-with-basic-authentication/

Another method is to setup a RESTful API on your website which is easier IMHO to work with for specific tasks that you setup in your end point: How to get HttpClient to pass credentials along with the request?

Sulphy
  • 766
  • 2
  • 9
  • 29
  • So ideally, i should only send a request, get the html response and see from the HTML response if user is logged in? I don't understand well how the other method could be applicated to a windows form client, can you elaborate a bit more? Thank you – Oper Jul 25 '18 at 06:30
  • If your use case is simply to determine if the passed username and password is correct then by using the HttpClient allows you to interact with your existing site. There are different ways of doing authentication which you didn't mention in your original post. For the other method lookup Web API, it's already a project template in Visual Studio. You could move/copy the authentication logic from your existing site into this new project. This may help as an intro: https://learn.microsoft.com/en-us/aspnet/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api – Sulphy Jul 25 '18 at 06:52