0

我正在 Visual Studio 2010 中创建一个默认的 ASP.NET MVC 2 Web 应用程序。然后我将此应用程序部署到 IIS 服务器上的目录。我能够在 Visual Studio 中正常运行默认应用程序。但是,这是我尝试在服务器上运行应用程序时出现的错误。

Server Error in '/apps/myapp' Application.
--------------------------------------------------------------------------------

Runtime Error 
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration> 

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration> 

添加后

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration> 

我有一个新错误:

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

Source Error: 


Line 28:         <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 29:         <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 30:         <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 31:       </assemblies>
Line 32:     </compilation> 

Source File: D:\Data\Intranet\Apps\icaps\web.config    Line: 30 

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


=== Pre-bind state information ===
LOG: User = NT AUTHORITY\NETWORK SERVICE
LOG: DisplayName = System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///D:/Data/Intranet/Apps/icaps/
LOG: Initial PrivatePath = D:\Data\Intranet\Apps\icaps\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\Data\Intranet\Apps\icaps\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/apps_icaps/d8535ca2/6aefb703/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/apps_icaps/d8535ca2/6aefb703/System.Web.Mvc/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///D:/Data/Intranet/Apps/icaps/bin/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///D:/Data/Intranet/Apps/icaps/bin/System.Web.Mvc/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/apps_icaps/d8535ca2/6aefb703/System.Web.Mvc.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/apps_icaps/d8535ca2/6aefb703/System.Web.Mvc/System.Web.Mvc.EXE.
LOG: Attempting download of new URL file:///D:/Data/Intranet/Apps/icaps/bin/System.Web.Mvc.EXE.
LOG: Attempting download of new URL file:///D:/Data/Intranet/Apps/icaps/bin/System.Web.Mvc/System.Web.Mvc.EXE.

谢谢!

4

2 回答 2

2

根据错误 System.Web.Mvc is missing。检查 Web 服务器上站点的 bin 文件夹并确保该程序集存在。

Predeep链接到相关文章,以确保在发布时将必要的程序集部署到您的 bin。

haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx

编辑:同样在 Visual Studio 中,确保相关程序集上的 CopyLocal 属性设置为 True。

于 2013-09-19T17:48:04.987 回答
-1

这意味着您有一个错误,您需要修改您的 Web.config,就像 IIS 告诉您的那样,您才能真正看到正在引发的异常。

绝对清楚,您希望将customErrorsweb.config 中的元素更改为:

<configuration>
  <system.web>
    <customErrors mode="Off"/>
  </system.web>
</configuration> 
于 2013-09-19T17:14:13.777 回答