我讨厌违反DRY规则。Asp.net的通用控制器Mvc
对于url:/ student/charles /Views/Student/Show.cshtml将使用学生模型进行呈现。
如何用asp.net mvc实现它?
(我可以从网址相关模型)
我想我已经解决了。我赶上这个代码的所有请求:
routes.MapRoute("CatchAll", "{*url}",
new { controller = "Base", action = "Dispatch" }
);
现在我想在调度程序中调用CustomView。
瞧:
public class BaseController : Controller
{
public ActionResult Dispatch(string url)
{
object model = null;
.....
return View("~/Views/Student/Show.cshtml", model);
}
}
看起来很脏,但工程:)我打开任何好转implemantation。
你不明白你在问什么。你能否多解释一下,发布相关的代码,给出任何适当的错误信息等? – mfanto