If your tasked with doing a code review of a fellow developers code or indeed are looking to improve an … Continue reading What to look for when reviewing code for SOLID principle ‘violations’
CheckBoxFor values not binding when output using foreach loop
If your outputting a list of checkboxes using CheckBoxFor from within a loop and are having problems getting the checkboxes … Continue reading CheckBoxFor values not binding when output using foreach loop
Handling multiple submit buttons in ASP.NET MVC action methods
You can have multiple non nested forms all posting to different action methods from different submit buttons, you can also … Continue reading Handling multiple submit buttons in ASP.NET MVC action methods
Excluding $(this) from jQuery selector
If you want to attach a click (for example) event to a set of elements but then do something with … Continue reading Excluding $(this) from jQuery selector
Viewing raw HTTP post name/value pairs sent to MVC action method
When using ASP.NET MVC sometimes after a request viewModel properties you expect to be binded and populated are not. For … Continue reading Viewing raw HTTP post name/value pairs sent to MVC action method
Forms authentication failed for the request. Reason: The ticket supplied was invalid
If your using forms authentication in .net and the application that creates the authentication cookie is different than the one … Continue reading Forms authentication failed for the request. Reason: The ticket supplied was invalid
Viewing SQL generated by Entity Framework when querying or calling SaveChanges()
When using Entity Framework, in an effort to track down bugs or performance problems, it’s very handy to see what … Continue reading Viewing SQL generated by Entity Framework when querying or calling SaveChanges()
Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details
You may see this exception when doing a DbContext.SaveChanges() call. You then may go drilling into the exception details to … Continue reading Validation failed for one or more entities. See ‘EntityValidationErrors’ property for more details
Passing userId to SQL Server delete trigger from entity framework
If you’re in an enterprise environment some form of auditing is likely to be required so you can track who … Continue reading Passing userId to SQL Server delete trigger from entity framework
Adding data attributes to each option rendered by MVC DropDownListFor HTML Helper
Quite often you have a scenario whereby a parent dropdown causes another element to be updated based on what is … Continue reading Adding data attributes to each option rendered by MVC DropDownListFor HTML Helper
Posting disabled checkboxes from MVC Razor views
In ASP.Net MVC a common technique when dropdowns and textboxes are required to be disabled but their values still need … Continue reading Posting disabled checkboxes from MVC Razor views
MVC HTML helpers read from modelState before looking in the model
If you have posted back a form to an MVC action method and want to update some of the bound … Continue reading MVC HTML helpers read from modelState before looking in the model
MVC Dropdownlistfor defaulting to previously selected value when using a single SelectListItem List
Watch out for this one. If you have created a single list of SelectListItems and use this viewModel property to populate … Continue reading MVC Dropdownlistfor defaulting to previously selected value when using a single SelectListItem List
Prevent account enumeration on login, reset password and registration pages
Account enumeration is a potential security risk whereby a web site gives out information about what accounts are already in … Continue reading Prevent account enumeration on login, reset password and registration pages
Converting numbers to strings without scientific notation in C#
C# will automatically convert numbers which are of type float, double or decimal and have a lot of precision (lots … Continue reading Converting numbers to strings without scientific notation in C#
Automapper 4.2 IgnoreAllNonExisting – ignore missing properties
Given that Automapper 4.2 has marked the static API as obsolete we shouldn’t be using things like Mapper.GetAllTypes() etc. as … Continue reading Automapper 4.2 IgnoreAllNonExisting – ignore missing properties
Automapper 4.2 example
Automapper 4.2 has marked the static API as obsolete so things should be done slightly differently than before as the … Continue reading Automapper 4.2 example
Organise ASP.MVC projects by feature by changing view location in MVC
I think it would be a safe bet to say most people stick with the default ASP.Net MVC folder structure … Continue reading Organise ASP.MVC projects by feature by changing view location in MVC
Adding a TXT DNS record on Blacknight to verify a site on Google Search Console
When verifying any of my sites for Google webmaster tools/search console etc. I usually just use the upload a file … Continue reading Adding a TXT DNS record on Blacknight to verify a site on Google Search Console
two way automapper mapping with child properties mapped too
Quite often in our development projects which use automapper we will not only want to convert an object A to an … Continue reading two way automapper mapping with child properties mapped too
Software development improvements from a recent sprint retrospective I participated in.
In my current contract the use of agile processes is relatively new to the organisation as a whole and certainly … Continue reading Software development improvements from a recent sprint retrospective I participated in.
WordPress preview post not working… quick workaround
WordPress preview post links not working? Sick of unsuccessfully trying different things you’ve found on Google like I was? Pretty much … Continue reading WordPress preview post not working… quick workaround
Trimming strings globally with automapper
Recently working on an application based on a legacy database with a lot of char data types I was using … Continue reading Trimming strings globally with automapper
ASP.MVC 6 razor tag helpers for more designer friendly view markup
I’m really liking a lot of the ASP.NET 5 stuff which is coming down the line. Cross platform capabilities are … Continue reading ASP.MVC 6 razor tag helpers for more designer friendly view markup
Config files specified in SQL Agent being overridden by design time package configuration
In work, our DEV and our UAT DB environments reside on the same box, but with their own SQL instances. We prefer to … Continue reading Config files specified in SQL Agent being overridden by design time package configuration