IIS7.5 migration, iis7.5 Configuration

Source: Internet
Author: User
Tags log4net

IIS7.5 migration, iis7.5 Configuration

When the Asp.net application is migrated to IIS7.5, the site reports an HTTP Error 404.0-Not Found. The process is as follows:
Runtime Environment: Framework 2.0, IIS7.5, and a set of Web sites without source code. The application pool is in Classic mode by default.
The URL of the error page is as follows: http: // localhost/HL2008/UI/AutoMonitor/135? Autorun = true
When we see this URL address, the first response is that the HttpModule is overwritten. We decompile HL2008.Web. Common. dll through. net reflector 7.0 and find that the UrlRewriter class implements the System. Web. IHttpModule interface.
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 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 called ") ;}} public static bool IsAutoMon (out string PermissionId) {PermissionId = GetPermissionId (); return! String. isNullOrEmpty (PermissionId);} public static string GetPermissionId () {return GetPermissionId (HttpContext. current. request. rawUrl);} public static string GetPermissionId (string url) {ILog log = log4net. logManager. getLogger (MethodBase. getCurrentMethod (). declaringType); log. info ("DemoHttpModule GetPermissionId called"); log. info (string. format ("Url 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 expression 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 ;}

Therefore, it was preliminarily determined that the HttpModule was not activated, through the Web search, find a similar blog (http://q.cnblogs.com/q/38592/), which mentioned IIS7.5 httpModules use: 404 to solve, add the modules configuration to <system. webServer> Configuration section.
In web. config, httpModules and httpHandlers are configured under <system. web>, and modules and handlers are configured under <system. webServer>.
The problem persists. By inserting the modules component with log4net logs into the logs output by the original application, the application does not activate http: /// localhost/HL2008/UI/AutoMonitor/135? The request autorun = true has been terminated before. The log is as follows:

-DemoHttpModule context_BeginRequest was called 12:41:37, 010 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 12:41:37, 010 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/UI/Security/Main. aspx/FocusHashCode] 12:41:37, 010 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-12 12:41:37, 010 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. isAutoMon = false was called 12:42:01, 313 [1276] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 12:42:01, 313 [1276] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 12:42:01, 313 [1276] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/UI/Security/Main. aspx/FocusHashCode] 12:42:01, 313 [1276] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-12 12:42:01, 313 [1276] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. isAutoMon = false was called 12:42:06, 804 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 12:42:06, 804 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 12:42:06, 804 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/UI/Security/Main. aspx/FocusHashCode] 12:42:06, 804 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-12 12:42:06, 804 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. isAutoMon = false was called 12:42:11, 921 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 12:42:11, 921 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 12:42:11, 921 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/UI/Security/Main. aspx/FocusHashCode] 12:42:11, 921 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-12 12:42:11, 921 [4084] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. isAutoMon = false called

The problem is defined as: modules is called, but http: // localhost/HL2008/UI/AutoMonitor/135 is not activated? Autorun = true.
Continue, set the application pool to integration mode. The IIS error is as follows:
HTTP 500.22-Internal Server Error
Detected ASP. NET settings that are 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.
Therefore, the system. web/httpModules configuration section is removed.
Initiate a request to continue with the 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.
The content of the request. log is as follows:

22:03:18, 058 [6676] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule init was called 22:03:18, 136 [6676] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 22:03:18, 136 [6676] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 22:03:18, 136 [6676] INFO Demo. demoHttpModule [(null)] <(null)>-U The rl address is [/HL2008/UI/AutoMonitor/135? Autorun = true] 22:03:18, 136 [6676] INFO Demo. DemoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. IsAutoMon = true is called

After being deployed to the production environment, the JQuery framework on the Framework page becomes invalid. Continue the analysis. The ScriptManager control is used on the Framework page. The generated Html code is shown as follows:

<script src="/HL2008/ScriptResource.axd?d=v9-Vun33Q_Tt6fz_-KdfOxFkktcmXkHtJ_xaAlnYyRI1w9v_8zmlGWWHE_7u5Jrvi61k8TbJhxrwk5pWmXh_t7arSi5GkKCo5fRbtk8AocTMmYe-Z7DxXDxZ58VlpPixyBnc59F5eZHs5UV4zWR1dzu8BAU-upWipKdmIR9lgzaYhBED0&t=fffffffff9d85fa6" type="text/javascript"></script><script type="text/javascript"> 

Check the web. config file again and add the following configuration to webServer (inspired by the code automatically generated when you create a web project ):

The configuration in the old web. config corresponding to the above Code is as follows:

After the web. config file is modified, the generated debugging log is as follows:

