The type or namespace name ‘ApplicationInsights’ does not exist in the namespace ‘Microsoft’

If you uninstall the Application Insights package from a .NET Core MVC project, you might get a few errors as it can’t “remove all the references” that might have made it into your application. The changes to StartUp.cs will be pretty self-explantory, but elsewhere you will get something a bit more off-the-wall as it referencesContinue reading “The type or namespace name ‘ApplicationInsights’ does not exist in the namespace ‘Microsoft’”

IISExpress.exe Exited With Access Violation

I was happily typing away at some ASP.NET Core controllers and views, calling a view component to render out some paging links, when this happened… The program iisexpress.exe’ has exited with code -1073741819 (0xc0000005) ‘Access violation’. No exception visible in Visual Studio. No indication of where the error was. Nothing. The Internet supplied links toContinue reading “IISExpress.exe Exited With Access Violation”

Prevent AJAX Requests Making Sessions Infinite in ASP.NET MVC

If you are terminating inactive sessions in your ASP.NET MVC application and you add an AJAX polling call, the chances are you’ll make your sessions last forever thanks to the AJAX request bringing down an updated session cookie. This is because the AJAX call will pull down an updated auth cookie and extend your timeout.Continue reading “Prevent AJAX Requests Making Sessions Infinite in ASP.NET MVC”

Html.RenderAction Equivalent in .NET Core MVC

If you were a fan of ASP.NET MVC Widgets using Html.RenderAction, you might be a bit stunned that RenderAction is nowhere to be found in .NET Core. Don’t worry, though, because there is a Html.RenderAction equivalent in .NET Core MVC and it’s called View Components. View Component Class The view component class is quite aContinue reading “Html.RenderAction Equivalent in .NET Core MVC”

Minification Failed. Returning Unminified Contents.

Has you ASP.NET applicaiton reported that minification failed? If you are using bundles in application, you might come across this exception comment at the top of your larger-than-expected bundle file. /* Minification failed. Returning unminified contents. (List of problems here) */ It can happen for JavaScript or CSS, but it means minifier has found somethingContinue reading “Minification Failed. Returning Unminified Contents.”

Squash ASP.NET MVC ModelState Errors into a String or JSON

Once ASP.NET MVC has done all of the hard work of validating a model for you, you may find yourself wanting to squash the ModelState values into a string or JSON object. Because of the hierarchy, it might not be obvious at first glance how to do this, so your best bet would be toContinue reading “Squash ASP.NET MVC ModelState Errors into a String or JSON”

ASP.NET MVC Image Squishing with Picz

Responsive images have been around for a while and have wide browser support as well as a strong fallback story for older browsers. The one thing holding us back from using them is the manual workflow… Arrive at office Create images at different sizes Upload images Write an HTML tag listing all the image sizesContinue reading “ASP.NET MVC Image Squishing with Picz”

How To Fix Broken Intellisense in Visual Studio Razor Views

I had an annoying issue in Visual Studio 2015 whereby the views lost all intellisense. Errors such as “The name model does not exist” and lack of assitance with HTML Helper methods were accompanied by red squiggly lines. Most of the advice for fixing this is based on the assumption that the views are brokenContinue reading “How To Fix Broken Intellisense in Visual Studio Razor Views”

Handle Legacy .aspx Page Requests In ASP.NET MVC

If you have a public web application that you are upgrading from Web Forms to ASP.NET MVC, you may find yourself wanting to capture requests to the now obsolete .aspx addresses. By default, these requests won’t be passed to your application so you won’t be able to catch them using a route. So to getContinue reading “Handle Legacy .aspx Page Requests In ASP.NET MVC”