<p>I have an application that runs as a child application in a virtual directory.</p>

<p>I want to pass a value from the parent application, but I believe that Session is keyed per application, and won't work.</p>

<p>To further complicate things, the parent application is WebForms, while the child is NVelocity MVC.</p>

<p>Does anyone know a trick that allows me to use some sort of Session type functionality between virtual applications?</p>

<p>EDIT: A webservice isn't really what I had in mind, all I need to do is pass the logged in users username to the child app. Besides, if calling a webservice back on the parent, I won't get the same session, so I won't know what user.</p>

[{'answer_id': 67917, 'author': 'ctcherry', 'author_id': 10322, 'author_profile': 'https://Stackoverflow.com/users/10322', 'pm_score': 1, 'selected': False, 'text': '<p>Sounds like web service is the way to go. You could do something like the following:</p>\n\n<ul>\n<li>Have the WebForms app create some data in its database with a key of some kind associated to it.</li>\n<li>Pass that key in the URL to the NVelocity MVC application.</li>\n<li>Allow the NVMVC application to call a web service (REST,XML-RPC,SOAP,whatever) on the WebForms app using the key that was passed.</li>\n</ul>\n\n<p>This will get around any kind of session keying or cookie-domain problem you may have and allow you to pass some nicely structured data.</p>\n'}, {'answer_id': 67935, 'author': 'foxxtrot', 'author_id': 10369, 'author_profile': 'https://Stackoverflow.com/users/10369', 'pm_score': 0, 'selected': False, 'text': '<p>You can do a server-side HTTP Request, it looks something like this in C#:</p>\n\n<pre><code>HttpWebRequest req = (HttpWebRequest)WebRequest.Create("/ASPSession.ASP?SessionVar=" + SessionVarName);\nreq.Headers.Add("Cookie: " + SessionCookieName + "=" + SessionCookieValue);\n\nHttpWebResponse resp = (HttpWebResponse)req.GetResponse();\nStream receiveStream = resp.GetResponseStream();\n\nSystem.Text.Encoding encode = System.Text.Encoding.GetEncoding("utf-8");\n\nStreamReader readStream = new StreamReader(receiveStream, encode);\n\nstring response = readStream.ReadToEnd();\n\nresp.Close();\nreadStream.Close();\nreturn response;\n</code></pre>\n\n<p>On the ASP side, I just verify that the request only comes from localhost, to prevent XSS-style attacks, and then the response is just the value of the Session variable.</p>\n\n<p>Finding the cookie is easy enough, Session cookies all have similar names, so just examine the cookies collection until you find the appropriate cookie.  Note, this does only work if the cookies are valid on the entire domain, and not just on the subfolder your are on.</p>\n'}, {'answer_id': 191830, 'author': 'GvS', 'author_id': 11492, 'author_profile': 'https://Stackoverflow.com/users/11492', 'pm_score': 0, 'selected': False, 'text': "<p>Store the data you need to share on a place where both applications can query it, with a key both applications know.</p>\n\n<p>A database is something you can use,if you don't want a Web service.</p>\n"}, {'answer_id': 986953, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Use a classic asp form on your page to pass using post, in child app pick up using request.form</p>\n'}, {'answer_id': 2211661, 'author': 'Mick Walker', 'author_id': 199510, 'author_profile': 'https://Stackoverflow.com/users/199510', 'pm_score': 0, 'selected': False, 'text': '<p>Why could it not simply be passed as an encrypted query string?</p>\n\n<p>The child app could decrypt it, validate it, and bob is your uncle.</p>\n'}]
['https://Stackoverflow.com/questions/67879', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1965/']