1
我只想问是否有使用masterpage的URL路由的解决方法。我把链接放在我的主页面(即第一个链接是href =“Bookstore/CSS”,另一个链接是href =“tools/toolx”)如果我点击第一个链接,它会将我重定向到正确的url, :2039/Bookstore /但是如果我点击下一个链接,它会将我重定向到localhost:2039/tools/Bookstore/CSS,但链接应该是localhost:2039/Bookstore/CSS。ASP.NET 4.0 webforms在主页面内路由
下面是代码
Global.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>