URL重写问题-由于相对路径而丢失CSS和图像 [英] URL rewriting problem- loses css and images due to relative path

查看:85
本文介绍了URL重写问题-由于相对路径而丢失CSS和图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们.

URL重写中有一个小问题.我正在使用RewritePath方法.

认为.我在应用程序中具有以下结构.

root/
category.aspx
product.aspx

现在,对于类别页面,我没有任何问题,因为我像这样调用页面
www.mydomain.com/nokia.aspx并将其重写为category.aspx页面

对于产品页面,我像这样调用页面
www.mydomain.com/nokia/n6300.aspx并重写到product.aspx页面.
但是当打开此页面时,由于相对的根路径,我失去了该页面中使用的css样式和图像,在这种情况下,路径将由nokia定义.

我在Google上搜索了很多,但没有找到解决此问题的任何特定解决方案.

任何人都可以给我解决方案或建议,以帮助我完成我的工作.

谢谢
Imrankhan

Hi friends.

I have a small issue in URL rewriting. I am using RewritePath method.

Suppose. I have following structure in application.

root/
category.aspx
product.aspx

Now, for category page, I have not any problem because I am calling page like as
www.mydomain.com/nokia.aspx and its rewrite to category.aspx page

for product page, I am calling page like as
www.mydomain.com/nokia/n6300.aspx and rewrite to product.aspx page.
but when this page is opened, I loses css style and images that are used in the page because of relative root path and in this case path will be defined by nokia.

I have googled a lot but not find any particular solution to resolve this issue.

can any one give me solution or suggestion that will help me to complete my work.

Thanks
Imrankhan

推荐答案

在您的代码后面添加样式表,并使用 ResolveUrl

关于ResolveUrl方法 [
Add stylesheets in your code behind and use ResolveUrl

About ResolveUrl method[^]


这篇关于URL重写问题-由于相对路径而丢失CSS和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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