Bug 23772 - Microsoft.AspNet.Mvc version not automatically updated in web.config after package update
Summary: Microsoft.AspNet.Mvc version not automatically updated in web.config after pa...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web ()
Version: 3.12.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
: 35542 ()
Depends on:
Reported: 2014-10-13 03:50 UTC by meng.wang
Modified: 2016-02-27 04:17 UTC (History)
7 users (show)

Is this bug a regression?: ---
Last known good build:

Solutions Tree (12.07 KB, image/png)
2015-03-02 00:12 UTC, doubledevwp
Error Received (313.49 KB, image/png)
2015-03-02 00:13 UTC, doubledevwp

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 23772 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description meng.wang 2014-10-13 03:50:34 UTC
Description of Problem:

Steps to reproduce the problem:
1. Create a new solution and the Studio hints 3 updates beside "Packages" in solution explorer
2. Right click on "Packages" and select "Update"
3. After update is finished, start debugging the solution and an application exception occurs with the following exception information:
    Could not locate Razor Host Factory type: System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=,
    Culture=neutral, PublicKeyToken=31BF3856AD364E35

Actual Results:
System.InvalidOperationException raised

Expected Results:
Website started with no problem

How often does this happen? 
Every time after updating the Microsoft.AspNet.Mvc package

Additional Information:
Root of problem discovered so far, MVC version in both web.config (the root one and the one under views/shared) is not automatically updated to the latest number. Once updated manually, the problem is eliminated.
Comment 1 Lluis Sanchez 2014-10-14 07:13:56 UTC
Matt, is this something the NuGet update should have fixed?
Comment 2 Matt Ward 2014-10-14 08:09:14 UTC
The MVC version is updated in the root Web.config but not the views/shared/Web.config. I see the binding redirect updated:

        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="" newVersion="" />

The only thing I needed to fix was the version in the views/shared/Web.config for the host factoryType:

		<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

On Windows you do not need to fix the above, but on the Mac with Mono you do. Ideally it would work on Mono the same way. I am guessing that the host factory type is being redirected on Windows to the correct assembly but this is not happening on Mono.

The NuGet package will not update the views/shared/Web.config file. NuGet only supports updating the Web.config file in the project's root directory.

I cannot reproduce the Web.config file in the project's root directory not being updated. The views/shared/Web.config file will not be updated by NuGet. So NuGet is working as expected on my machine for both Mac and Windows.

My test steps:

1) Create new ASP.NET MVC Razor Project.
2) Update all the NuGet packages.
3) Run the project.
4) See error "Could not locate Razor Host Factory type..."
5) Edit views/shared/Web.config file and update <host factoryType...> to the correct assembly version.
6) Run the project again and see the web page opened with the welcome message displayed.
Comment 3 doubledevwp 2015-03-02 00:11:24 UTC

I was wondering if this issue has ever been resolved?

I tried to add it in like Mr. Ward had mentioned, but it is not working for my project.

I started up a brand new project and was able to get it running.  I saw that there were some updates, so I updated them.  Two are still currently saying that they need updated and I am receiving the aforementioned issue.

I will attach a screen shot of the results after I updated.

Thank you,
Comment 4 doubledevwp 2015-03-02 00:12:38 UTC
Created attachment 10104 [details]
Solutions Tree
Comment 5 doubledevwp 2015-03-02 00:13:20 UTC
Created attachment 10105 [details]
Error Received
Comment 6 Matt Ward 2015-03-02 05:02:30 UTC
With Xamarin Studio 5.7 after updating all the NuGet packages in the ASP.NET Razor project the only change I made to get it to run on the Mac without the "Could not locate Razor Host Factory" error was to update the version in the views/shared/Web.config
for the host factoryType:

        <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory,
System.Web.Mvc, Version=, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" />
Comment 7 Lluis Sanchez 2015-03-16 08:32:54 UTC
Can this be closed?
Comment 8 Mikayla Hutchinson [MSFT] 2015-03-16 17:35:15 UTC
I don't think so, I suspect it's a bug that Mono is not respecting the binding redirects.
Comment 9 Matt Ward 2015-11-10 04:47:43 UTC
*** Bug 35542 has been marked as a duplicate of this bug. ***