Xamarin ASP MVC 4参数不工作的行动 [英] Xamarin ASP mvc 4 action with parameters not working
本文介绍了Xamarin ASP MVC 4参数不工作的行动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这些动作:
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:
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.
任何想法?
在此先感谢!
P.S。我没有做任何路由没有定义。
p.s. I don't have any routes defined yet.
推荐答案
的使用最新的单声道(3.6.1)都不能解决问题。的
什么是帮助:
如果您正在使用5.X的NuGet微软ASP.NET MVC包,降级到MVC 4是必需的。
- 卸载以下的NuGet包(顺序很重要):
- Microsoft.AspNet.WebPages
- Microsoft.AspNet.Razor
- Microsoft.AspNet.Mvc
- 的视图索引或它的主人没有被发现。的
- 解决方案 - 变化的 /Views/Web.Config 在
System.Web.Mvc.MvcWebRazorHostFactory,System.Web.Mvc
的版本factoryType
主机
节点的属性为 4.0.0.0 。
所以行看起来是这样的:
Errors that may occur:
- The view 'Index' or its master was not found.
- Solution - change version of
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: - 的检测到ASP.NET网页的System.InvalidOperationException冲突版本:指定版本为3.0.0.0,但斌的版本为2.0.0.0。要继续,从应用程序的bin目录中删除文件或删除版本规范在web.config中。的
- 解决方案 - 改变
网页:版本
来2.0.0.0根目录/ 的Web.Config ,所以它看起来是这样的:&LT;添加键=网页:版本值=2.0.0.0/&GT;
- System.InvalidOperationException Conflicting versions of ASP.NET Web Pages detected: specified version is "3.0.0.0", but the version in bin is "2.0.0.0". To continue, remove files from the application’s bin directory or remove the version specification in web.config.
- Solution - change
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.
这篇关于Xamarin ASP MVC 4参数不工作的行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Solution - change
- 解决方案 - 改变
&LT;主机factoryType =System.Web.Mvc.MvcWebRazorHostFactory,System.Web.Mvc,版本= 4.0.0.0,文化=中性公钥= 31BF3856AD364E35/&GT;
- Solution - change version of
- 解决方案 - 变化的 /Views/Web.Config 在
查看全文