在一个子目录ASP.Net用户控件,没有找到目录错误 [英] ASP.Net user controls in a child directory, directory not found error

查看:233
本文介绍了在一个子目录ASP.Net用户控件,没有找到目录错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近改组的web应用程序,而不是全部坐在应用程序根目录中的文件,这样,一切都被分成业务领域的子文件夹和下按类型分为文件夹。而不必这样:

I've recently reorganised a web app so that instead of all the files sitting in the application root, everything is split into business area sub-folders and beneath that divided into folders by type. So instead of having:

  • 〜/ MasterPage.master
  • 〜/ Page.aspx
  • 〜/ UserControl.ascx

结构是现在这个样子:

  • 〜/应用/通用/ MasterPages / MasterPage.master
  • 〜/应用/通用/页/ Page.aspx
  • 〜/应用/普通/用户控件/ UserControl.ascx

这所有的作品非常好我的机器上,一切都编译并运行在调试或发布模式,但是当我部署到测试服务器事情有点梨形。要部署创建一个MSI在Visual Studio中使用 _deploy _msi 项目,然后在测试服务器上运行MSI。

This all works quite well on my machine, everything compiles and runs in Debug or Release mode, however when I deploy to the testing server things go a bit pear shaped. To deploy I create an MSI using _deploy and _msi projects in visual studio, then run the MSI on the test server.

这是直接从引用的.aspx 用户控件似乎是确定的,但如果用户控件有孩子的用户控件,然后随之而来的错误:

User controls that are referenced directly from an .aspx seem to be OK, but if a User Control has a child user control then errors ensue:

目录   C:\的Inetpub \ wwwroot的\ Web应用程序\ APP \公用\ MasterPages   不存在。无法启动   监控文件的更改。

Directory 'C:\Inetpub\wwwroot\WebApp\App\Common\MasterPages' does not exist. Failed to start monitoring file changes.

目录   C:\的Inetpub \ wwwroot的\ Web应用程序\ APP \公用\用户控件   不存在。无法启动   监控文件的更改。

Directory 'C:\Inetpub\wwwroot\WebApp\App\Common\UserControls' does not exist. Failed to start monitoring file changes.

该目录不测试服务器上不存在,因为没有文件走在其中,所有的内容都在生成过程中编译成的DLL,所以微星不必复制到他们的任何文件。如果我用手新建一个目录,然后一切开始,即使他们是空的工作,所以一个明显的解决办法是包括 blank.html 或每个文件夹中的相似,所以他们获得由安装程序创建的;另一种是把用户控件与页面相同的目录 - 但这一切似乎掩盖了真正的问题:为什么在部署Web应用程序需要这些目录在首位存在

The directories do not exist on the testing server because there's no files to go in them, all their contents are compiled into DLLs during the build, so the MSI doesn't have any files to copy into them. If I create the directories by hand then everything starts working even though they're empty, so one obvious fix is to include a blank.html or similar in each folder so that they get created by the installer; another would be to put the user controls in the same directory with the pages - but that all seems like papering over the real issue: why does the deployed web app needs these directories to exist in the first place?

因此​​,有几个问题我想答案:

So there are a few questions I'd like answers to:

  • 这是一个根本性的错误为首的做法,我希望看到,因为在这个项目的目录结构的进一步类似问题的未来? (如果是的话,有什么更好的方式来组织应用程序吗?)
  • 有没有一种方法来配置构建这样ASP.net并不需要开始监视文件更改? (它是什么做的让编译网站可更新的选择吗?)
  • 是否有这一切是如何工作的地方一些好的文档解释了这个问题?

推荐答案

我有同样的确切的错误,尽管任何用户控件会导致它,不管它是用一个页面或其他用户控件。我相信这只是发生如果控制是在一个单一的请求中使用的5倍以上。

I have had the same exact error although any UserControl would cause it, regardless of whether it was used by a Page or another UserControl. I believe it only happened if that control was used more than 5 times in a single request.

一个解决方法是一个空的占位符文件添加到每个包含CustomControl目录,并设置占位符文件的属性为生成操作:内容复制到输出目录:复制始终。从时,该网站发布消失保持目录。

One workaround is to add an empty Placeholder file to every directory containing a CustomControl and set the Placeholder file's properties to Build Action: Content, Copy to Output Directory: Copy always. That keeps the directories from disappearing when the site is published.

这篇关于在一个子目录ASP.Net用户控件,没有找到目录错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