【问题标题】:Using Themes with URL rewriting in ASP.net在 ASP.net 中使用带有 URL 重写的主题
【发布时间】:2014-08-24 12:03:58
【问题描述】:

我正在使用 UrlRewriter.NET 库来执行 URL 重写。我注意到主题无法正常工作,因为浏览器试图错误地检索 CSS 文件。

ASP.NET自动生成的链接标签如下:

<link href="App_Themes/vertebrata/style.css" type="text/css" rel="stylesheet" />

在浏览器中输入的 URL:localhost:1708/BloggingEngine/aa 显示不错

在浏览器中输入的 URL:localhost:1708/BloggingEngine/aa/ 浏览器不加载 CSS 文件

我可以通过在 href 属性中的 URL 前添加一个“/”前缀来解决这个问题,但这是由 ASP.net 根据所选主题动态生成的,我无法控制它。

如何让 ASP.net 正确加载主题?

【问题讨论】:

    标签: c# asp.net url-rewriting


    【解决方案1】:

    不是对问题的直接回答,而是指向 URL 重写的指针 -

    现在我根本没有调查这个问题,并且可能有一个简单的修复 - 正如你所建议的那样。但是,您可能会发现以下文章很有趣。

    http://msdn.microsoft.com/en-us/library/ms972974.aspx

    【讨论】:

      【解决方案2】:

      我在显示我的徽标时遇到了问题,并且在寻找解决方案的许多夜晚之后。我在这里找到了部分解决方案: http://www.c-sharpcorner.com/uploadfile/afenster/using-an-Asp-Net-master-page-with-theme-and-css/

      首先,我通过添加 Pager.Resolve 解决了我的 css 主题... " type="text/css" />

      其次,我通过添加 Page.ResolveUrl...解决了我的 ImageUrl....

      <asp:HyperLink ID="HeaderLink" 
                                         ImageUrl='<%# Page.ResolveUrl( "~/Images/BalloonShopLogo.png" )%>'
                                         NavigateUrl="~/"
                                         ToolTip="BalloonShop Logo"
                                         runat="server" />
      

      最后,我通过添加以下内容修改了我的 .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();
      
      }
      

      并且能够显示徽标。如果有更好的方法,我一定会读一读。

      【讨论】:

        猜你喜欢
        • 2011-08-26
        • 2013-03-04
        • 2014-09-04
        • 1970-01-01
        • 2016-01-20
        • 2023-04-06
        • 1970-01-01
        • 2020-04-10
        • 2013-01-15
        相关资源
        最近更新 更多