我有这些动作:
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 ();
}
}页面操作不起作用。我得到一个错误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 如果我从该操作中删除参数,则该操作可以正常工作。
有什么想法吗?
提前感谢!
附注:我还没有定义任何路由。
发布于 2014-07-08 18:35:14
使用最新的mono(3.6.1)不能解决问题。有帮助的是:如果你使用的是5.X NuGet微软ASP.NET MVC软件包,则需要降级到MVC 4。
步骤:
:
可能发生的错误:
System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc节点的factoryType属性中的host中的版本更改为4.0.0.0。所以这行看起来像this:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
检测到ASP.NET网页的
webpages:Version更改为2.0.0.0,如下所示:
然后,您可以在控制器操作中使用参数。
发布于 2015-01-27 10:45:08
这很尴尬,但在Mono更新System.Web之前,这是我的变通方法:
public ActionResult Index() //string app_id, string session_id, int surah_id, int ayat_id)
{
string app_id = Request["app_id"];
string session_id = Request["session_id"];
int surah_id = Int32.Parse(Request["surah_id"]);
int ayat_id = Int32.Parse(Request["ayat_id"]);
// ...
}发布于 2015-03-10 23:46:12
在我的MVC-project中,我得到了与OP相同的错误。(目前在Mac上使用Xamarin )我正在使用Microsoft Exchange WebServices,我发现降级这个包解决了我的问题。我将Microsoft.Exchange.Webservices包从2.2降级为1.2。
https://stackoverflow.com/questions/21827225
复制相似问题