Iis7.5-http Error 404.0-not found-0x80070002 error analysis and solution

Source: Internet
Author: User
Tags httpcontext log4net

When a customer migrates to IIS7.5, the site reports an HTTP error 404.0-not Found error. The process is as follows:

Customer Environment: Framework 2.0,iis7.5,web Site set, no source code, application Chime considered Classic mode.

The URL of the error page is as follows: Http://localhost/HL2008/UI/AutoMonitor/135?autorun=true

See this URL address, the first reaction is HttpModule was rewritten, through the. NET Reflector 7.0 anti-compilation HL2008.Web.Common.dll, found Urlrewriter class, Implements the System.Web.IHttpModule interface.

Continue tracking, the core code of this class is a jump operation.

void Context_beginrequest (object sender, EventArgs e) {//string path = string.            Format ("~/action/requesthandler.aspx?id={0}&{1}", "Yeyang", HTTPCONTEXT.CURRENT.REQUEST.RAWURL);            HttpContext.Current.RewritePath (Path,false); ILog log = log4net. Logmanager.getlogger (Methodbase.getcurrentmethod ().            DeclaringType); Log.            Info ("Demohttpmodule context_beginrequest is called"); String p = string.            Empty; if (Globaldefine.isautomon (out P)) if (Isautomon (out p)) {log.                Info ("demohttpmodule Context_beginrequest-globaldefine.isautomon = = True is called"); String path = string.                Format ("~/ui/automonitor/automonitorbasepage.aspx?id={0}&{1}", p, HttpContext.Current.Request.QueryString);            HttpContext.Current.RewritePath (path, false); } else {log.    Info ("demohttpmodule Context_beginrequest-globaldefine.isautomon = = False is called");        }        } 


 

  public static bool Isautomon (out string permissionid) {PermissionID = Getpermissionid (); Return!string.        IsNullOrEmpty (PermissionID);        } public static string Getpermissionid () {return Getpermissionid (HTTPCONTEXT.CURRENT.REQUEST.RAWURL); The public static string Getpermissionid (string url) {ILog log = log4net. Logmanager.getlogger (Methodbase.getcurrentmethod ().            DeclaringType); Log.            Info ("Demohttpmodule Getpermissionid is called"); Log. Info (String.            Format ("URL address is [{0}]", url)); String PermissionID = String.            Empty; MatchCollection mc = new Regex (@ "\/ui\/automonitor\/(?<permissionid> (\d+)) (($) | ( \?\s+)) ", regexoptions.ignorecase).            Matches (URL); if (MC. Count > 0) {return mc[0]. groups["PermissionID"].            Value; } log. Info ("After the first regular match: MC.            Count = = 0 "); MC = new Regex (@ "/ui/automonitor/automonitorbasepagE.aspx\?id= (? <permissionid>\d+) ", regexoptions.ignorecase).            Matches (URL); if (MC. Count > 0) {permissionid = mc[0]. groups["PermissionID"].            Value;        } return PermissionID; }


So the preliminary decision for HttpModule is not activated, through the web search, to find a similar post (http://q.cnblogs.com/q/38592/), which refers to IIS7.5 under the httpmodules use appears: 404 To resolve, you need to add the modules configuration to the <system.webServer> configuration section.

In the Web. config at this point, there are modules and handlers configurations under <system.web> under the httpmodules and httphandlers configurations,<system.webserver>.

The problem is still unresolved, the application is not activated by inserting the modules component of the Log4net log into the output log in the original application http://localhost/HL2008/UI/AutoMonitor/ 135?autorun=true the request had been terminated before. The log is as follows:

 -Demohttpmodule Context_beginrequest is called 2015-01-12 12:41:37,010 [4084] INFO demo.demohttpmodule [(NULL)] < (NULL) ;  -Demohttpmodule Getpermissionid is called 2015-01-12 12:41:37,010 [4084] INFO demo.demohttpmodule [(NULL)] < (NULL) >-URL Address is [/hl2008/ui/security/main.aspx/focushashcode]2015-01-12 12:41:37,010 [4084] INFO demo.demohttpmodule [(NULL)] < (NULL) >-After the first regular match: MC. Count = = 02015-01-12 12:41:37,010 [4084] INFO demo.demohttpmodule [(NULL)] < (NULL) >-Demohttpmodule context_beginr Equest-globaldefine.isautomon = = False is called 2015-01-12 12:42:01,313 [1276] INFO demo.demohttpmodule [(NULL)] < (NULL) &G T -Demohttpmodule Context_beginrequest is called 2015-01-12 12:42:01,313 [1276] INFO demo.demohttpmodule [(NULL)] < (NULL)  >-Demohttpmodule Getpermissionid is called 2015-01-12 12:42:01,313 [1276] INFO demo.demohttpmodule [(NULL)] < (NULL) > -The URL address is [/hl2008/ui/security/main.aspx/focushashcode]2015-01-12 12:42:01,313 [1276] INFO demo.demohttpmodule [(NULL) ] <(null) >-After the first regular match: MC. Count = = 02015-01-12 12:42:01,313 [1276] INFO demo.demohttpmodule [(NULL)] < (NULL) >-Demohttpmodule context_beginr Equest-globaldefine.isautomon = = False is called 2015-01-12 12:42:06,804 [4084] INFO demo.demohttpmodule [(NULL)] < (NULL) &G T -Demohttpmodule Context_beginrequest is called 2015-01-12 12:42:06,804 [4084] INFO demo.demohttpmodule [(NULL)] < (NULL)  >-Demohttpmodule Getpermissionid is called 2015-01-12 12:42:06,804 [4084] INFO demo.demohttpmodule [(NULL)] < (NULL) > -The URL address is [/hl2008/ui/security/main.aspx/focushashcode]2015-01-12 12:42:06,804 [4084] INFO demo.demohttpmodule [(NULL) ] < (NULL) >-After the first regular match: MC. Count = = 02015-01-12 12:42:06,804 [4084] INFO demo.demohttpmodule [(NULL)] < (NULL) >-Demohttpmodule context_beginr Equest-globaldefine.isautomon = = False is called 2015-01-12 12:42:11,921 [4084] INFO demo.demohttpmodule [(NULL)] < (NULL) &G T -Demohttpmodule Context_beginrequest is called 2015-01-12 12:42:11,921 [4084] INFO demo.demohttpModule [(NULL)] < (NULL) >-Demohttpmodule Getpermissionid is called 2015-01-12 12:42:11,921 [4084] INFO Demo.demohttpmodu  Le [(NULL)] < (NULL) >-the URL address is [/hl2008/ui/security/main.aspx/focushashcode]2015-01-12 12:42:11,921 [4084] INFO Demo.demohttpmodule [(NULL)] < (NULL) >-After the first regular match: MC. Count = = 02015-01-12 12:42:11,921 [4084] INFO demo.demohttpmodule [(NULL)] < (NULL) >-Demohttpmodule context_beginr Equest-globaldefine.isautomon = = False is called

The problem is defined as themodules is called, but the request is not activated http://localhost/HL2008/UI/AutoMonitor/135?autorun=true.

To continue, set the application pool to Integrated mode, when IIS errors are as follows:

HTTP Error 500.22-internal Server error detected an ASP. NET setting that is not applicable in integrated managed pipeline mode. Module: Configurationvalidationmodule Notification: BeginRequest handler: Staticfile error code: 0x80070032

The key information is as follows:

Most likely cause: This application defines the configuration in the System.web/httpmodules section.

So the System.web/httpmodules configuration section was removed.

To initiate a request to continue HTTP error, the key information is as follows:

? This application defines the configuration in the System.web/httphandlers section.

Remove the System.web/httphandlers configuration section.

Initiate the request. The log contents are as follows:

2015-01-12 22:03:18,058 [6676] INFO  demo.demohttpmodule [(NULL)] < (NULL) >-demohttpmodule init called 2015-01-12 22:03:18,136 [6676] INFO  demo.demohttpmodule [(NULL)] < (NULL) >-Demohttpmodule context_beginrequest Called 2015-01-12 22:03:18,136 [6676] INFO  demo.demohttpmodule [(NULL)] < (NULL) >-Demohttpmodule Getpermissionid is called 2015-01-12 22:03:18,136 [6676] INFO  demo.demohttpmodule [(NULL)] < (NULL) >-the URL address is [/ Hl2008/ui/automonitor/135?autorun=true]2015-01-12 22:03:18,136 [6676] INFO  demo.demohttpmodule [(NULL)] < ( NULL) >-Demohttpmodule Context_beginrequest-globaldefine.isautomon = = True is called

The problem is finally solved.

Summarized as follows:

IIS7.5 404, the HttpModule in System.Web is registered to system.webserver modules, and if the application pool is in Classic mode, module is not activated correctly. An abnormal termination occurs.

The module can be activated correctly only if the application pool is switched to integrated mode and the System.Web httpmodules and httphandlers are completely removed.

Iis7.5-http Error 404.0-not found-0x80070002 error analysis and solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.