17:23:36, 107 [6872] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 17:23:36, 107 [6872] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 17:23:36, 107 [6872] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/WebResource. axd? D = gzmZlqjdAFh6OdPGsBWp09jjWPrybcivIxB1dm9gbM8VxMISKAXu6a4U2PqImHgLFM7eAwQYHR9YWjCvEdtxcmFt2KUu6k398_VF7VKu6P0hbarkRVBG1v0HhDL3RubSr-FjRA2 & t = 634134071139291572] 17:23:36, 107 [6872] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-13 17:23:36, 107 [6872] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. isAutoMon = fal Se was called 17:23:36, 170 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 17:23:36, 170 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 17:23:36, 170 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/ScriptResource. axd? D = N98 _-SqLQ5674uNkLlgKa0Owba70UUJIMsXPPAsyT8skc5Y68FcDhDOE2hZO2_Abfm4CJI36eipVEOKx_qvvj5tECsi8ECd2UEcZevylFPlnvkifyGrPKKvzZONnzCSOA-CDsOISCtqpIQkZHcFG1b-8QFs1 & t = 434e8d85] 17:23:36, 170 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-13 17:23:36, 170 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. isA UtoMon = false was called 17:23:36, 170 [11096] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 17:23:36, 170 [11096] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 17:23:36, 170 [11096] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/ScriptResource. axd? D = v9-Vun33Q_Tt6fz _-KdfOxFkktcmXkHtJ_xaAlnYyRI1w9v_8zmlGWWHE_7u5Jrvi61k8TbJhxrwk5pWmXh_t7arSi5GkKCo5fRbtk8AocTMmYe-Z7DxXDxZ58VlpPixyBnc59F5eZHs5UV4zWR1dzu8BAU-upWipKdmIR9lgzaYhBED0 & t = fffffffff9d85fa6] 17:23:36, 170 [11096] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-13 17:23:36, 170 [11096] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_ B EginRequest-GlobalDefine. isAutoMon = false was called 17:23:36, 170 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule init was called 17:23:36, 170 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 17:23:36, 170 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 17:23:36, 170 [10228] INFO Demo. DemoHttpModule [(null)] <(null)>-the Url is [/HL2008/ScriptResource. axd? D = cNixn-OEPWiQvFR3nFBwBrScpOjRsGp3fK5-H9KtsGrmb5eRvELjuTbsfhOOw80UrKbNl6SQ8-0hshzPc4OU2ynAKKiUHOR-vFpJxtiDz2fm420esofumH2wQGbp5wRVQjPsut_vVJsyCltqoJO2yiIOgA_iWolrD9KQNUVR6IBhOY3U0 & t = 434e8d85] 17:23:36, 170 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-13 17:23:36, 170 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequ Est-GlobalDefine. isAutoMon = false was called 17:23:36, 170 [11096] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 17:23:36, 170 [11096] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 17:23:36, 170 [11096] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/ScriptResource. axd? D = GkKeUdwTdRtNhm1Ma1oioEFAgffAgAW_IXjB82oPb2TS8P8ORcSnRzj-mMUHz0DqTyxBwcApwJHW6TtsGFJAg9GUe_PAIQks-Mb5WHwblXUn3u_FGjbGRGIjGbLZP5C05BIa63bIg9F1gYs-gw_xTr8IgDU1 & t = 434e8d85] 17:23:36, 170 [11096] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-13 17:23:36, 170 [11096] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. isA UtoMon = false was called 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/ScriptResource. axd? D = iHAPcT_FVgUzSSekKo0HhOH348ApF9q6M46cXylkg7WB62P5SDfYGAEH8pzg6XDXyS7COBUUOw4Fi-UMAJxKG_ADQ3oE0UkqOshzqC1PcDtV8tbAQJqIN7dSKhFMq7naNJRSkw2 & t = 434e8d85] 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-13 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. isAutoMon = false called 20 15-01-13 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/WebResource. axd? D = found & t = 634259354654344891] 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-13 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. isAutoMon = false called 17:23:36, 185 [10228] INF O Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is <span style = "color: # ff0000;"> [/HL2008/ScriptResource. axd? D = fill _-KpQ9Q6lkll0eG-QfovrUW1f2A4xfJkZnlNqRzbVG0GKMOqqst59KbZ_eEFL25pKyFJr9Zh-90 & t = fffffff9d85fa6 </span>] 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-after the first regular expression match: mc. count = 02015-01-13 17:23:36, 185 [10228] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule co Ntext_BeginRequest-GlobalDefine. isAutoMon = false was called 17:23:37, 730 [5544] INFO Demo. demoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest was called 17:23:37, 730 [5544] INFO Demo. demoHttpModule [(null)] <(null)>-The DemoHttpModule GetPermissionId is called 17:23:37, 730 [5544] INFO Demo. demoHttpModule [(null)] <(null)>-the Url is [/HL2008/UI/AutoMonitor/135? Autorun = true] 17:23:37, 745 [5544] INFO Demo. DemoHttpModule [(null)] <(null)>-DemoHttpModule context_BeginRequest-GlobalDefine. IsAutoMon = true is called

The problem was finally solved when the problem was re-deployed to the production environment.
Summary:

IIS7.5 404: register the httpModule in system. web to the modules of system. webServer. If the application pool is in Classic mode, the module is not activated correctly. An exception will occur and termination will occur.
1. you only need to switch the application pool to the integration mode and remove the system. the httpModules and httpHandlers configuration sections of the web can correctly activate the module. (if you do not remove the httpModules and httpHandlers registration used in Classic mode, you mustValidationElementValidateIntegratedModeConfigurationSet propertyFalseTo avoid errors)

<pre class="html" name="code"><system.webServer>           
                <modules runAllManagedModulesForAllRequests="true">                </modules><span style="color:#ff0000;"><validation validateIntegratedModeConfiguration="false"/></span>

2. in integration mode. content Under httpHandlers in the web is migrated to system. under webServer. to ensure that httpHandlers (asp.net framework level) can run normally.

Ps: Thanks to csdn's customer service. This article was published around last night. When I modified this blog post this afternoon, I found that my account was stolen and this article was also deleted, it's csnd's customer service that helped me retrieve my password and this article. Thanks again !!

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.