我只是想问一下使用母版页的 url 路由是否有解决方法。我将链接放在我的母版页中(即第一个链接是 href="Bookstore/CSS",另一个链接是 href="tools/toolx"),如果我单击第一个链接,它会将我重定向到正确的 url,即 localhost :2039/Bookstore/但如果我点击下一个链接,它会将我重定向到 localhost:2039/tools/Bookstore/CSS,但链接应该是 localhost:2039/Bookstore/CSS。
这是代码
全球.asax
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RouteTable.Routes.MapPageRoute("StoreRoute",
"BookStore/{Name}",
"~/Webpages/BookStore/ViewBookDemo.aspx");
RouteTable.Routes.MapPageRoute("mytool",
"tools/{Name}",
"~/tools/tools.aspx");
}
母版源代码
<div class="page">
<div >
<div class="title">
<h1>
URL Routing in MAsterpage
</h1>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
<Items>
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
</Items>
</asp:Menu>
</div>
</div>
<div class="clear"> </div>
<div style=" width:90%">
<div style="float:left; width:25%;border: 1px solid #009933;">
<br />
<a href="Bookstore/CSS">Click Here to go to bookstore</a>.
<div class="clear"> </div>
<p>
<a href="tools/toolx">Click Here to go to tools</a>.
</p> </div>
<div style="float:right;width:73%">
<div class="main">
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</div>
</div>
</div>
</div>
<div class="clear"> </div>
<div class="footer">
</div>