问题描述
||
我有一个可以安装插件的Web应用程序。为了创建这些插件,我创建了一个具有相同结构的新Web应用程序,并从主应用程序引用了程序集。
此后,我仅将aspx(标记)文件复制到主应用程序,因此我具有标记页和对程序集的引用,以便可以调试。
直到到目前为止,当Im进行修订时,这一切都一直很好,自从我上次研究以来,唯一改变的就是安装了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创建一个新会话
解决方法
好的,这可能与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,string Name,Sicon.API.Web.Enums.ScrollBars ScrollBars,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 +\' \",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(),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 );
}
catch ( Exception ex )
{
ErrorLogging.LogError( ex );
}
}
注意:我在从dialogArguments传递的窗口对象上调用window.open。
当然这太可怕了,有人能找到更好的解决方案吗?
有关此问题的信息在这里:
http://support.microsoft.com/kb/831678
更新:这也可能与IE10的安装有关,似乎我的某些互联网安全设置已重置,并且正在影响javascript。代码中的变通方法也很容易实现,以防将来再次出现这种情况。