[英]Organizing ASP.NET Web Application Project
How do I update references to user controls after putting ascx
and aspx
files into different folders?将ascx
和aspx
文件放入不同文件夹后,如何更新对用户控件的引用?
I'm not used to working with ASP.NET Web Forms projects, but I inherited this one.我不习惯使用 ASP.NET Web 窗体项目,但我继承了这个项目。 When I first received this Project, every file was directly under the root;当我第一次收到这个项目时,每个文件都直接在根目录下; no folders whatsoever.没有任何文件夹。 I've started putting files into folders and updating the paths.我已经开始将文件放入文件夹并更新路径。
When I try to load a user control, however, I get this error:但是,当我尝试加载用户控件时,出现此错误:
Cannot use a leading .. to exit above the top directory.不能使用前导 .. 退出顶级目录。
My user control is located at:我的用户控件位于:
myProject\controls\Widget.asxc
My page is located at:我的页面位于:
myProject\Pages\Activity\AST_Page.aspx
Markup from AST_Page.aspx
:来自AST_Page.aspx
标记:
<%@ Register TagPrefix="tf" TagName="Cost" Src="..\..\controls\Widget.ascx" %>
My understanding is:我的理解是:
AST_Page.aspx
, the current path is myProject\\Pages\\Activity\\
.当用户导航到AST_Page.aspx
,当前路径是myProject\\Pages\\Activity\\
。..\\..\\
should put me at myProject\\
.以..\\..\\
myProject\\
的路径应该把我放在myProject\\
。..\\..\\controls\\Widget.ascx
actually points to myProject\\controls\\Widget.asxc
.因此, ..\\..\\controls\\Widget.ascx
实际上指向myProject\\controls\\Widget.asxc
。myProject\\
.我的项目可以访问我的myProject\\
。 If I change ..\\..\\controls\\Widget.ascx
to ..\\controls\\Widget.ascx
, I get a different error about not finding the file, which is expected as Widget.ascx
is not under myProject\\Pages\\controls\\
.如果我将..\\..\\controls\\Widget.ascx
为..\\controls\\Widget.ascx
,我会收到一个关于找不到文件的不同错误,这是预期的,因为Widget.ascx
不在myProject\\Pages\\controls\\
.
There was a second issue on the page.页面上还有第二个问题。 I had "~/../../" in a src attribute;我在 src 属性中有“~/../../”; likely due to an aggressive find and replace.可能是由于积极的查找和替换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.