路由不适用于在Mono上运行的ASP.NET MVC4 [英] Routing doesn't work for ASP.NET MVC4 running on Mono

查看:75
本文介绍了路由不适用于在Mono上运行的ASP.NET MVC4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mono 3.2.8上运行ASP.NET MVC4应用程序。当控制器动作返回字符串时,

例如:

公共字符串索引()

{

return MVC4页面......;

}



浏览器呈现OK,

但是当控制器动作时返回View(),例如:



public ActionResult Index()

{

return View() ;

}



错误信息如下:



系统.InvalidOperationException

未找到视图'Index'或其主节点或视图引擎不支持搜索的位置。搜索了以下位置:

~ / Views / Home / Index.aspx

~ / Views / Home / Index.ascx

~ /观看/分享/ Index.aspx

~ / Views / Shared / Index.ascx

~ / Views / Home / Index.cshtml

~ /Views/Home/Index.vbhtml

~ / Views / Shared / Index.cshtml

~ / Views / Shared / Index.vbhtml





但是,〜/ Views / Home / Index.cshtml确实存在。





如何解决问题?

Run an ASP.NET MVC4 application on Mono 3.2.8. When the controller action returns string,
for example:
public string Index()
{
return "MVC4 Page...";
}

the browser renders OK,
but when the controller action returns View(), for example:

public ActionResult Index()
{
return View();
}

The error messages are as follows:

System.InvalidOperationException
The view 'Index'or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml


However, ~/Views/Home/Index.cshtml does exist.


How do I solve the problem?

推荐答案

检查RouteConfig.cs文件并设置Controller和Action值。希望能帮助到你。 :)
Check You RouteConfig.cs File and set your Controller and Action values. Hope it helps. :)


这意味着找不到索引操作方法的视图。因此,您需要使用索引名称添加视图。
This means no view found for Index action method. So you need to add a view in with 'Index' name.


这篇关于路由不适用于在Mono上运行的ASP.NET MVC4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