近来,用MVC5开发自己的一个小网站.网上租用了一个小空间(虚拟主机),可选.net版本为2.0 3.0 3.5 4.0 ,上传网站 后发现是403错误.不能访问.

IIS7.0(虚拟机)发布MVC5程序出现Http403错误的解决方法.
IIS7.0(虚拟机)发布MVC5程序出现Http403错误的解决方法.

经与技术人员联系,把虚拟机更换到高版本.net4.5.1上面,还是不行.在本地IIS环境下可以访问.远程服务器下不能访问.
IIS7.0(虚拟机)发布MVC5程序出现Http403错误的解决方法.

多方查资料未能解决.服务器提供方也无能为力了.只能自己再想办法解决.原来在刚刚购买空间时上传了一个.net2.0的程序,能正常运行.而且服务器上以经安装了相应.net框架,理论上是应该能使用的.本着解决问题不怕麻烦的精神,用VS2013建立了多个版本的网站基本程序,(如: .net4.0 MVC4, .net4.5 MVC4, .net4.5 Mvc5,.net4.5.1 MVC5)发现在.net4.0 MVC4,能够访问,其它的三个都不能访问.遂对比Web.config文件.

<?xml version="1.0" encoding="utf-8"?>
<!--
  有关如何配置 ASP.NET 应用程序的详细信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>

  <system.web>
    
    <compilation targetFramework="4.0" />

    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    
    <modules runAllManagedModulesForAllRequests="true" />
    
  <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers></system.webServer>
</configuration>
这是.net4.0 MVC4 的Web.config代码

相关文章:

  • 2021-11-24
  • 2021-11-26
  • 2021-09-25
  • 2021-07-16
  • 2022-02-07
  • 2021-11-15
  • 2021-09-05
猜你喜欢
  • 2021-08-10
  • 2021-06-28
  • 2022-12-23
  • 2021-08-07
  • 2022-03-09
  • 2021-12-16
  • 2021-05-29
相关资源
相似解决方案