覆盖〜控件中的行为

发布于 2024-08-18 10:51:27 字数 511 浏览 1 评论 0原文

快速背景故事:我正在制作网站的“框架”版本,其母版页与正常母版页不同(适合 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缪败 2024-08-25 10:51:27

难道你真的想要“../Server.aspx?framed=true”吗?这可能更容易实现

Don't you really want "../Server.aspx?framed=true" ? That might be easier to pull off

扛起拖把扫天下 2024-08-25 10:51:27

~ 解析为应用程序的根目录,因此您可以在主站点下为框架版本创建一个名为“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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文