好的,请看下面这个例子:
public ActionResult ViewProfile()
{
//Load the profile for the currently logged in user
if (Membership.GetUser() != null)
{
//Do some stuff get some data.
return View(ReturnViewModel);
}
return RedirectToAction("MainLogon", "Logon");
}
Run Code Online (Sandbox Code Playgroud)
在重定向到登录页面时,有没有避免"魔术字符串"?
And*_*rew 11
在这种情况下,我不会接近MVC Futures.
我建议使用T4MVC
David Ebbo在这里谈到它:http: //blogs.msdn.com/davidebb/archive/2009/06/17/a-new-and-improved-asp-net-mvc-t4-template.aspx
此处的更新版本还包括对操作方法的重构支持:
意味着不是使用这样的文字:
<% Html.RenderPartial("DinnerForm"); %>
Run Code Online (Sandbox Code Playgroud)
您现在可以使用intellisense并强烈输入:
<% Html.RenderPartial(MVC.Dinners.Views.DinnerForm); %>
Run Code Online (Sandbox Code Playgroud)
斯科特·汉塞尔曼(Scott Hanselman)在此发表了一篇博客:
http://www.hanselman.com/blog/TheWeeklySourceCode43ASPNETMVCAndT4AndNerdDinner.aspx
| 归档时间: |
|
| 查看次数: |
1262 次 |
| 最近记录: |