如果不使用标准输出目录,则无法运行MVC4项目 [英] Cannot run MVC4 project if not using standard output directory

查看:53
本文介绍了如果不使用标准输出目录,则无法运行MVC4项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目结构如下:

  • src
    -类库1
    -类库2
    -网络项目
  • bin
    -调试
    -释放
  • src
    -- class library 1
    -- class library 2
    -- web project
  • bin
    -- debug
    -- release

MVC4 Web项目的默认输出目录是.\Bin\(即在Web项目的目录中),但是我将其更改为..\bin\debug\..\bin\release\之类的内容以适合我上面的项目结构.它可以很好地编译,并且二进制文件可以移至正确的位置.

The default output directory for an MVC4 web project is .\Bin\ (i.e. within the web project's directory), but I change it to something like ..\bin\debug\ or ..\bin\release\ to fit my above project structure. It compiles fine and the binaries go to the correct places.

但是当我运行项目时,它会抱怨Could not load type Myproject.MvcApplication,而如果我不进行上述更改,那么它将起作用.

But when I run the project it complains that Could not load type Myproject.MvcApplication, whereas if I don't make the above changes then it works.

我如何控制二进制文件的位置?我希望输出目录与源目录完全分开-部署更简单,更安全,因为我没有混合使用源代码和二进制文件放在一个地方.

How do I control the location for the binaries? I want the output directory to be completely separate from the source directories - it's easier to deploy and more secure because I don't have a mixture of source and binaries in one place.

推荐答案

简短答案,不能.它与Visual Studio甚至.NET均无关,这是IIS的限制.

Short answer, you can't. It has nothing to do with Visual Studio or even .NET, it's an IIS restriction.

原因是IIS希望bin目录位于网站文件夹位置的正下方.这是您无法绕过的安全机制.目的是防止受感染的网站直接从网站根目录的边界逃脱".

The reason is that IIS expects the bin directory to be directly under the web site folder location. This is a security mechanism that you cannot bypass. It's purpose is to prevent a compromised web site from "escaping" from the bounds of the root directly of the site.

您为什么还要这么做?

这篇关于如果不使用标准输出目录,则无法运行MVC4项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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