简体   繁体   中英

Organizing ASP.NET Web Application Project

How do I update references to user controls after putting ascx and aspx files into different folders?

I'm not used to working with ASP.NET Web Forms projects, but I inherited this one. 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 :

<%@ Register TagPrefix="tf" TagName="Cost" Src="..\..\controls\Widget.ascx" %>

My understanding is:

  • When a user navigates to AST_Page.aspx , the current path is myProject\\Pages\\Activity\\ .
  • Starting a path with ..\\..\\ should put me at myProject\\ .
  • Therefore, ..\\..\\controls\\Widget.ascx actually points to myProject\\controls\\Widget.asxc .
  • My Project has access to my 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\\ .

There was a second issue on the page. I had "~/../../" in a src attribute; likely due to an aggressive find and replace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM