问题描述
我有一个asp.net网站有了它我们有登录页面的管理区域,只有管理员和所有网站允许所有 - 我要问如何定义它的正确的安全配置,我得到这个错误
I have a asp.net web site with it we have admin area with login page for admin only and all site is allowed for all - i need to ask how to define the right security configuration for it as i get this error
Cannot use a leading .. to exit above the top directory.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Cannot use a leading .. to exit above the top directory.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Cannot use a leading .. to exit above the top directory.]
System.Web.Util.UrlPath.ReduceVirtualPath(String path) +8862087
System.Web.Util.UrlPath.Reduce(String path) +52
System.Web.Util.UrlPath.Combine(String appPath, String basepath, String relative) +214
System.Web.UI.Control.ResolveClientUrl(String relativeUrl) +180
System.Web.UI.WebControls.Image.AddAttributesToRender(HtmlTextWriter writer) +68
System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) +20
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +20
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +163
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
我的配置文件:
my configuration file :
<authentication mode="Forms">
<forms name=".ASPXFORMSAUTH" protection="All" loginUrl="Admin/LoginPage.aspx" path="/" enableCrossAppRedirects="true">
</forms>
</authentication>
<authorization>
<deny users="*" />
</authorization>
推荐答案
这意味着你的网页是指它是从你的页面中的一层文件夹的内容,但你的页面已经在网站的根夹,因此相对路径是无效的。您的异常信息来看,它看起来像一个图像的控制导致了问题。
What this means is that your web page is referring to content which is in the folder one level up from your page, but your page is already in the website's root folder, so the relative path is invalid. Judging by your exception message it looks like an image control is causing the problem.
您必须有类似:
<asp:Image ImageUrl="..\foo.jpg" />
不过,由于页面本身是在网站的根文件夹,也不能引用内容上一级,这是领先的 .. \
在做什么。
这篇关于不能使用领先../退出顶级目录上方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!