我最近将我的Web应用程序升级到.NET 4.5.将代码推送到我们的测试环境后,我得到一个“404 – 文件或目录未找到”.错误.代码在我的VS2013桌面上运行良好. Web服务器在W2K08 R2上运行IIS 7.5.我可以在网站上查看.asp或.htm页面,但在尝试查看最简单的.aspx页面时会出现此错误.我怀疑这是我的web.config的配置问题.
解决方法
这是web.config.
http://go.microsoft.com/fwlink/?LinkId=235367.
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,PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Windows.Forms,PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Drawing.Design,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,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,PublicKeyToken=31bf3856ad364e35"/> <add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler,Version=3.5.0.0,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,PublicKeyToken=31BF3856AD364E35" preCondition="integratedMode"/> <add name="*_AppService.axd_*" path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory,PublicKeyToken=31BF3856AD364E35" preCondition="integratedMode"/> <add name="*.asmx_*" path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory,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>