【发布时间】:2011-11-26 13:37:46
【问题描述】:
我对设置 mvc 很陌生,请耐心等待.. 所以我有这两个模型
public class Promoter
{
public int Id {get; set;}
public string Name {get;set;}
public ICollection<Event> AllEvents {get;set;}
}
public class Event
{
public int Id {get;set;}
public string Name {get;set;}
public date Date {get;set;}
public int PromoterId {get; set;}
public virtual Promoter Promoter {get;set;}
}
我有一个控制器事件
public class EventsController : Controller
{
public ActionResult New()
{
return View()
}
[HttpPost]
public ActionResult New(Model model)
{
// do stuff to save the new Event related to Promotion
}
}
所以我的问题是,在 New Action 上,我如何确保 New View 能够拥有一个标识符相关?我正在考虑 hiddenfor 具有 PromotionId 以便在调用 Post 时该 ID 会在那里,但是当我调用 New 时我将不得不传递促销员 ID行动? 还是您认为我应该在访问该页面之前将促销员详细信息存储在 cookie 中? 需要注意的另一件事是,用户将通过身份验证并且需要登录才能访问 Promotion 控制器(此线程中未显示),然后在该控制器上用户可以转到说 Event Controller 会有新的 Action...
我希望这是有道理的。 需要一些建议,想法/想法非常感谢。
谢谢,
G
【问题讨论】:
标签: c# asp.net-mvc model-view-controller model