asp.net-mvc - ASP.NET MVC 区域返回空白视图
问题描述
我有一个 ASP.NET MVC 应用程序,其中也有区域。
对于短 url,我在如下区域的 RouteConfig 中设置了所有带有短 url 的操作方法。
//admin dashboard having short url admin/dashboard
context.MapRoute(
"admin_dashboard",
"admin/dashboard",
new { area = "admin", controller = "admin", action = "dashboard" }
);
//student list having short url admin/studentlist
context.MapRoute(
"student_list",
"admin/studentlist",
new { area = "admin", controller = "students", action = "List" }
);
//new student having short url admin/student/new
context.MapRoute(
"student_new",
"admin/student/new",
new { area = "admin", controller = "students", action = "RegisterStudent" }
);
//edit student having short url admin/student/id
context.MapRoute(
"student_edit",
"admin/student/{id}",
new { area = "admin", controller = "students", action = "RegisterStudent" }
);
如您所见,我为所有操作方法定义了短 url,除了最后两个调用该方法但返回空白视图外,它也可以正常工作。
[Route("admin/student/{id}")]
[Route("admin/student/new")]
public ActionResult RegisterStudent(string Id)
{
....mycode
return View("RegisterStudent", mymodel);
}
问题是它调用该方法没有任何错误,但它没有返回视图。它返回空白视图。为什么会发生这种情况我做错了什么?
解决方案
如果您的请求将发送到您的操作方法,那么路由就没有问题。如果您的操作返回空白View
,那么它本身一定有问题View
。
推荐阅读
- node.js - npm:启动脚本失败
- python - 要通过 lambda 排序的列表
- angular - 反应形式的对象成员的角度验证器
- xaml - 如何在 Silverlight 中将“ListView”添加到 Visual Studio 工具箱?
- javascript - 处理相同代码必须立即运行或在承诺解决后运行的最佳方法
- json - 使用 JSONDecoder 解码 PascalCase JSON
- jquery - 水平居中背景图像以实现响应式布局
- python - 生成不在数组中的数字
- python - Google Analytics 发布请求未出现
- c++ - C++ 自定义向量类:指针行为