如何在asp.net 2.0创建友好的URL [英] How to create friendly url's in asp.net 2

查看:163
本文介绍了如何在asp.net 2.0创建友好的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用IHttpModule的和托管的URL转换就好了,
但是我所有的图像返回的路径错误(所有经历新的URL目录)。

I tried using the IHttpModule and managed to convert the urls just fine, but all of my images returned path error (all going through the new url directory).

什么解决办法吗?

推荐答案

您需要确保您使用〜/路径表示法上的图像,并确保它们与RUNAT =服务器的所有服务器控件。否则,图像的URL不会得到改写。

You need to make sure that you use the "~/" path notation on your images and make sure that they are all server controls with runat='server'. Otherwise the images urls won't get rewritten.

例如,如果你有一个会从重写页面:

For example if you have a page that gets rewritten from:

/Item/Bicycle.aspx

/Item/Bicycle.aspx

/Item.aspx?id=1234

/Item.aspx?id=1234

然后会发生什么事是,一个图像引用这样的:

Then what will happen is that an image reference like this:

<img src='images/something.gif' />

将打破。因此,你必须做这样的事情:

will break. So instead you have to do something like this:

<asp:image imageurl='~/images/something.gif' runat='server' id='img1'/>

另外,您可以使用绝对路径为你的形象。或者你可以尽可能地推入您的.css文件。

Alternatively you can use absolute paths for your images. Or you can push as much as possible into your .css files.

这篇关于如何在asp.net 2.0创建友好的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