0

我有一个可以安装插件的 Web 应用程序。为了创建这些插件,我创建了一个具有相同结构的新 Web 应用程序,并从主应用程序中引用程序集。

在此之后,我只将 aspx(标记)文件复制到主应用程序,所以我有标记页面和对程序集的引用,以便我可以调试。

到目前为止,这一切都运行良好,直到我进行修改时,自上次工作以来唯一改变的是安装 VS2010 SP1。

现在代码中有一点 - 我无法确切地看到它在外部代码中发生的位置,但是会话 ID 正在更改并且我在会话中丢失了所有内容。

我有一段代码可以打开一个带有报告的新窗口:

        string link = String.Format( "window.open('{0}');", Page.ResolveUrl( "~/CustomPages/BudgetOnlineMedia.aspx" ) );

        Page.ClientScript.RegisterStartupScript( this.GetType(), "MedReport", link, true );

在此之后,在基本页面中遇到断点:

/// <summary>
/// OnPreload
/// </summary>
/// <param name="e">args</param>
[VersionChange( "7.3.88.272", "13/04/2011", "Fully qualified path to login page" )]
protected override void OnPreLoad( EventArgs e )
{
    try
    {
        base.OnPreLoad( e );

        if ( base.CurrentUser == null )
        {
            Response.Redirect( "~/Pages/Login.aspx", false );
        }
    }
    catch ( Exception ex )
    {
        ErrorLogging.LogError( ex );
    }
}

再次命中相同的断点,但这次 SessionID 已更改!

此时我可以读取调用堆栈,但我的代码中没有任何内容可以更改会话。

堆栈跟踪如下所示:

>   Web.WAP.Objects.DLL!Web.WAP.Objects.Controls.UserPresencePage.OnPreLoad(System.EventArgs e) Line 28 C#
    System.Web.dll!System.Web.UI.Page.ProcessRequestMain(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) + 0x22b bytes   
    System.Web.dll!System.Web.UI.Page.ProcessRequest(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint) + 0x84 bytes    
    System.Web.dll!System.Web.UI.Page.ProcessRequest() + 0x51 bytes 
    System.Web.dll!System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext context) + 0x16 bytes   
    System.Web.dll!System.Web.UI.Page.ProcessRequest(System.Web.HttpContext context) + 0x32 bytes   
    App_Web_-ti4sydr.dll!ASP.custompages_budgetexhibition_aspx.ProcessRequest(System.Web.HttpContext context) + 0x33 bytes  C#
    System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() + 0xb6 bytes 
    System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step, ref bool completedSynchronously) + 0x4c bytes 
    System.Web.dll!System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(System.Exception error) + 0x133 bytes  
    System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback cb, object extraData) + 0x7c bytes  
    System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest wr) + 0x17c bytes 
    System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest wr) + 0x63 bytes  
    System.Web.dll!System.Web.HttpRuntime.ProcessRequest(System.Web.HttpWorkerRequest wr) + 0x47 bytes  
    WebDev.WebHost20.dll!Microsoft.VisualStudio.WebHost.Request.Process() + 0x177 bytes 
    WebDev.WebHost20.dll!Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Microsoft.VisualStudio.WebHost.Connection conn) + 0x6c bytes    
    [Appdomain Transition]  
    WebDev.WebHost20.dll!Microsoft.VisualStudio.WebHost.Server.OnSocketAccept(object acceptedSocket) + 0xd3 bytes   
    mscorlib.dll!System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(object state) + 0x2f bytes   
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6f bytes    
    mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(System.Threading._ThreadPoolWaitCallback tpWaitCallBack) + 0x53 bytes 
    mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(object state) + 0x59 bytes    

什么是【应用领域过渡】?

你能看到任何会导致会话 ID 改变的东西吗!?

编辑:

好的,这可能与 VS SP1 无关,而是与 IE10 预览有关。

现在当我做一个window.ShowModalDialog 时,然后从那个对话框中打开一个window.open。Internet Explorer 创建一个新会话

4

1 回答 1

0

好的,这可能与 VS SP1 无关,而是与 IE10 预览有关。

现在当我做一个window.ShowModalDialog 时,然后从那个对话框中打开一个window.open。Internet Explorer 创建一个新会话

这似乎是 IE8 中的一个错误,但看起来它可能会回到 IE10 中。

这是我不得不使用的解决方法。

在我的基本页面中显示一个模式对话框(它传递窗口对象)

