在IIS 7上发布的ASP.NET页面报告404

时间:2012-12-12 16:00:00

标签: asp.net asp.net-mvc-4 web-config http-status-code-404

我正在尝试将ASP.NET MVC 4页面用于生产系统。在使用IIS 7和Windows 7 Professional的本地系统上,一切正常。

生产系统:

  • Windows Web Server 2008 R2 64位
  • IIS 7 with .NET 4

对于我创建了一个新IIS站点的页面。对于该站点,我创建了一个新的应用程序池,它使用:.NET Framework v4.0.30319和集成模式。对于应用程序池,32位应用程序的标志被激活,因为我需要将我的应用程序作为32位应用程序运行。

当我通过

访问该页面时
https://localhost:12345/PageName

我收到错误消息:

(我从德语翻译:)     应用程序/ PageName中的服务器错误     无法找到资源

Description: HTTP 404. The resource or a dependency could not be found...
Requested URL: /PageName

Version: .NET 4.0.30319; ASP.NET 4.0.30319.1

路由表:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "MyController", action = "Index", id = "" });

控制器的Index方法如下所示

[ValidateInput(false)]
[RequireHttps(Order = 1)]
public ActionResult Index(string method, string chapterId, string sessionKey, string cn, string ui, string pw, string ProductNumber, string DocumentData)
{
    // something...
}

的web.config

...
<system.web>
     <compilation debug="true" defaultLanguage="c#" targetFramework="4.0" />

     <authentication mode="Forms">
       <forms protection="All" loginUrl="~/Account/Login" timeout="1" />
     </authentication>

     <httpRuntime requestValidationMode="2.0" />

     <sessionState mode="Off" />
</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>

出于调试目的,我将http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx添加到global.asax文件的Application_Start函数中。

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();

    WebApiConfig.Register(GlobalConfiguration.Configuration);
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);

    // added call here
}

路线解决正确。 - &GT; Controller =“MyController”,Action =“Index”,Id =“”

IIS日志

2012-12-12 15:21:04 ::1 GET /PageName - 49266 - ::1 Mozilla/5.0+(compatible;+MSIE+9.0;+Windows+NT+6.1;+WOW64;+Trident/5.0) 404 0 0 656
2012-12-12 15:32:18 ::1 GET /PageName - 49266 - ::1 Mozilla/5.0+(compatible;+MSIE+9.0;+Windows+NT+6.1;+WOW64;+Trident/5.0) 404 0 0 0
2012-12-12 15:37:48 ::1 GET /PageName - 49266 - ::1 Mozilla/5.0+(compatible;+MSIE+9.0;+Windows+NT+6.1;+WOW64;+Trident/5.0) 404 0 0 5687

Windows EventLog不再显示任何内容。

0 个答案:

没有答案