HTTP Error 500.0 - Internal Server Error, AspNetInitializationExceptionModule VS 2015 - visual-studio

After running some NuGet Updates my project will not run locally throwing "HTTP Error 500.0 - Internal Server Error" and referencing Handler "AspNetInitializationExceptionModule"
I'm using VS 2015, .NET Framework 4.6.1, Any CPU, IISExpress.
The refered link suggests I look into the IIS Logs which are full of data but there seems to be no information for these eyes.
I Understand that 500.0 is the server shouting that something generic went wrong but frankly I don't know what to try next.
Any thoughts?
Frustrated in New Hampshire.
More info
adding a vanilla favicon.ico still resulted in 500.0 but now just at the root.
HTTP500: SERVER ERROR - The server encountered an unexpected condition that prevented it from fulfilling the request.
(XHR): GET - http://localhost:3029/

Drilling into Eventviewer/Custom Views/Summary page events I found an ASP.NET 4.0.30319.0 Warning.
At the bottom of the warning detail it says
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) Could not load file or assembly 'Microsoft.AI.Agent.Intercept' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
http://localhost:3029/
So my Nuget Update incorrectly updated Microsoft Application Insights.
Uninstalled it and now I'm back to earning a living.
It seems that when IIS knows it has an exception it should tell the browser.
Pat NH USA

Related

Azure App Service recently started throwing an error: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.1.4.0

I didn't change anything, and my Azure App Service started throwing the error:
An error occurred while starting the application.
FileLoadException: Could not load file or assembly'Microsoft.EntityFrameworkCore, Version=2.1.4.0 ...
Which seemed odd, so I tried adding Microsoft.EntityFrameworkCore v2.1.4 with Nuget, and from that i just get a white error screen with
This page isn’t working
[WEBSITE] is currently unable to handle this request.
HTTP ERROR 500
With no other errors.
This all works perfectly fine locally (as always...) - I am not sure where to go from here? Any ideas? Thank you.
The error is because of the different versions between packages.
Please use this command in PM.
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design -Version 2.0.3
For more details, you could refer to this issue.

Intermittent "Could not load type 'System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter'" Error

