覆盖〜控件中的行为
快速背景故事:我正在制作网站的“框架”版本,其母版页与正常母版页不同(适合 iframe 的母版页)。它通过 mysite.com/Framed/whatever
访问,而不是 mysite.com/whatever
。这在 IIS 中被重写为 mysite.com/whatever?framed=true
。效果很好。
我遇到的问题是,所有链接都是相对的,使用类似于 ~/Server.aspx
的 ~,它在正常站点中工作正常。我需要重写它,而不是生成 ../Server.aspx
(因为它“应该”),而是生成 ../Framed/Server.aspx
或 服务器.aspx
。
目前,这意味着只要您单击链接,页面就会返回到正常视图 (mystite.com/whatever2
),我希望它继续保留在 mysite.com/ 中框架/...
Quick backstory: I'm making a "framed" version of my site that has a different master page than normal (one suitable for iframing). It's accessed by mysite.com/Framed/whatever
, instead of mysite.com/whatever
. This is rewritten in IIS to mysite.com/whatever?framed=true
. That works fine.
The issue I'm having is that all the links are relative using a ~ like ~/Server.aspx
which works fine in the normal site. I need to override that so instead of producing ../Server.aspx
(as it "should") it produces ../Framed/Server.aspx
or Server.aspx
.
Currently this means that the page goes back to it's normal view (mystite.com/whatever2
) as soon as you click on a link, I want it to continue to stay in mysite.com/Framed/...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
难道你真的想要“../Server.aspx?framed=true”吗?这可能更容易实现
Don't you really want "../Server.aspx?framed=true" ? That might be easier to pull off
~ 解析为应用程序的根目录,因此您可以在主站点下为框架版本创建一个名为“Framed”的虚拟目录,因此“~/”解析为“/Framed/”。然后,您可以检查原始请求 URI 中是否存在“/Framed/”,而不是使用查询字符串开关来选择母版页。
~ resolves to the root of the application, so you could create a virtual directory beneath your main site for your framed version called "Framed", so "~/" resolves to "/Framed/". Then instead of using a query string switch to select your master page, you can check for the presence of "/Framed/" in the raw request URI.