Solved

250 pts:  Persistence of cookies and authentication tickets when CHtmlView launches new IE browser windows

Posted on 2004-04-04
4
436 Views
Last Modified: 2012-08-13
My clients must be authenticated with a .NET authentication ticket or cookie that persists over all browser windows.  It works correctly if I start the web application in Internet Explorer.  The authentication ticket will persist over any new window that is launched by a script on the page.

But if the user logs on from a page running in a CHtmlView, and then when the page launches a new IE browser window, the user is not authenticated in the new window and must log on in that new window.

Why is this so?  What must i do?

250 points at:
http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20942665.html#10751703
0
Comment
Question by:Shake29
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 10753213
Hi,

  I may be way offbase here, but...

  CHtmlView is not executing an IE browser window.  It is simulating an IE browser through its MFC classes.  Therefore, the implication would be that all behavior is not the same.  

  I'm presuming the app is spawning a new window that knows nothing of cookies and whatever authentication you are requiring through the .NET.  So, while I know the MFC people told you to come here, I believe they are mistaken and you need write some code within the app to check for cookies before spawning the 'browser' window.

Vinny
0
 

Author Comment

by:Shake29
ID: 10754750
I will be closing this question, for I have solved the problem.

I have overrided the OnNewWindow2 event of CHtmlView.
In the event, i create a new document window, and the authentication ticket persists.
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 10754979
User resolved; points (20) refunded and question closed. Solution from http://www.experts-exchange.com/Q_20943403.html is posted below.

Netminder
Site Admin

======

Solution:
I overrided the OnNewWindow2 event and created a new document frame having the same parent application....

void CBrowserView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel)
{
    // Get a pointer to the application object
    CWinApp* pApp = AfxGetApp();    // Get the correct document template
   
     CDocTemplate* pDocTemplate;
    POSITION pos = pApp->GetFirstDocTemplatePosition();
    pDocTemplate = pApp->GetNextDocTemplate(pos);
    ASSERT(pDocTemplate);    // Create the new frame

    CFrameWnd* pNewFrame = pDocTemplate->CreateNewFrame(GetDocument(),
                                   (CFrameWnd*)AfxGetMainWnd());
    ASSERT(pNewFrame);    // Activate the frame and set its active view
     pDocTemplate->InitialUpdateFrame(pNewFrame, NULL);

    CBrowserView* pWBVw = (CBrowserView*)pNewFrame->GetActiveView();
    ASSERT(pWBVw);
    pWBVw->SetRegisterAsBrowser(TRUE);
     *ppDisp = pWBVw->GetApplication();
}
0
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 10757115
Glad to see I wasn't that offbase :D

Vinny
0

Featured Post

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to count occurrences of each item in an array.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question