【发布时间】:2018-02-14 04:26:37
【问题描述】:
我已经搜索过,无法使用普遍接受的答案来解决我的问题。
在我的 Site.Master c# 页面后面的 c# 代码中,我有这段代码可以即时创建引导菜单项。
R1.Text =
"<li class='dropdown'>" +
"<a runat='server' href='#' class='dropdown-toggle' data-toggle='dropdown' role='button' aria-haspopup='true' aria-expanded='false'>My Account<span class='caret'></span></a>" +
"<ul class='dropdown-menu' >" +
"<li><a runat='server' href='../Account/Register'>Register</a></li>" +
"<li class='divider'></li>" +
"<li><a runat='server' href='../Account/Login'>Login</a></li>" +
"<li class='divider'></li>" +
"<li><a runat='server' href='../TermsConditions'>Terms and Conditions</a></li>" +
"<li class='divider'></li>" +
"<li><a runat='server' href='../PrivacyPolicy'>Privacy Policy</a></li>" +
"</ul>" +
"</li>";
相应的 aspx 页面在创建引导导航的过程中也有这个......
<ul class="nav navbar-nav navbar-right">
<li>
<asp:Label ID="R1" runat="server" />
</li>
</ul>
所以href='../TermsConditions' 和../PrivacyPolicy 工作正常,但href='../Account/Register' 和href='../Account/Login' 都给出了
不能使用前导 .. 退出顶级目录。 错误。
我尝试使用友好的网址~,这会生成一个404 error of page not found /~/Account/Register
我以为是路由权限,所以我的 RouteConfig =
public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
//var settings = new FriendlyUrlSettings();
//settings.AutoRedirectMode = RedirectMode.Permanent;
//routes.EnableFriendlyUrls(settings);
routes.EnableFriendlyUrls();
}
}
我有我的 /Account web.Config =
<location>
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Manage.aspx">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
那么我错过了什么?
这里是堆栈跟踪。谁能告诉我这个错误发生在哪里?
[HttpException (0x80004005): 'href' 属性的 URL 格式错误: 无法使用前导 .. 退出顶级目录..] System.Web.UI.HtmlControls.HtmlControl.PreProcessRelativeReferenceAttribute(HtmlTextWriter writer, String attribName) +188 System.Web.UI.HtmlControls.HtmlAnchor.RenderAttributes(HtmlTextWriter writer)+93 System.Web.UI.HtmlControls.HtmlControl.RenderBeginTag(HtmlTextWriter writer)+41 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +20 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter 编写器,ControlAdapter 适配器)+66 System.Web.UI.Control.RenderControl(HtmlTextWriter 编写器,ControlAdapter 适配器)+100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer)+25 C:\Users\Michael Wood\Documents\Visual Studio 2017\Projects\Thinair\Thinair\Site.Master:0 中的 ASP.site_master.__Renderform1(HtmlTextWriter __w, Control parameterContainer) System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter 作家,ICollection 孩子)+268 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +9856836 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)+32 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter 输出)+53 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter 编写器,ControlAdapter 适配器)+66 System.Web.UI.Control.RenderControl(HtmlTextWriter 编写器,ControlAdapter 适配器)+100 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter 作家,ICollection 孩子)+128 System.Web.UI.Control.RenderChildren(HtmlTextWriter 作家)+13 System.Web.UI.Control.Render(HtmlTextWriter 编写器)+12 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter 编写器,ControlAdapter 适配器)+66 System.Web.UI.Control.RenderControl(HtmlTextWriter 编写器,ControlAdapter 适配器)+100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer)+25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter 作家,ICollection 孩子)+128 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)+13 System.Web.UI.Page.Render(HtmlTextWriter 编写器)+29 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter 编写器,ControlAdapter 适配器)+66 System.Web.UI.Control.RenderControl(HtmlTextWriter 编写器,ControlAdapter 适配器)+100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer)+25 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1303
【问题讨论】:
标签: c# navigation directory