Toolkit ScriptManager 的 Asp.Net Server.Transfer 问题
我正在一个网站上工作,该网站的母版页中有一个工具包脚本管理器。我的问题在于导航到执行 server.transfer 的页面时。我实际上也在使用 url 重定向,但据我所知,这与问题没有任何关系。
如果我将代码更改为 Response.Redirect,页面重定向效果很好,但这不是我正在寻找的功能,我需要保留 SEO 友好的网址。
例如 - 假设在 Page1.aspx 的代码中有一个 Server.Transfer 到 Page2.aspx。我的诊断是,脚本管理器向您浏览的页面添加了脚本引用。所以,如果我直接导航到 Page2.aspx,添加的脚本是
但是,使用 Server.Transfer,它正在尝试查找
如何告诉 ScriptManager 使用脚本文件的最终目标?我一直在研究尝试在 TSM 中使用一些魔法设置,但到目前为止还没有成功。
I'm working on a site which has a toolkitscriptmanager in the master page. My problem lies when navigating to a page which performs a server.transfer. I'm actually also using url redirects, but from what I can tell, that doesn't have any bearing on the problem.
If I change code to Response.Redirect, the page redirects fine, but that's not the functionality I'm looking for, I need to keep the SEO friendly urls.
For example - say in the code of Page1.aspx there's a Server.Transfer to Page2.aspx. What I've diagnosed, is that the Script Manager adds a script reference to the page your'e browsing. So, If I were to navigate straight to Page2.aspx, The script added is
<script src="/Page2.aspx?_TSM_HiddenField_=ctl00_ctl00_ToolkitScriptManager1_HiddenField... etc
However, with the Server.Transfer, it's trying to find
<script src="/Page1.aspx?_TSM_HiddenField_=ctl00_ctl00_ToolkitScriptManager1_HiddenField... etc
How can I tell the ScriptManager to use the final destination for the script file? I've been researching trying to use some magic setting in the TSM but no luck so far.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过一些挖掘和测试,我能够让它发挥作用。我必须将头部中定义的脚本移至 TSM 中,并使用 CompositeScripts:
我发现 stringe 是如果我设置 JointScripts=true,TSM 会将所有 js 文件编译到其自己的内部脚本中 - 然后仍然放置引用其所在页面的脚本。通过设置CombineScripts=false,它仍然会编译js文件,单独执行它们,并且对于页面脚本引用也是如此。
After some digging and testing, I was able to get this to work. I had to move my scripts defined in the head into the TSM, and make use of the CompositeScripts:
What I find stringe is if I set CombineScripts=true, the TSM would compile all the js files into its own internal script - and then still place the script referencing the page it's on. By turning CombineScripts=false, it still compiles the js files, does them individually, and also does so for the page script reference.