I have these actions:
public class HomeController : Controller
{
public ActionResult Index ()
{
ViewData ["Message"] = "Welcome to ASP.NET MVC on Mono!";
return View ();
}
public ActionResult Pages (string test)
{
ViewBag.Message = test;
return View ();
}
}
The pages action is not working. I get an error 500:
System.TypeLoadException
Could not load type 'System.Web.UnvalidatedRequestValuesBase' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.Mvc.
Exception stack trace:
at System.Web.Mvc.FormValueProviderFactory.GetValueProvider (System.Web.Mvc.ControllerContext controllerContext) [0x00000] in <filename unknown>:0 at System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider (System.Web.Mvc.ControllerContext controllerContext) [0x00000] in <filename unknown>:0 at System.Web.Mvc.ControllerBase.get_ValueProvider () [0x00000] in <filename unknown>:0 at System.Web.Mvc.ControllerActionInvoker.GetParameterValue (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ParameterDescriptor parameterDescriptor) [0x00000] in <filename unknown>:0 at System.Web.Mvc.ControllerActionInvoker.GetParameterValues (System.Web.Mvc.ControllerContext controllerContext, System.Web.Mvc.ActionDescriptor actionDescriptor) [0x00000] in <filename unknown>:0 at System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass21.<BeginInvokeAction>b__19 (System.AsyncCallback asyncCallback, System.Object asyncState) [0x00000] in <filename unknown>:0
If I remove the parameter from that action is working fine.
Any ideas?
Thanks in advance!
p.s. I don't have any routes defined yet.
Using newest mono(3.6.1) doesn't resolve issue. What helps is: If you're using 5.X NuGet Microsoft ASP.NET MVC package, downgrade to MVC 4 is required.
Steps:
Errors that may occur:
System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc
in /Views/Web.Config infactoryType
attribute ofhost
node to 4.0.0.0. So line looks like this:<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
webpages:Version
to 2.0.0.0 in Root directory/Web.Config so it looks like this:<add key=”webpages:Version” value=”2.0.0.0” />
Then you can use parameters in controller actions.
I got the same error as OP in my
MVC
-project. (Currently usingXamarin
on aMac
) I'm using Microsoft Exchange WebServices, and I found out that downgrading this package solved my problem. I downgraded theMicrosoft.Exchange.Webservices
package from2.2
to1.2
.This is embarrassing, but here is my workaround until Mono updates System.Web: