I'm trying to implement a very simple login system for a webapi backend. The site will only have one login, which is an admin, which will allow create/update/delete actions.
For this reason, I'm trying to implement a simple login with usernames and passwords coded directly into the pages in C#.
Here's how I want it to work:
On the Login.aspx page, the user enters the username and password to a form, which gets sent to the server via a webmethod:
[WebMethod]
public static something Login(string username, string password)
{
if (username == "bob" && password == "password")
{
*Send some response indicating authentication success*
}
}
This response needs to be something I can obtain from the client-side. Ideally, I'd like to be able to grab it using javascript. Is this possible using WebMethod? And I'm not sure what the method signature should be like.. I assume it would be "public static something methodName" but I'm not sure what that something would be.
Basically, If the user login is a success, I'll pass back a string such as "A(@I#ASGJAWIAW", the client will cache it in the browser, and from there, when they need to make any CREATE, UPDATE, or DELETE requests, they will also send in that value to the webapi methods. The webapi methods will determine whether the have the correct value before running the action.
Does anyone have any experience doing something like this?