[SalesForce] INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session

I am integrating salesforce in my asp.net application. I am using partner WSDL from my account lets say I am having a developer account XYZ@gmail.com and I have downloaded partner WSDl from that account and integrate it and now I am trying to login from some other credentials like ABC@gmail.com. Now I am getting an exception

"INVALID_SESSION_ID: Invalid Session ID found in SessionHeader:
Illegal Session. Session not found, missing session key:
00DG0000000l7dV!ASAAQHNyaM8cop7Oy2pgqjdCQxb4Vwim1BsEvNDYi7Qy45NhEIzg83Mvo2lAMFi37ycpcNKl.vntNgztNRQqFMxZB87cxJLx"

if I am doing so. I have found that the URL of developer ID is like na15.salesforce.com and the credentials that I am using having URL as na11.salesforce.com. So will it create any issue and I am able to login through the credentials but when I am making any request then I am getting an exception. Kindly check the below code for login part

 LoginResult lr = binding.login(username, password);                
 String authEndPoint = binding.Url;
 binding.Url = lr.serverUrl;
 binding.SessionHeaderValue = new PartnerWSDL.SessionHeader();
 binding.SessionHeaderValue.sessionId = lr.sessionId;
 header = new PartnerWSDL.SessionHeader();
 header.sessionId = lr.sessionId;
 printUserInfo(lr, lr.serverUrl);
 done = true;

Above part is working fine but when I running below code then it generates the exception

InsertUserService service = new InsertUserService();
service.SessionHeaderValue = new SForce.SessionHeader();
service.SessionHeaderValue.sessionId = binding.SessionHeaderValue.sessionId;
SForce.Account account = new SForce.Account();
account.Id = "001G000001DJv6n";
String strs = service.InsertLead(new SForce.Lead() { });

Here InsertUser is the class declared in APEX code. So can any one please suggest me is there any issue in my code or I following wrong path.

Best Answer

To handle this issue, add an exception handler and relogin to salesforce. That should fix it. There seems no solution or setting to address this.