[英]Using Themes with URL rewriting in ASP.net
I am using the UrlRewriter.NET library to perform URL rewriting. 我正在使用UrlRewriter.NET库执行URL重写。 I noticed that themes do not work properly as the browser tries to retrieve the CSS file incorrectly.
我注意到主题无法正常工作,因为浏览器试图错误地检索CSS文件。
The link tag generated by ASP.NET automatically is as follows: ASP.NET自动生成的链接标记如下:
<link href="App_Themes/vertebrata/style.css" type="text/css" rel="stylesheet" />
URL typed into browser: localhost:1708/BloggingEngine/aa Displays fine 在浏览器中输入URL:localhost:1708 / BloggingEngine / aa正常显示
URL typed into browser: localhost:1708/BloggingEngine/aa/ Browser does not load the CSS file 在浏览器中输入的URL:localhost:1708 / BloggingEngine / aa /浏览器未加载CSS文件
I can probably fix the problem by prefixing a "/" before the URL in the href attribute, but this is dynamically generated by ASP.net depending on selected theme and I have no control over it. 我可以通过在href属性中的URL前面添加一个“ /”前缀来解决此问题,但这是由ASP.net根据所选主题动态生成的,我无法控制它。
How do I get ASP.net to load themes properly? 如何获得ASP.net以正确加载主题?
I was having problems displaying my logo and after many nights looking for a solution. 我在显示我的徽标时遇到了问题,并且经过许多晚上的寻找解决方案。 I found a partial solution here: http://www.c-sharpcorner.com/uploadfile/afenster/using-an-Asp-Net-master-page-with-theme-and-css/
我在这里找到了部分解决方案: http : //www.c-sharpcorner.com/uploadfile/afenster/using-an-Asp-Net-master-page-with-theme-and-css/
First of all, I resolved my css theme by adding Pager.Resolve... " type="text/css" /> 首先,我通过添加Pager.Resolve ...“ type =” text / css“ />解决了CSS主题
Secondly, I resolved my ImageUrl by adding Page.ResolveUrl.... 其次,我通过添加Page.ResolveUrl ...来解决ImageUrl。
<asp:HyperLink ID="HeaderLink"
ImageUrl='<%# Page.ResolveUrl( "~/Images/BalloonShopLogo.png" )%>'
NavigateUrl="~/"
ToolTip="BalloonShop Logo"
runat="server" />
Finally, I modified my .master.cs file by adding the following 最后,我通过添加以下内容修改了.master.cs文件
protected void Page_Load(object sender, EventArgs e)
{
// a new declarative syntax <%# %> is the basis for using data binding
Page.Header.DataBind();
HeaderLink.DataBind();
}
and was able to display the logo. 并能够显示徽标。 If there is a better approach, I would definitely like to read it.
如果有更好的方法,我一定会阅读。
Not a direct answer to the question but a pointer to URL rewriting - 不是直接回答问题,而是指向URL重写的指针-
Now I haven't investigated the issue at all, and there may be a simple fix - as you have suggested. 现在,我根本没有研究此问题,并且可能有一个简单的解决方法-如您所建议。 However, you , may find the following article interesting.
但是,您可能会发现以下文章很有趣。
http://msdn.microsoft.com/en-us/library/ms972974.aspx http://msdn.microsoft.com/en-us/library/ms972974.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.