views:

1024

answers:

2

I want to pass some data between an existing excel application and an existing ASP.Net VB Webforms application.

I thought a hyperlink with some query string variables would be the most straightforward means of doing this. However, it seems that the hyperlink does not retain the session of the logged in user.

Testing this with the same URL on a webpage does work. So it seems Excel is starting a new session. Any ideas on how to make Excel hyperlinks behave the same way a browser hyperlink does?

A: 

Clicking a link in Excel typically opens a new browser, and thus, a new session. There's nothing you can really do within Excel or the hyperlink to mitigate this - it's the way browser sessions work.

If you can't just re-initialize the user's session state when they access this url (I assume they may be asked to log in, etc.) then maybe you could consider using cookies to retain the user's identity?

Kurt Schindler
Yes it requires a login. I've not dug into that side of the application yet, it just seems strange that I can start a new browser window or tab myself and not need to login (when already logged in), but if I do it from Excel it doesn't seem to have access to what I presume is a cookie stored on the machine. I don't want to have to dig into the filesystem to open up a cookie just to duplicate this cookie for use by excel. It doesn't seem to me like the way browser sessions work, but more about how Excel works
Mark Burns
A: 

I am having this same problem, and using Fiddler I can see that when following the link in Excel, cookies are not being sent to the server - causing session problems.

My work around is as follows; create a redirect page that does not require a valid session, that just redirects to the page that requires a valid session. As the redirect page is in the browser - the page that is redirected to gets the session cookies as expected.

Code (redirect.htm);

<html>
<body>
Please wait, loading your page... 
<script type="text/javascript">
<!--
function getQuerystring(key) {
key = key.replace(/[\[]/,"\\\[").replace(/    [\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var query = regex.exec(window.location.href);
return query[1];
}

window.location = "http://site-page/" + getQuerystring('page'); //-->
</script>
</body>
</html>

Accessing the page from access using http://site-page/redirect.htm?page=this-sub-page - works for me now.

Thies