Custom Search
Logiclabz
  • Home
  • Asp.Net
  • Consuming ASP.Net Web Service with Login Cookie Programmatically

Consuming ASP.Net Web Service with Login Cookie Programmatically

  

Some Web Service created using ASP.Net for security reason consists of login WebMethod. When login method is invoked with userid and password would create a login cookie. And the login cookie is required to access other WebMethods.

Hence while consuming WebService programmatically with login, requires storing cookies programmatically.

Cookie information can be stored programmically using System.Net.CookieContainer class.

	wbs.CookieContainer = new System.Net.CookieContainer();

Sample Webservice Call

	WebserviceNameSpace.WebserviceClass wbs = new WebserviceNameSpace.WebserviceClass();
	wbs.CookieContainer = new System.Net.CookieContainer();
	bool ret = wbs.Login("username", "password");
	wbs.OtherWebServiceMethod();

CookieContainer property in Webservice would maintain the STATE information of the webservice.



  


Leave a reply




Do you like this post?