public ActionResult Detail(int id = 1) { if (!Permission.LoginedNeed(Request, Response, Session)) { return(null); } User user = (User)Session["user"]; log.Info("uid:" + user.uid + "访问消息id:" + id); Message message = MessageView.GetMessage(id); if (user.uid != message.sender && user.uid != message.receiver) { Response.Redirect("/Message"); } bool isReceiver = false; if (user.uid == message.receiver) { if (message.read == false) { MessageView.ReadMessage(id); } isReceiver = true; } ViewBag.message = message; ViewBag.isReceiver = isReceiver; return(View()); }