{"id":2884,"date":"2014-03-09T05:14:43","date_gmt":"2014-03-09T05:14:43","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/09\/iis-stopped-working-collection-of-common-programming-errors\/"},"modified":"2014-03-09T05:14:43","modified_gmt":"2014-03-09T05:14:43","slug":"iis-stopped-working-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/09\/iis-stopped-working-collection-of-common-programming-errors\/","title":{"rendered":"IIS stopped Working-Collection of common programming errors"},"content":{"rendered":"<p>I am developing web application using (C#) and (ASP.NET Web API) and MS SQL 2008 R2 and hosting on IIS7 in Windows Server 2008, All APIs return data in JSON<\/p>\n<p>When i call any API from any web browser and refresh the page to call again before the first call finishes it give me warning in the event viewer and after 0 to 5 minutes the worker process in the II7 stopped for about 2 minutes(hang) and all APIs calls from all users at the period of those 2 minutes don&#8217;t work and event viewer give me an error:<\/p>\n<p><strong>The Warning in the event viewer<\/strong><\/p>\n<pre><code>Event code: 3005 \nEvent message: An unhandled exception has occurred. \nEvent time: 6\/5\/2012 3:29:10 PM \nEvent time (UTC): 6\/5\/2012 1:29:10 PM \nEvent ID: 63adcb812864465cab58e9f870bcbb92 \nEvent sequence: 5 \nEvent occurrence: 1 \nEvent detail code: 0 \n\nApplication information: \n    Application domain: \/LM\/W3SVC\/2\/ROOT\/AAA-2-129833765408950000 \n    Trust level: Full \n    Application Virtual Path: \/AAA\n    Application Path: C:\\inetpub\\wwwroot\\AAA\\ \n    Machine name: MyMachine\n\nProcess information: \n    Process ID: 9860 \n    Process name: w3wp.exe \n    Account name: NT AUTHORITY\\NETWORK SERVICE \n\nException information: \n    Exception type: HttpException \n    Exception message: The remote host closed the connection. The error code is 0x800704CD.\n   at System.Web.Http.WebHost.HttpControllerHandler.EndProcessRequest(IAsyncResult result)\n   at System.Web.Http.WebHost.HttpControllerHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)\n   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\n   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)\n\n\n\nRequest information: \n    Request URL: My API URL\n    Request path: API Path \n    User host address: My IP \n    User:  \n    Is authenticated: False \n    Authentication Type:  \n    Thread account name: NT AUTHORITY\\NETWORK SERVICE \n\nThread information: \n    Thread ID: 8 \n    Thread account name: NT AUTHORITY\\NETWORK SERVICE \n    Is impersonating: False \n    Stack trace:    at System.Web.Http.WebHost.HttpControllerHandler.EndProcessRequest(IAsyncResult result)\n   at System.Web.Http.WebHost.HttpControllerHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)\n   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\n   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)\n<\/code><\/pre>\n<p><strong>The Error in the event viewer<\/strong><\/p>\n<pre><code>An unhandled exception occurred and the process was terminated.\n\nApplication ID: \/LM\/W3SVC\/2\/ROOT\/AAA\n\nProcess ID: 9860\n\nException: System.AggregateException\n\nMessage: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.\n\nStackTrace:    at System.Threading.Tasks.TaskExceptionHolder.Finalize()\n\nInnerException: System.Web.HttpException\n\nMessage: The remote host closed the connection. The error code is 0x800704CD.\n\nStackTrace:    at System.Web.Http.WebHost.HttpControllerHandler.EndProcessRequest(IAsyncResult result)\n   at System.Web.Http.WebHost.HttpControllerHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)\n   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\n   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)\n<\/code><\/pre>\n<ol>\n<li>\n<p>public class contentController : ApiController { dynamic json = new JsonObject();<\/p>\n<pre><code>    \/\/ GET \/api\/v1\/content      \n    [HttpGet]\n    public IEnumerable GetContent()\n    {\n        Request.Headers.Add(\"Accept\", \"application\/json\");\n        List contentList = new List() ;\n        try\n        {\n            \/\/DateTime CurrentDateTime = DateTime.Now;\n\n            var querystring = this.Request.RequestUri.Query;\n            var parameters = HttpUtility.ParseQueryString(querystring);\n\n            string userID = parameters[\"userID\"];\n            string countryCode = parameters[\"countryCode\"];\n            string language = parameters[\"language\"];\n            string categoryName = parameters[\"categoryName\"];\n            string subcategoryID = parameters[\"subcategoryID\"];\n            string count = parameters[\"count\"];\n            string start = parameters[\"start\"];\n            string platform = parameters[\"platform\"];\n            string imageSize = parameters[\"imageSize\"];\n\n\n\n            \/\/Check IP Restiriction\n            Restriction restiriction = new Restriction(ConfigurationManager.ConnectionStrings[\"AppSQLConnection\"].ToString());\n            bool allowedCheck = restiriction.IsUserAllowed(userID);\n            if (!allowedCheck)\n            {\n                dynamic json = new JsonObject();\n                json.message = \"Authorized Only for Mobinil in Egypt\";\n                var msg = new HttpResponseMessage(System.Net.HttpStatusCode.Forbidden);\n                msg.Content = new StringContent(json.ToString());\n                msg.Content.Headers.ContentType.MediaType = \"application\/json\";\n                throw new HttpResponseException(msg);\n            }\n            else\n            {\n\n\n\n                \/\/Validate input data\n                if (InputValidation.isValidUserid(userID) &amp;&amp;\n                    InputValidation.isValidCountryCode(countryCode) &amp;&amp;\n                    InputValidation.isValidLanguage(language) &amp;&amp;\n                    InputValidation.isValidCategory(categoryName) &amp;&amp;\n                    InputValidation.isValidUserid(subcategoryID) &amp;&amp;\n                    InputValidation.isValidPlatform(platform)\n                    )\n                {\n                    if (!InputValidation.isValidImageSize(imageSize))\n                    {\n                        imageSize = \"high\";\n                    }\n\n                    if (!InputValidation.isValidUserid(count) || !InputValidation.isValidUserid(start))\n                    {\n                        start = WebConfigurationManager.AppSettings[\"DefaultStart\"];\n                        count = WebConfigurationManager.AppSettings[\"DefaultCount\"];\n                    }\n\n                    ContentOperations contentOperations = new ContentOperations();\n                    contentList = contentOperations.getContent(subcategoryID, categoryName, count, start, countryCode, userID, ConfigurationManager.ConnectionStrings[\"AppSQLConnection\"].ToString(), WebConfigurationManager.AppSettings[\"FileFolderName\"], imageSize, language, platform);\n                    if (contentList != null)\n                    {\n                        List contentOutputList = new List();\n                        foreach (ZMSLibrary.ME.Models.Content c in contentList)\n                        {\n                            File tempFile = new File();\n                            ME_API_V1.Models.Content cTemp = new ME_API_V1.Models.Content();\n                            cTemp.contentID = int.Parse(c.ContentID);\n                            if (c.Rating == \"1\")\n                                cTemp.userRating = \"Like\";\n                            else if (c.Rating == \"0\")\n                                cTemp.userRating = \"Dislike\";\n\n                            cTemp.date = String.Format(\"{0:G}\", c.ContentDate);\n\n                            \/\/if (c.Provider.ContentProviderName != \"\")  \/\/to make the value null instead of \"\"\n                            cTemp.providerName = c.Provider.ContentProviderName;\n                            \/\/if (c.Provider.ContentProviderIcon != \"\")\n                            cTemp.providerIconURL = c.Provider.ContentProviderIcon;\n                            \/\/if (c.Provider.ContentProviderImage != \"\")\n                            cTemp.providerImageURL = c.Provider.ContentProviderImage;\n\n                            if (language == \"AR\")\n                            {\n                                \/\/if (c.ContentArabicTitle != \"\")\n                                cTemp.title = c.ContentArabicTitle;\n                                \/\/if (c.ContentArabicSubTitle != \"\")\n                                cTemp.subtitle = c.ContentArabicSubTitle;\n                                \/\/if (c.ContentArabicDescription != \"\")\n                                cTemp.description = c.ContentArabicDescription;\n                            }\n                            else\n                            {\n                                \/\/if (c.ContentEnglishTitle != \"\")\n                                cTemp.title = c.ContentEnglishTitle;\n                                \/\/if (c.ContentEnglishSubTitle != \"\")\n                                cTemp.subtitle = c.ContentEnglishSubTitle;\n                                \/\/if (c.ContentEnglishDescription != \"\")\n                                cTemp.description = c.ContentEnglishDescription;\n                            }\n\n                            if (categoryName == \"Music\")\n                            {\n                                foreach (ContentFile cf in c.ContentFiles)\n                                {\n                                    if (cf.FileType.FileTypeName == \"Icon\")\n                                        tempFile.iconURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"Image\")\n                                        tempFile.imageURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"Clip_High\")\n                                        tempFile.highVideoURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"Clip_Low\")\n                                        tempFile.lowVideoURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"Tone\")\n                                        tempFile.toneURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"Song\")\n                                        tempFile.songURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"YouTube\")\n                                        tempFile.youtubeID = cf.ContentFileName;\n\n                                }\n\n                            }\n                            else if (categoryName == \"News\")\n                            {\n                                foreach (ContentFile cf in c.ContentFiles)\n                                {\n                                    if (cf.FileType.FileTypeName == \"Icon\")\n                                        tempFile.iconURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"Image\")\n                                        tempFile.imageURL = cf.ContentFileName;\n\n                                }\n\n                            }\n                            else if (categoryName == \"Videos\")\n                            {\n                                foreach (ContentFile cf in c.ContentFiles)\n                                {\n                                    if (cf.FileType.FileTypeName == \"Icon\")\n                                        tempFile.iconURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"Image\")\n                                        tempFile.imageURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"Video_High\")\n                                        tempFile.highVideoURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"Video_Low\")\n                                        tempFile.lowVideoURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"YouTube\")\n                                        tempFile.youtubeID = cf.ContentFileName;\n\n                                }\n\n                            }\n                            else if (categoryName == \"Applications\")\n                            {\n                                foreach (ContentFile cf in c.ContentFiles)\n                                {\n                                    if (cf.FileType.FileTypeName == \"Icon\")\n                                        tempFile.iconURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"Image\")\n                                        tempFile.imageURL = cf.ContentFileName;\n                                    else if (cf.FileType.FileTypeName == \"App_Android\" || cf.FileType.FileTypeName == \"App_Nokia\" || cf.FileType.FileTypeName == \"App_Blackberry\" || cf.FileType.FileTypeName == \"App_iPhone\")\n                                    {                                           \n                                            tempFile.appURL = cf.ContentFileName;                                               \n                                    }\n\n                                }\n\n                            }\n\n                            cTemp.files = tempFile;\n                            contentOutputList.Add(cTemp);\n                        }\n                        return contentOutputList;\n\n                    }\n\n                }\n\n                if (contentList == null)\n                    throw new Exception();\n                else\n                {\n                    json.message = \"Wrong or missing data\";\n                    var msg = new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest);\n                    msg.Content = new StringContent(json.ToString());\n                    msg.Content.Headers.ContentType.MediaType = \"application\/json\";\n                    throw new HttpResponseException(msg);\n                }\n            }\n\n\n\n\n        }       \n        catch (Exception ex)\n        {\n            if (ex is HttpResponseException)\n            {\n                throw;\n            }\n            else\n            {\n                json.message = \"Error in System\";\n                var msg = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);\n                msg.Content = new StringContent(json.ToString());\n                msg.Content.Headers.ContentType.MediaType = \"application\/json\";\n                throw new HttpResponseException(msg);\n            }\n        }\n\n    }\n\n\n}\n<\/code><\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>I am developing web application using (C#) and (ASP.NET Web API) and MS SQL 2008 R2 and hosting on IIS7 in Windows Server 2008, All APIs return data in JSON When i call any API from any web browser and refresh the page to call again before the first call finishes it give me warning [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2884","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2884","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2884"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2884\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}