简体   繁体   English

URL重写

[英]URL Rewriting

i am using URL rewriting in my asp.net application using regx 我正在使用regx在我的asp.net应用程序中使用URL重写

virtual URL is 虚拟网址为

/ProductDatabaseCMS/(?<category>\w*)/Product/(?<product>\w*)\.aspx

original URL is 原始网址为

/ProductDatabaseCMS/Product.aspx?PROD_ID=${product}

application path is ~/ProductDatabaseCMS 应用程序路径为~/ProductDatabaseCMS

my application has master page that uses style sheet and the path is 我的应用程序具有使用样式表的母版页,路径为

~/App_Themes/Styles/Style_Sheet.css

i am requesting the URL 我正在请求网址

/ProductDatabaseCMS/(?<category>\w*)/Product/(?<product>\w*)\.aspx

from one of the webpage of application using Hyperlink control but in that case stylesheet is not working for this page Because it is taking path 从使用Hyperlink控件的应用程序网页之一中获取,但在这种情况下,样式表不适用于此页面,因为它采用了路径

~/ProductDatabaseCMS/(?<category>\w*)/Product/App_Themes/Styles/Style_Sheet.css

what i have to do in this case. 在这种情况下我该怎么办。

If you use a relative URI to reference the external stylesheet, you have to consider this: Relative URIs are always resolved from a base URI which is the URI of the current resource if not declared otherwise. 如果使用相对URI来引用外部样式表,则必须考虑以下事项:相对URI总是从基本URI解析的,如果没有另外声明,则它是当前资源的URI。

So if you request /foo/bar and there is a relative URI reference css/baz.css in the HTML document, it would be resolved to /foo/css/baz.css as /foo/bar is the base URI. 因此,如果您请求/foo/bar并且在HTML文档中有一个相对的URI引用css/baz.css ,它将被解析为/foo/css/baz.css因为/foo/bar是基本URI。

To solve this problem you have two options: 要解决此问题,您有两种选择:

  1. use absolute URIs or at least absolute paths to reference the resources (eg /App_Themes/Styles/Style_Sheet.css ), or 使用绝对URI或至少绝对路径来引用资源(例如/App_Themes/Styles/Style_Sheet.css ),或者
  2. set a suitable base URI using the BASE HTML element (eg <base href="/"> ) so that every relative URI is resolved from that new base URI. 使用BASE HTML元素(例如<base href="/"> )设置合适的基本URI,以便从该新的基本URI解析每个相对URI。

Use a "root-relative path" for the CSS href. 为CSS href使用“相对根路径” You start the href with "/", that's all. 您以“ /”开始href,仅此而已。

Try: /App_Themes/Styles/Style_Sheet.css 尝试: /App_Themes/Styles/Style_Sheet.css

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM