升级到ASP.NET 4.5后出现404错误


10

我最近将Web应用程序升级到了.NET 4.5。将代码推送到我们的测试环境后,我得到“ 404-找不到文件或目录”。错误。该代码可以在我的VS2013桌面上正常运行。Web服务器在W2K08 R2上运行IIS 7.5。我可以在网站上查看.asp或.htm页面,但是在尝试查看最简单的.aspx页面时出现此错误。我怀疑这是我的web.config的配置问题。


您能告诉我们您的web.config和与您的网站相关的applicationhost.config部分吗?
Anthony Fornito '16

试图发布web.config,但是太长了。您想具体看到什么,我将复制该部分。
jbonwell's

为了帮助找出问题所在,我们需要查看配置,主要是站点特定的部分。通常,整个web.config都是有帮助的。在您的问题的applicationhost.config中,<site>容器应该没问题。
安东尼·佛尼托

要长吗?您将不得不在此处发布它,使用notepad ++在每行的
开头

<site name =“ SHIPPING” id =“ 10067” serverAutoStart =“ true”> <application path =“ / CPORT” applicationPool =“ ASP.NET v4.0 Classic”> <virtualDirectory path =“ /” physicalPath =“ E: \ inetpub \ wwwroot \ WEB_APPS \ CPORT“ /> </ application> <bindings> <binding protocol =” http“ bindingInformation =” 136.171.92.24:80:stage.chx.com“ /> </ bindings> <logFile logExtFileFlags = “日期,时间,ClientIP,用户名,站点名,计算机名,ServerIP,方法,UriStem,UriQuery,HttpStatus,Win32Status,BytesSent” directory =“ E:\ Inetpub \ SHIPPING \ Logs” /> </ site>
jbonwell

Answers:


11

这是web.config。http://go.microsoft.com/fwlink/?LinkId=235367。

The following attributes can be set on the <httpRuntime> tag.
  <system.Web>
    <httpRuntime targetFramework="4.5.2" />
  </system.Web>
  -->
  <system.web>
    <httpRuntime requestValidationMode="4.0" enableHeaderChecking="false" encoderType="System.Web.Security.AntiXss.AntiXssEncoder,System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <httpCookies httpOnlyCookies="true"/>
    <compilation debug="true" strict="false" explicit="true">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Drawing.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
      </assemblies>
</compilation>
<trace enabled="false" pageOutput="false"/>
<pages theme="Apps" enableEventValidation="true" validateRequest="true" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
  <namespaces>
    <clear/>
    <add namespace="System"/>
    <add namespace="System.Collections"/>
    <add namespace="System.Collections.Generic"/>
    <add namespace="System.Collections.Specialized"/>
    <add namespace="System.Configuration"/>
    <add namespace="System.Text"/>
    <add namespace="System.Text.RegularExpressions"/>
    <add namespace="System.Linq"/>
    <add namespace="System.Web"/>
    <add namespace="System.Web.Caching"/>
    <add namespace="System.Web.SessionState"/>
    <add namespace="System.Web.Security"/>
    <add namespace="System.Web.Profile"/>
    <add namespace="System.Web.UI"/>
    <add namespace="System.Web.UI.WebControls"/>
    <add namespace="System.Web.UI.WebControls.WebParts"/>
    <add namespace="System.Web.UI.HtmlControls"/>
  </namespaces>
  <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add tagPrefix="Ipls" assembly="cvx.Ipls.Web" namespace="cvx.Ipls.Web.UI.Controls"/>
    <add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI"/>
    <add tagPrefix="ccc" namespace="CSC.Web.Common.Controls" assembly="CSC.Web.Common.Controls35"/>
  </controls>
</pages>
<sessionState mode="InProc" timeout="60"/>
<httpHandlers>
  <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false"/>
  <add path="*_AppService.axd" verb="*" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  <add path="ScriptResource.axd" verb="GET,HEAD"  type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" /> 
</httpHandlers>
<httpModules>
  <add name="ErrorModule" type="CSC.Web.Common.Errors.ErrorModule"/>
  <add name="securityModule" type="CSC.Web.Common.Security.securityModule"/>
  <add name="RadCompression" type="Telerik.Web.UI.RadCompression"/>
</httpModules>
<identity impersonate="false"/>
  </system.web>
     <!-- 
    The system.webServer section is required for running ASP.NET AJAX under Internet
    Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
   <modules>
  <add name="ErrorModule" type="CSC.Web.Common.Errors.ErrorModule"/>
  <add name="securityModule" type="CSC.Web.Common.Security.securityModule"/>
  <add name="RadCompression" type="Telerik.Web.UI.RadCompression"/>
</modules>
<handlers>
  <add name="Telerik.Web.UI.WebResource.axd_*" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" preCondition="integratedMode"/>
  <add name="ScriptResource.axd_GET,HEAD" path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" preCondition="integratedMode"/>
  <add name="*_AppService.axd_*" path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" preCondition="integratedMode"/>
  <add name="*.asmx_*" path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" preCondition="integratedMode"/>
</handlers>
<httpErrors errorMode="DetailedLocalOnly"/>
<defaultDocument>
  <files>
    <add value="Main.aspx"/>
  </files>
</defaultDocument>
 </system.webServer>
 <runtime>
 <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <!--<dependentAssembly>
    <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
  </dependentAssembly>-->
 </assemblyBinding>
</runtime>
<location path="Telerik.Web.UI.WebResource.axd">
  <system.web>
    <authorization>
        <allow users="*"/>
    </authorization>
  </system.web>
</location>
<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding_ITwoWayAsync">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://servername.com/InformationService/MasterDataService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITwoWayAsync" contract="MasterData.MasterDataService" name="BasicHttpBinding_ITwoWayAsync"/>
</client>
</system.serviceModel>
</configuration>

查看iis访问日志并向我们显示向您扔404的确切条目。这将有所帮助。就我们所知,即使在E:\ inetpub \ wwwroot \ WEB_APPS \ CPORT中,“ Main.aspx”也不存在。您要前往自己的站点/ CPORT吗?
Jeff W.

这是条目。146.27.228.73,CT \ jbpj,12/2/2016,13:39:12,W3SVC10067,HOU150W8AHV1590,136.171.92.24,280,779,1498,404,1260,GET,/cport/test.aspx,-如果我将页面更改为test.htm,它就会出现。
jbonwell's

E. \ inetpub \ wwwroot \ WEB_APPS \ CPORT中的文件系统上是否确实存在test.aspx?
Jeff W.

是的,它确实存在。
jbonwell '16

您是否按照上面的建议运行aspnet_regiis命令?
Jeff W.

10

如果所有文件都在假定的位置,请查看您提供的配置,然后执行以下操作。

对于Windows Server 2008/2008 R2

首先确保已安装.NET Framework 4.5.1

从提升的命令提示符处运行以下命令:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

然后打开Internet信息服务

在左侧树视图中选择服务器。

在“ IIS”部分中,打开“ ISAPI和CGI限制”。

对于以“ ASP.NET v4.0”开头的所有项目,请右键单击该项目,然后选择“允许”。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.