Asp.net mvc 共享主机中的虚拟目录是否与wwwroot中的内容冲突?

Asp.net mvc 共享主机中的虚拟目录是否与wwwroot中的内容冲突?,asp.net-mvc,web-services,hosting,virtual-directory,Asp.net Mvc,Web Services,Hosting,Virtual Directory,我有一个asp.NETMVC应用程序、phpBB论坛和asp.NETWebService,我希望它们都在同一个wwwroot中 我的共享主机允许虚拟目录,所以我做了一个。它创建了目录和其中的一些web.config 然后我上传了我的asp.net web服务,并将虚拟目录中的web.config与web服务中的web.config重写 Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutra

我有一个asp.NETMVC应用程序、phpBB论坛和asp.NETWebService,我希望它们都在同一个wwwroot中

我的共享主机允许虚拟目录,所以我做了一个。它创建了目录和其中的一些web.config

然后我上传了我的asp.net web服务,并将虚拟目录中的web.config与web服务中的web.config重写

 Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
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.IO.FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

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.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].


Stack Trace:

[FileNotFoundException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +57
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
   System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
   System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +83
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
   System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +83
   System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath) +10
   System.Web.UI.WebServiceParser.GetCompiledType(String inputFile, HttpContext context) +43
   System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +180
   System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +307
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
所以我不知道它为什么想要MVC.dll,是不是因为我删除了虚拟目录中的默认web.config而疯了

好的,我有这个

    <location path="." inheritInChildApplications="false">
        <compilation debug="true">
            <assemblies>
                <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
            </assemblies>
        </compilation>
    </location>

但我明白了

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: <location> sections are allowed only within <configuration> sections.

Source Error:

Line 68:             during development.
Line 69:     -->
Line 70:        <location path="." inheritInChildApplications="false">
Line 71:            <compilation debug="true">
Line 72:                <assemblies>
配置错误
描述:处理服务此请求所需的配置文件时出错。请查看下面的特定错误详细信息,并适当修改配置文件。
分析器错误消息:只允许在节内使用节。
源错误:
第68行:开发期间。
第69行:-->
第70行:
第71行:
第72行:
我也试过这个

<configuration>
  <location path="."  inheritInChildApplications="false">
    <configSections>

因此,它想先配置分区,但我不确定要将其移动到哪里

 Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Only one <configSections> element allowed per config file and if present must be the first child of the root <configuration> element.

Source Error:

Line 10: <configuration>
Line 11:   <location path="."  inheritInChildApplications="false">
Line 12:    <configSections>
Line 13:        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
Line 14:            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=n
配置错误
描述:处理服务此请求所需的配置文件时出错。请查看下面的特定错误详细信息,并适当修改配置文件。
解析器错误消息:每个配置文件只允许一个元素,如果存在,则必须是根元素的第一个子元素。
源错误:
第10行:
第11行:
第12行:
第13行:

第14行:您是否将MVC DLL放在/bin文件夹中

有时它会在本地工作,因为MVC容器在GAC中,但它们可能不在服务器上的GAC中

预计到达时间:

听起来您的webservice虚拟机可能正在从主web继承设置。您的主web.config中可能有类似的内容:

    <compilation debug="true">
        <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        </assemblies>
    </compilation>


您的web.config文件正在查找MVC文件,请从web.config中删除此行

<add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

在我的wwwroot中,我的asp.net mvc应用程序所在的位置有一个bin文件夹,其中包含mvc.dll,它可以正常加载。问题是我的虚拟目录中有我的asp.net webservice,而不是asp.net mvc应用程序,因此它在bin文件夹中只有我的webservice.dll。然而,它要求使用mvc.dll却毫无意义。如果我把webservice单独放在wwwroot中(所以不是mvc的东西),它工作得很好。我只是尝试了一下,我必须在我的虚拟目录中找到我使用的每个bin,即使我的应用程序没有使用它。这没有任何意义。嗯,我认为它可能会工作,但我注意到这样做会杀死Vs2008中的调试器。如果我的web.config中有这一行,我就不能再调试了。我把它取出来,我就可以调试了。@chobo2-这可能是因为
不再被webservice子网站继承了。尝试将web.config文件放在该虚拟目录中,并添加确保其中包含该节(当然不包括MVC dll引用)Hi-webservice有自己的web.config,并且在其中包含该行。我认为它仍然可以在webserivce上进行调试。我说的是我的asp.NETMVC应用程序,它是web.config(也就是根web.config)。当我有了那行代码后,我丢失了Deubuger。是的,它必须在那里,否则我的asp.net mvc应用程序将无法工作。那么,请将mvc dll放在bin文件夹中。
<add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>