I am working on a project that includes an ASP.NET WebAPI component.
Intermittently, I get the following error:
Could not load type
'System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter' from
assembly 'System.Net.Http.Formatting, Version=5.2.3.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
with the source error pointing to my GlobalConfiguration.Configure() call:
Line 35: {
Line 36: AreaRegistration.RegisterAllAreas();
Line 37: GlobalConfiguration.Configure(WebApiConfig.Register); //<-- error here
Line 38: FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
Line 39: RouteConfig.RegisterRoutes(RouteTable.Routes);
In my register, I am doing the following to return JSON by default:
var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes
.FirstOrDefault(t => t.MediaType == "application/xml");
if (appXmlType != null)
{
config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
}
(not sure of the source, but found somewhere on this site as a way to return JSON by default, unless the caller asks for something else)
I'd like to continue to return JSON as the default content type going forward.
The project includes two other (non WebAPI) websites (that are MVC5), which hit the WebAPI site.
Here's the interesting thing:
This DOES NOT happen when the application is deployed (to Azure)
This only happens occasionally
Typically, I run one of the MVC5 sites in the debugger and see this issue
If I navigate directly to the WebAPI site after the above, I'll get the "Yellow Screen of Death" with the error as per above
Sometimes, even after a cold reboot, this error will NOT appear, other times it will
What I currently do to work around the problem:
If I run the WebAPI site in the debugger, if the error is present, it will fixed itself
After running in the debugger (per above), I can relaunch an MVC5 site in the debugger and the issue goes away
Just to repeat, this DOES NOT happen ever when the application is deployed to Azure.
I have multiple developers working on this project, and we all run into the same error at some stage.
I am referencing the following Nuget packages:
Microsoft.AspNet.WebApi (version 5.2.3)
Microsoft.AspNet.WebApi.Client (version 5.2.3)
Microsoft.AspNet.WebApi.Core (version 5.2.3)
Microsoft.AspNet.WebApi.Owin (version 5.2.2)
Microsoft.AspNet.WebApi.WebHost (version 5.2.3)
If I look inside the *.csproj file, I have a reference to the following:
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
<Private>True</Private>
</Reference>
I've checked the bin folder of the website, and all the assemblies inside it have the correct version as per the above list (including System.Net.Http.Formatting.dll).
Also note that, during debugging and development, each of the three websites are run under Local IIS (constraints of external resources force us to do this), so I have:
http://localhost/site1
http://localhost/site2
http://localhost/api
It's becoming cumbersome to get into a debugging session, to get this error, to then stop debugging, launch the API site under the debugger, and to then switch back to what I was doing at the start.
Not sure where else to go to track down what is happening here. Any ideas?
Update - 26 July 2016
Still have this happening. Since posting the question, have updated the WebAPI to run in its own Application Pool, but that doesn't seem to have made a difference.
Uninstalled Web API 2 NuGet package
Installed Web API 2 NuGet package again.
I think you are going about it wrong. Try setting JSON as your default media formatter like this:
// first clear all formatters
config.Formatters.Clear();
// Since JSON is the first added,
// it will be the "default" if no Accept header present
config.Formatters.Add(new JsonMediaTypeFormatter());
// You can choose not to add these back if you never want to use them,
// up to you.
config.Formatters.Add(new XmlMediaTypeFormatter());
config.Formatters.Add(new FormUrlEncodedMediaTypeFormatter());
I had added what was possibly an incorrect version of System.Net.Http.Formatting to my Global Assembly Cache (GAC) and started getting
Could not load type
'System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter' from assembly
'System.Net.Http.Formatting
errors in my Webservice. After removing this System.Net.Http.Formatting dll from GAC my webservice started working again.
when you build looks for any warning that talks about conflict. Double-clicking on the warnings injects the compatible versions in the section of web.config. This obviously can be done manually also.

WCF not working when debugging in visual studio but works in IE

I have a WCF that is hosted in an ASP.NET application. Suddenly, the WCF service has stopped working when i debug it in visual studio 2010. When i try to access the service, it throws the below exception.
CommunicationException was unhandled by user code. The remote server returned an error: NotFound
I have WCF tracing enabled but no errors are being logged.
The strange bit is that if i deploy the code to my QA server and access the application, the service works fine, so the code looks like not the problem.
If i also get the source code currently running in production successfully & try debugging it in my dev environment, it fails with the same error i mention above.
Any one have an idea what could be messed up in my dev environment?. I have tried both IE, Firefox & Chrome & the results are the same.
I after a very long debugging involving deleting Bin & obj folders and lots of rebuilds, i finally got this WCF service working again.
First, i suspected the service could be corrupted somehow, so i tried to update the service reference in my silverlight application but was bumped with the following error.
There was an error downloading 'http://localhost/mySite/Webservice/GetData.svc'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://localhost/mySite/Webservice/GetData.svc'.
The remote server returned an unexpected response: (405) Method Not Allowed.
The remote server returned an error: (405) Method Not Allowed.
I then browsed to the physical folder path to confirm if really my .svc file was there and indeed as expected, the file was there.
Trying to Browse to the path http://localhost/mySite/Webservice/GetData.svc in my browser bumped me with another error below.
HTTP Error 404.7 - Not Found The request filtering module is
configured to deny the file extension.
Most likely causes: Request filtering is configured for the Web server
and the file extension for this request is explicitly denied.
This made me start thinking that suddenly, IIS 7.0 has decided to block access to my .svc files.
I then added fileExtension=".svc" mimeType="application/octet-stream" to IIS, restart IIS but got the same error.
I then read on some blog i cant remember about adding <add fileExtension=".svc" allowed="true" /> under <requestFiltering> tag in file applicationHost.config located at C:\Windows\System32\inetsrv\Config, still nothing changed. Tried adding <mimeMap fileExtension=".svc" mimeType="application/octet-stream" /> under serverSideInclude in the same file, again with no luck.
Tried this http://www.adamwlewis.com/articles/iis-7-not-serving-files-4047-error still with no luck.
The following 2 steps are i think what resolved the issue.
I added a mapping for the SVC extension to ASP.NET by running ServiceModelReg.exe -i from C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation
Browsed to my .svc file in the browser and this time it looked like i had made some progress but still, i had one more error to overcome . The is bellow.
Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
I resolved the above error by registering the correct version of ASP.NET using the ASP.NET IIS Registration Tool (aspnet_regiis.exe,) as described in the link below
https://msdn.microsoft.com/en-us/library/hh169179(v=nav.70).aspx
At this point my service was back to normal as it had always been. I still haven't figured out what messed up my development machine.

Web API 404 File or Directory not Found for "root" routes

I am developing a RESTful web api service. It's web api v.1, not v.2. Also I am developing on Visual Studio 2010 SP1. I have installed the MVC 4 for VS2010 SP1.
Please understand and keep in mind that Upgrading to newer versions of VS or Web Api 2 is not an option.
I have the following problem after a Windows Update ocurred.
When I try to use my RESTful api this way....
http://url.com/documents/ (get all the documents) I get the following error...
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Here is the stack trace.
[HttpException]: File does not exist. at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response) at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context, String overrideVirtualPath) at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) at system.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
If I specify the action name directly, it works. For example...
http://url.com/documents/get (gets all the documents) or
http://url.com/documents/7 (gets document id=7.
It only fails when you call it by its default name. I have already read similar situations here and I have tried to follow their solutions but they are not working for me properly.
Now, I know this is not a "web api routing" issue because I actually get the .net default exception page html markup (I am using Postman to test my webservice). When I force a "routing issue", then I get a JSON error description, which means that the Controller actually got created in the pipeline and returned a response.
Also, I have a custom file (SecurityHandler) that inherits from DelegatingHandler. This file gets executed almost first in the pipeline with each call to the api. Even before the actual Controller. Well, this file is never called when I get the error, which confirms to me that the "webserver" (either VS Development Server or IIS 7) is the one throwing the exception.
I have exhausted every single solution that I have found here. Change my web.config to multiple handlers configurations, re-installed MVC 4 for VS2010, created an entire new project... all these efforts have shown no results whatsoever.
Like I said, this was working perfectly fine until my pc restarted from a Windows Update BUT... why does it fail in the server as well? I did deploy my api to the server after the error started to occur.
Thanks.
The issue is not in Web API (and has nothing to do with it's version or Visual Studio 2010), it's the static file handler trying to serve and failing.
Alternatives:
0. Do you have a documents folder in your site? Get rid of it.
1. Remove the static file handler for directory browsing and re-add it.
2. Use RAMMFAR (less recommended)

WebMatrix 2 site problems on upload to host

I have developed a Web Pages 2 website for my company using WebMatrix 2 that includes a simple SQL Compact Edition (.sdf file) database. Sounds simple. Runs perfectly on my local development box.
However, upon FTP to my Web host, it's a no-go. The first error I received was this:
Server Error in '/' Application.
Unable to find the requested .Net Framework Data Provider. It may not be installed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
Source Error:
Line 1: #{
Line 2: WebSecurity.InitializeDatabaseConnection("Omniflow", "UserProfile", "UserId", "Email", true);
Line 3: }
I have searched and searched and searched the Internet, trying to find out what the source of this problem is and how to fix it. I haven't found the answer yet. I gather than apparently some needed assemblies/dlls are not being uploaded with the application. I have tried both FTP and the Web Deploy method with no fix.
Is this the root of the problem? And why does WebMatrix not upload all its dependencies? If it cannot, why is there nothing in the online literature from Microsoft--and it should come from Microsoft--or anyone else describing this issue?
Are you using one of the hosting sites listed on the Microsoft WebMatrix page: http://www.microsoft.com/web/webmatrix/ ? I know that when I deployed my WebMatrix site to a generic IIS server, it took some extra DLL's in the bin directory, and a couple of settings to be fine tuned before it worked.
While publishing check whether your have selected Database file( .sdf file ) or not.If not then select it and publish.
Hope it will work for you.
Ensure that you have all the SqlCE DLLs required for accessing the SqlCE database.
They should be present in the bin\, bin\x86\ and bin\AMD64\ folders.
You can try creating a new site using Site from Template -> Empty Site (ASP.NET) and checking the bin folder to see which all dlls are present.
If you don't already have them in your site, add them. That should solve your problem.

Resources