Using Themes with URL rewriting in ASP.net
I am using th开发者_JS百科e UrlRewriter.NET library to perform URL rewriting. I noticed that themes do not work properly as the browser tries to retrieve the CSS file incorrectly.
The link tag generated by ASP.NET automatically is as follows:
<link href="App_Themes/vertebrata/style.css" type="text/css" rel="stylesheet" />
URL typed into browser: localhost:1708/BloggingEngine/aa Displays fine
URL typed into browser: localhost:1708/BloggingEngine/aa/ Browser does not load the CSS file
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.
How do I get ASP.net to load themes properly?
Not a direct answer to the question but a pointer to URL rewriting -
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
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/
First of all, I resolved my css theme by adding Pager.Resolve... " type="text/css" />
Secondly, I resolved my ImageUrl by adding Page.ResolveUrl....
<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
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.
精彩评论