Click here to Skip to main content
15,887,350 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Below is my Web Service code:

[WebMethod(EnableSession = true)]
public string GetStringValue(string sessionstring)
{
// return sessionstring+"1";

 HttpContext.Current.Session["regid"] = sessionstring;

 return HttpContext.Current.Session["regid"].ToString();
}

Below is my first application Code for on button click passing session value to web service

   protected void Button1_Click(object sender, EventArgs e)
{
    localhost.WebService objserv1 = new localhost.WebService();
    Session["RegId"] = "Mazar";
    Label.Text =objserv1.GetStringValue(Session["RegId"].ToString());

}


In second Application need to show on page load.

     protected void Page_Load(object sender, EventArgs e)
{

 //    localhost.WebService objserv1 = new localhost.WebService();
 //     lbl_Value.Text = objserv1.GetStringValue(HttpContext.Current.Session["regid"].ToString());

}


In Second application trying to showing first application session value but not getting any Idea.

<a href="https://i.stack.imgur.com/7gjzi.png">enter image description here
[^]

What I have tried:

Getting first application session value to second application
Posted
Updated 1-Feb-17 21:58pm
Comments
Suvendu Shekhar Giri 2-Feb-17 3:56am    
..and what do you want to do with that session value?
ZurdoDev 2-Feb-17 16:04pm    
A session value is just temporary storage so why do you want to share it? How do you know which session matches up with which session?
mazharkhan123 2-Feb-17 4:13am    
I have requirement like that only, please help to out this.
mazharkhan123 2-Feb-17 5:31am    
My requirement is user will go from one application to the other app, It is for authenticated users. I will explain clearly, If in first application user is valid then user will redirect to another application that is second application. The first application is made in .NET frame asp.net web forms and the second application made in PHP framework. So in asp.net web form I have to check user is valid or not from second application mysql database table. Please provide logic or code very urgent.

1 solution

What "Session" do you want to access via the web method? Applications can't share Session so it's unlikely you're going to get this to work. If a user is browsing both sites then he has two Sessions, but if he is browsing one site and that site makes a call to the other then it can't access that user's Session on that site, but instead creates a new Session on that site.
 
Share this answer
 
Comments
mazharkhan123 2-Feb-17 4:12am    
Leave the session, I want to pass value of first application using button click into second application using web service. @F-ES Sitecore
F-ES Sitecore 2-Feb-17 5:45am    
If you google something like "call web service c#" you'll find examples of how to do this. Add a web service reference is probably the easiest way.
mazharkhan123 2-Feb-17 4:25am    
Can you tell other way to acchieve leave the session value, pass a single value to one application to another using web service. @F-ES Sitecore
mazharkhan123 2-Feb-17 5:31am    
My requirement is user will go from one application to the other app, It is for authenticated users. I will explain clearly, If in first application user is valid then user will redirect to another application that is second application. The first application is made in .NET frame asp.net web forms and the second application made in PHP framework. So in asp.net web form I have to check user is valid or not from second application mysql database table. Please provide logic or code very urgent.
F-ES Sitecore 2-Feb-17 5:47am    
You're looking to implement a "single sign on" type system which is a massive subject and not a trivial exercise at all. Given you want single sign on across sites that use different server side technologies your task is even more complex. Google "single sign on" to learn what systems are out there or how you can build your own. If this is "urgent" then I dare say you have left this far too late.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900