0

我使用 urlrewriter.net 来实现友好的 url。当我进行重写时,我有时会使用子文件夹。

我发现自己在使用图像和链接时遇到了问题,而且 ~ 符号对我不起作用。读了一点后,我发现我不是唯一一个有这个问题的人,他们建议使用完整路径“www.website.com/images/x.jpg”等。现在,我无法开发和 QA,因为所有的链接去我真正的在线网站。

我能做些什么?

4

2 回答 2

1

如果 URL 前缀是您唯一关心的问题,您是否考虑过在 web.config 中为 URL 前缀添加一个键,然后以这种方式动态生成图像的路径?

通过这样做,您可以在完成后轻松地将所有代码迁移到生产环境,然后只需更新 web.config 以将所有内容指向正确的服务器。

于 2008-12-30T20:45:11.097 回答
0

~ only works with ASP.NET Web Controls, not standard HTML controls.

A similar problem is when you have content pages (located in subfolders) referencing a masterpage in the application root. You need to use Image and Hyperlink controls in the MasterPage since the files are referenced from the location of the content page.

<asp:Image ID="Image1" runat="server" ImageUrl="~/images/Test.png" AlternateText="" />

<asp:HyperLink ID="HyperLink1" runat="server"NavigateUrl="~/Test.aspx">HyperLink</asp:HyperLink>

于 2008-12-30T20:55:57.907 回答