0
我在一個門戶網站使用jQuery的portlet /排序/可拖動,其中還包括一個內容管理系統,都在ASP.NET MVC 2.目前的工作只有管理員才能夠改變目前網站的佈局/內容。ASP.NET MVC門戶/ CMS - 控制器和窗口小部件的設計?
每個視圖基於控制器和動作得到用於頁面的個性化(從基部控制器)。然後視圖通過小部件進行循環,併爲它們中的每一個調用renderaction。
目前,我對每個視圖查看+「編輯」操作頁面設置進入編輯模式。由於我複製代碼,所以必須有更好的方法,但我無法看到它爲我的生活!
你會如何實施行動,使每一個視圖中進行編輯?
public ActionResult Legal()
{
PageModel model = GetPageSetting();
return View("Portal", model.PageSetting.Master.Path, model);
}
[HttpPost]
[Authorize(Roles = "Administrator")]
public ActionResult LegalEdit(EditorModel e)
{
PageModel model = GetPageSetting("Legal", "Home", true);
return View("Portal", model.PageSetting.Master.Path, model);
}
//這是基本控制器
protected PageModel GetPageSetting(string action, string controller, bool isEditing)
{
PersonalizationProcess personalizationProcess = new PersonalizationProcess();
string path = string.Format("~/{0}/{1}", controller, action);
string userName;
bool isAuthenticated;
if (User == null)
{
userName = "TestUser";
isAuthenticated = false;
}
else
{
userName = User.Identity.Name;
isAuthenticated = User.Identity.IsAuthenticated;
}
PageSetting setting = personalizationProcess.GetPageSetting(userName, isAuthenticated, path);
PageModel model = new PageModel();
model.Act = action;
model.Con = controller;
model.IsEditing = isEditing;
model.PageSetting = setting;
return model;
。該網站必須是搜索引擎優化爲好,所以我不能只呈現小部件,使AJAX試鏡。 – 2010-07-27 20:26:40