【发布时间】:2013-02-21 15:47:37
【问题描述】:
我正在尝试将消息传递给另一个视图(实际上是同一个控制器)我可以做得很好,但是对我来说有问题..
我是网络新手,看起来不太好..
这里是我的 c# 代码
if (createStatus == MembershipCreateStatus.Success)
{
string registrationMessage = "You have registered successfully";
return RedirectToAction("KurumsalGiris", new { message = registrationMessage });
}
[AllowAnonymous] //sonradan eklendi
public ActionResult KurumsalGiris(string message="")
{
if (User.Identity.IsAuthenticated)
return Content("Zaten giriş yapmışsınız");
ViewBag.RegistrationMessage = message;
return View();
}
这里是html端
@model E_Cv.Models.LogOnModel
@{
ViewBag.Title = "Kurumsal Giriş";
}
<h2>Kurumsal Giriş</h2>
<h2>@ViewBag.RegistrationMessage</h2>
<p>
Please enter your user name and password.
@Html.ActionLink("Yeni Kurum Kaydı", "KurumsalKayit")
if you don't have an account.
</p>
所以我不知道如何以不同的方式将值传递给另一个视图。我不想在地址栏上显示这种消息并且用户不得更改它。
其次我可以用“Get”方法吗?
【问题讨论】:
标签: asp.net-mvc view viewbag