Web service request authentication

后端 未结 3 780
一向
一向 2021-01-15 06:19

We\'re being really stuck here so I decided to ask your help.

Yesterday I\'ve been asked to help to consume a web service, got the URL to the WSDL, and the user cred

3条回答
  •  没有蜡笔的小新
    2021-01-15 07:18

    I've achieved similar, using a regular HttpCookie.

    To create the cookie:

    [OperationContract]     
    public void LoginToApi(string username, string password, string clientName)
    {
    // authenticate with DB, if successful ...
    // construct a cookie
        HttpCookie httpCookie = new HttpCookie("SessionID","whateverneeded");
        HttpContext.Current.Response.SetCookie(httpCookie);
    }
    

    This appears in your regular HttpRequests, too. So you just reverse the process, checking the hash/session ID/username/password whatever you put in the cookie on receipt before doing anything.

提交回复
热议问题