/// <summary>
/// Shows a Page as a Modal dialog
/// </summary>
/// <param name="URL">The URL</param>
/// <param name="Width">The Width</param>
/// <param name="Height">The Height</param>
/// <param name="Resizable">Resizable?</param>
/// <param name="IfScript">Java script to run if the window returns true</param>
/// <param name="ElseScript">Java script to run if the window returns false</param>
protected void ShowModalDialog( string URL, int Width, int Height, bool Resizable, string IfScript, string ElseScript )
{
    try
    {
        string sModalDialog = @"
                                try
                                {{
                                    var args = new Object();
                                    args.window = window;
                                    if (window.showModalDialog('{0}', args, 'dialogHeight={1}px;dialogWidth={2}px;resizable={3}'))
                                    {{
                                        {4}
                                    }}
                                    else
                                    {{
                                        {5}
                                    }}
                                }}
                                catch (e)
                                {{
                                    alert(e.value);
                                }}";

        string vbs = String.Format( sModalDialog, URL, Height, Width, Resizable ? "yes" : "no", IfScript, ElseScript );

        base.ClientScript.RegisterStartupScript( this.GetType(), "ModalDialog", vbs, true );
    }
    catch ( Exception )
    {
        throw;
    }
}

以及打开弹出窗口的基本 Page 方法(检查传递的窗口对象)

       /// <summary>
    /// Shows a Popup Window
    /// </summary>
    /// <param name="Link">The link to show in the window</param>
    /// <param name="Width">The Width of the window</param>
    /// <param name="Height">The Height of the window</param>
    /// <param name="Name">The name of the window</param>
    /// <param name="ScrollBars">The Scroll bars to show</param>
    /// <param name="Resizable">Whether the window is resizable</param>
    /// <param name="ShowToolBar">Whether to show the toolbar</param>
    /// <param name="ShowStatusBar">Whether to show the status bar</param>
    /// <param name="ShowAddressBar">Whether to show the address bar</param>
    protected void OpenWindow( string Link, int Width, int Height, string Name, Sicon.API.Web.Enums.ScrollBars ScrollBars, bool Resizable, bool ShowToolBar, bool ShowStatusBar, bool ShowAddressBar )
    {
        try
        {
            StringBuilder sb = new StringBuilder();
            sb.Append( "try" );
            sb.Append( "{" );
            sb.AppendFormat( "Link='{0}';", Link );
            sb.AppendFormat( "Name='{0}';", Name.Replace( " ", "" ) );
            sb.Append( "    leftPos = 0;" );
            sb.Append( "    topPos = 0;" );
            sb.Append( "    if (screen) " );
            sb.Append( "    {" );
            sb.AppendFormat( "        leftPos = (screen.width / 2) - ( {0} / 2 );", Width );
            sb.AppendFormat( "        topPos = (screen.height / 2) - ( {0} / 2 );", Height );
            sb.Append( "    }" );
            sb.Append( @"
                        var myWindow = window;
                        if ((typeof(dialogArguments) !== 'undefined' && dialogArguments != null))
                        {
                            if (typeof(dialogArguments.window) !== 'undefined' && dialogArguments.window != null)
                            {
                                myWindow = dialogArguments.window;
                            }   
                        }
                        " );
            sb.AppendFormat( "    myWindow.open(Link,Name,'width={0},height={1},left=' + leftPos + ',top=' + topPos +' ", Width, Height );

            //Check whether to show Scroll Bars
            switch ( ScrollBars )
            {
                case Sicon.API.Web.Enums.ScrollBars.One:
                    sb.Append( ",scrollbars=1 " );

                    break;

                case Sicon.API.Web.Enums.ScrollBars.Two:
                    sb.Append( ",scrollbars=2 " );

                    break;
            }

            //Check whether the window is resizable
            if ( Resizable )
            {
                sb.Append( ",resizable " );
            }

            //Check Whether to show the toolbar
            if ( ShowToolBar )
            {
                sb.Append( ",toolbar " );
            }

            //Show the status bar
            if ( ShowStatusBar )
            {
                sb.Append( ", status " );
            }

            //Show the address bar
            if ( ShowAddressBar )
            {
                sb.Append( ", location " );
            }

            sb.Append( "');" );
            sb.Append( "}" );
            sb.Append( "catch (e)" );
            sb.Append( "{" );
            sb.Append( "    alert(e.value);" );
            sb.Append( "}" );

            Page.ClientScript.RegisterStartupScript( this.GetType(), Name, sb.ToString(), true );

            sb = null;
        }
        catch ( Exception )
        {
            throw;
        }
    }

然后在打开第二个窗口的页面中(调用基本页面方法)

    protected void btnBudgetOnlineMedia_Click( object sender, EventArgs e )
    {
        try
        {
            base.OpenWindow( Page.ResolveUrl( "~/CustomPages/BudgetOnlineMedia.aspx" ),
                800,
                600,
                "Med Report", 
                API.Web.Enums.ScrollBars.Two,
                true,
                false,
                false,
                false );
        }
        catch ( Exception ex )
        {
            ErrorLogging.LogError( ex );
        }
    }

注意:我在从 dialogArguments 传递的窗口对象上调用 window.open。

这当然很可怕,有人有更好的解决方案吗?

此处有关此问题的信息:

http://support.microsoft.com/kb/831678

更新:它也可能与 IE10 的安装有关,看起来我的一些互联网安全设置被重置,这影响了 javascript。代码中的解决方法也可以很好地实现,以避免将来发生这种情况。

于 2011-04-13T12:51:14.553 回答