locked
Excel - Hyperlink - Session Problem RRS feed

  • Question

  • User1735430007 posted

    Hello,


    I am facing a rather wierd situation here. My requirment was to provide the ability to be able to export the search results shown in a gridview to excel, which I have successfully done. One of the columns in the grid is a hyperlink column that has the id for that entity. Clicking on that hyperlink will take you to a page with that id's respective information. All of this gets exported to excel. But, here is the issue. When I click on the hyperlink in the grid, everything works fine and it takes me where it should. But this doesnot happen when I click the same link from excel. It opens up a new tab (in IE), and for some reason doesnot already recognize that I am logged in(since I assumed that the same browser share the same session information) and requests me to login again.

    I check for a session variable to determine if a user is logged in or not, and this variable is null when the reqeuest comes in from excel, always.

    How can I overcome this issue? If I manually copy the hyperlink location over from excel and paste it in the address bar in the browser, everything works fine, but doesnot work if I click on the link from excel.

    Please advice...


    Thanks

    Sunday, August 8, 2010 5:58 PM

Answers

  • User-660870441 posted

    Hi,

    As you have mentioned in your post, you use Session to determine whether a user is logged in or not, and the Session lost when user open a hyperlink from Excel.

    As far as I know, Session will lost depend on several reasons (e.g. different browsers, server incidents and others). And sometimes different tabs use different Sessions.

    So in order to achieve your original goal (keep being logined), I think you can use cookie to let users auto log in automatically (because cookie will be shared by all tabs in your browser). It general looks like that you logined a web site at first time, and then when you open this web site next time it will keep you being logined automatically.

    Here is a sample for you to clarify this concept.

    # ASP.NET cookie auto log in
    http://www.timmaxey.net/archive/2009/03/06/asp.net-cookie-auto-log-in.aspx

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 10, 2010 5:56 AM

All replies

  • User-1802908944 posted

    if you open your excel hyperlink in same browser tab, then it will work.

    if you open your hyperline in browser FF. then it will work.

    Which browser are you using?

    please check




    Monday, August 9, 2010 2:24 AM
  • User1735430007 posted

    IE 8

    Monday, August 9, 2010 10:12 AM
  • User-481631678 posted

    Go through this url, it will tell how to configure your IE8 for tabbed browsing and session sharing:-


    http://blogs.msdn.com/b/askie/archive/2009/05/08/session-management-within-internet-explorer-8-0.aspx


    Monday, August 9, 2010 10:16 AM
  • User1735430007 posted

    Thank you, but I dont think this post answers my question.


    Monday, August 9, 2010 10:41 AM
  • User1735430007 posted

    Thank you, but I dont think this post answers my question.


    Monday, August 9, 2010 10:42 AM
  • User1735430007 posted

    Any takers ? Please, this is a high priority issue.


    Monday, August 9, 2010 11:06 AM
  • User1986455008 posted

    Actually this works exactly as it should. Remember , you can click that link in the excel file 3 days later. You should not rely on session for this functionality. Instead pass data in query string and maybe have a public page which displays the information you want based on what you passed in query string.

    You could however do one thing, pass the user guid in query string and then use that to log the user in silently . Personally I would not do this though since the link can be clicked by anyone even someone else. Do you see the problem here ? Your excel file is a security risk so keep that in mind when doing whatever you want to achieve.

    Monday, August 9, 2010 12:30 PM
  • User-660870441 posted

    Hi,

    As you have mentioned in your post, you use Session to determine whether a user is logged in or not, and the Session lost when user open a hyperlink from Excel.

    As far as I know, Session will lost depend on several reasons (e.g. different browsers, server incidents and others). And sometimes different tabs use different Sessions.

    So in order to achieve your original goal (keep being logined), I think you can use cookie to let users auto log in automatically (because cookie will be shared by all tabs in your browser). It general looks like that you logined a web site at first time, and then when you open this web site next time it will keep you being logined automatically.

    Here is a sample for you to clarify this concept.

    # ASP.NET cookie auto log in
    http://www.timmaxey.net/archive/2009/03/06/asp.net-cookie-auto-log-in.aspx

    Hope this helps.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 10, 2010 5:56 AM
  • User-1172710425 posted

    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(2, MyLogin.UserName, DateTime.Now.Date, DateTime.Now.AddHours(5), true, "fjg", FormsAuthentication.FormsCookiePath);
                string encTicket = FormsAuthentication.Encrypt(ticket);
                Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
                FormsAuthentication.RedirectFromLoginPage(MyLogin.UserName, true);

    you should make a persistent cookie when the user is authenticated. This will keep u looged in the same browsr until u log out.

    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(2, MyLogin.UserName, DateTime.Now.Date, DateTime.Now.AddHours(5), true, "test",FormsAuthentication.FormsCookiePath);

    string encTicket = FormsAuthentication.Encrypt(ticket);

     Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

     FormsAuthentication.RedirectFromLoginPage(MyLogin.UserName, true);


    hope it works 4 u

    Thursday, December 23, 2010 3:14 AM
  • User800992467 posted

    I think there is a misunderstanding here. The issue is clearly an Office bug, discussed on StackOverflow and has been reported to MS by a John G. Norman, who documented his discussion with MS QA in a GenerationNT forum thread.

    If that leaves you unconvinced, consider the following test case:

    1. Inside your default browser, login to a page restricted by a login screen
    2. See that Skype/Outlook does things properly:
      1. Insert a http link to a restricted page in a Skype conversation. Skype automagically makes it clickable.
        Insert a http link to a restricted page in an Outlook email. Outlook automagically makes it clickable.
      2. Click the blue link
      3. Provided you logged in beforehand as instructed in step 1, the page appears without any need to login
    3. See that Excel does something wrong. Same steps:
      1. Insert a http link to a restricted page in an Excel cell via the Hyperlink tool
      2. Click the blue link
      3. Even though you logged in beforehand as instructed in step 1, you are redirected to a login screen

    Quote of some analysis done John G. Norman, revealing what's wrong with Excel's behavior:

    Outlook in Office 12 makes a request to a link embedded in e-mail, gets the redirect target, and then passes the redirect target to the default browser. This is AWFUL, because it means that the default browser will not have the session cookie.

    It's a shame his analysis didn't end up in the hands of MS engineering, I hope you can fix that. Thanks for your attention

    Wednesday, July 11, 2012 2:19 PM