Hi Bryan,
Thanks for your post!
After my researching, the reason of the Initialize method not executing is
that the architecture is different between Winform and Webform. In the
Webform application, switching form is implemented by call redirect method
in "Http.Context.Response". It means if we want to go to the new form, the
server side redirect to the new page directly. Below is the snippet for UIP
source code in "WebFormViewManager.cs file":
public void ActivateView( string previousView, Guid taskId, string
navGraph, string view )
{
RedirectToNextView(previousView, viewSettings);
}
the RedirectToNextView method:
private void RedirectToNextView(string previousView, ViewSettings
viewSettings)
{
try
{
if( previousView == null )
HttpContext.Current.Response.Redirect(
HttpContext.Current.Request.ApplicationPath + "/" + viewSettings.Type, true
);
else
HttpContext.Current.Response.Redirect(
HttpContext.Current.Request.ApplicationPath + "/" + viewSettings.Type ,
false );
}
catch(System.Threading.ThreadAbortException) {}
}
Actually the Initialize method is never called in the Webform application.
And below is the snippet for UIP source code in "WindowsFormViewManager.cs"
file:
public void ActivateView( string previousView, string view, Navigator
navigator, TaskArgumentsHolder args )
{
¡*
if (winFormView != null)
{
winFormView.Activate();
¡*
}
else if(controlView != null)
{
ActivateControl(controlView, previousView);
¡*
}
viewSettings = CreateNewView(view, navigator, taskId, args);
ClosePreviousFormIfNecessary(null, previousView, taskId, viewSettings);
¡*
}
We can find the CreateNewView call the ActivateForm method. And in the
ActivateForm method, the Initialize executes directly.
So the reason for designing is the Webform application use Http pipeline to
communicate with each other but the Winform application can create the new
form directly. We can find the description about the Initialize method in
the documentation as below:
"Called after the view manager instantiates the view, but before calling
Show()."
(*The documentation you can download from below link:
http://www.microsoft.com/downloads/d...C9D-88E1-4490-
8BD6-78092A0F084E&displaylang=en)
It means the method is used in the Winform application because there is no
the show method in the Webform application.
If your want to add the log for the Webform application. I suggest we add
the function into the "WebFormView_Load" method or your custom load method.
I hope the above information helps, if you have any questions or concerns,
please do not hesitate to let me know. I am standing by to help you.
Thanks.
Yuan Ren [MSFT]
Microsoft Online Support