Categories
Programming

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 references […]

Categories
Programming

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 to […]

Categories
Programming

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. […]

Categories
Programming

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 a […]

Categories
Programming

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 something […]

Categories
Programming

ASP.NET MVC Widgets with RenderAction

This is a useful pattern that I have successfully employed a couple of times with ASP.NET MVC applications; creating Widgets with RenderAction. The prevalent way to create a page in ASP.NET MVC is to grab a bunch of stuff in the controller and pass it into a view to be rendered. As the application grows, […]

Categories
Programming

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 to […]

Categories
Programming

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 sizes […]

Categories
Visual Studio

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 broken […]

Categories
Programming

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 get […]