Render HTML in a Validation Message in ASP.NET MVC

Often times you may want to render a custom validation message that contains HTML markup.  If you simply add the line:

This will encode the markup so that less than signs and greater than signs are rendered < and >, respectively.  This, of course, is not what you want.

To render your HTML markup, its a little dirty, but it does work.

Simply add the following to your view:

Where “Email” is a property of your model.


FileNotFoundException: Could not load file or assembly 'Microsoft.Web.Infrastructure'

When deploying an MVC application to a hosting environment you may receive the error:

[FileNotFoundException: Could not load file or assembly ‘Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.]

This is also one of a few component libraries that are needed for deploying an MVC application:

  • System.Web.Helpers.dll (required by the web.config)
  • System.Web.Mvc.dll
  • System.Web.Razor.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Razor.dll
  • Microsoft.Web.Infrastructure.dll

The system libraries are installed with .NET 4, however, ‘Microsoft.Web.Infrastructure.dll’ is only installed when Visual Studio is installed on the machine.  Therefore, short of needing to install MVC and Visual Studio on a production environment, we need to deploy the libraries with out application – and we’d like to do so automatically.

There are a few ways to automatically deploy the ‘Microsoft.Web.Infrastructure.dll’ component library with your application.  The steps depend on which version of Visual Studio you are using.

Read more


WMI Firewall Exception for Team Foundation Reporting Server 2012 in Virtual Environment

While installing TFS 2013 in a Windows Server 2012, I was having issues getting the TFS Application Tier to connect to WMI on the Reporting Server. Being that I’ve installed Team Foundation Server 2010 and 2012 countless times, I was sure that all of my settings were correct. Therefore, I predicted that this must be a firewall issue…and I was correct.

Read more


SharePoint 2013 + Visual Studio 2012 Debugging Extremely Slow

Prior to upgrading my machine to Windows 8, I was forced to use VMware Workstations 8 & 9 for development within a virtual environment.

My virtual environment within VMware Workstation 9 was:

  • Windows Server 2008R2
  • Visual Studio 2012
  • SharePoint 2013
  • SQL Standard 2012
  • 16 GB RAM
  • 4 Proc’s

When debugging SharePoint 2013 server-side code, all requests to SharePoint through the w3wp.exe process is extremely slow.  Furthermore, stepping through code becomes very sluggish. Additionally, while debugging 2013, the Virtual Studio Remote Debugging Monitor process eats up anywhere between 20-30% of the CPU resources.

Read more


Team Foundation Server 2012 Analysis Sync Jobs Will Not Automatically Re-queue

I have a TFS 2012 infrastructure designed according to Microsoft’s proposed multi-machine architecture. I am currently running Team Foundation Server 2012 with Update 1. A few weeks ago, I noticed my reports in SharePoint not being updated. Upon examining the web service admin interface (http://<your url>:8080/tfs/TeamFoundation/Administration/v3.0/WarehouseControlService.asmx), I was able to confirm that the jobs were not running.

tfs-process-import

You’ll notice in the attachment, my request to the process service is: 2013-02-16T23:29:54, however, the last time the Incremental ran was 2013-02-16T20:35:28.  Furthermore, there is no <NextRun /> element.  I’ve checked the settings, and its set to run every 7200 seconds (the 2-hour default).Read more


Adding E-mail Aliases in Office365

There are some instances where you wish to map alias email addresses to an account in Office365 (Office Online).

Read more


Issues with SharePoint Search

On one of my SharePoint installations, I was having a ton of issues with SharePoint Search.  I had created a SharePoint Search Application post-install with a different service account.  The search application starting adding an additional 10 MB to the individual log files.  I would reset the IIS application pool, but would see the search application continuing to run.

Read more


SharePoint People Picker Searching Accounts Across External Active Directory Trusts

In instances where your network administrator has created an external trust with another domain, you may want the SharePoint People Picker to find users in the external AD.

According to Microsoft’s TechNet, “The People Picker automatically issues queries to all two-way trusted domains when it uses the application pool account to search for users and groups. When you select a secondary account in the People Picker, the primary account information will be returned.”  Therefore, by default two-way trusts are automatically searched.

Read more


Counting the Factors of a Number

By definition, a factor is one of two or more positive numbers that when multiplied together produce a given product.  For example, given the integer 24, the count of factors 8.

The below algorithm tests the range of numbers from 1 to a given integer.  If the given interger divided by the current number returns a remainder of 0, then the current number is a factor of the given integer.

 

 

Get the source control, including unit tests: GetFactorsCount.zip (9.43 kb)


Getting All Factors for a Number

By definition, a factor is one of two or more positive numbers that when multiplied together produce a given product.  For example, given the integer 24, the factors are [1, 2, 3, 4, 6, 8, 12, 24].

The below algorithm tests the range of numbers from 1 to a given integer.  If the given integer divided by the current number returns a remainder of 0, then the current number is a factor of the given integer.

 

Get the source control, including unit tests: GetFactors.zip (9.85 kb)