---
title: "Call dynamic webservice with session"  
description: "Call dynamic webservice with session"  
author: "Jayden Bell"  
published: 2014-08-22  
updated: 2014-08-22  
canonical: https://www.mindstick.com/forum/2086/call-dynamic-webservice-with-session  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# Call dynamic webservice with session

I have [webservice](https://www.mindstick.com/forum/166/webservice-method), provide to user. User [must](https://www.mindstick.com/articles/12978/top-reasons-why-every-magento-ecommerce-store-must-opt-for-mobile-app) login to use it. My [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is when [user login](https://www.mindstick.com/forum/549/what-is-the-benfit-of-given-the-microsoft-account-when-we-create-a-user-login-in-windows-8) through WSLogin on webservice, I want to save [session](https://www.mindstick.com/articles/12042/session-in-c-sharp) to [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) for a next time.

```
[WebMethod(EnableSession = true)]public string WSLogin(string username, string password){    // do something    string sID = Guid.NewGuid().ToString();    Session.Add("SID", sID); // save session    return sID; // return to user to check next time}[WebMethod(EnableSession = true)]public string CallSomethingService(string sID){    string curSID = Session["SID"].ToString() // error, Object reference not set to an instance of an object.    // do some thing}
```

I call webservice dynamically. Thank for all help

## Replies

### Reply by Sumit Kesarwani

Hi Jayden, \

Instead of this:

Session.Add("SID", sID);

use this:

HttpContext.Current.Session["SID"] = sSid;


---

Original Source: https://www.mindstick.com/forum/2086/call-dynamic-webservice-with-session

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
