MVC, aynı görünümleri http get veya post için eşlemek için eylem özelliklerini kullanır:ASP.NET MVC'de görünümün GET veya POST için olup olmadığı nasıl belirlenir?
[HttpGet]
public ActionResult Index()
{
ViewBag.Message = "Message";
return View();
}
[HttpPost]
public ActionResult Index(decimal a, decimal b, string operation)
{
ViewBag.Message = "Calculation Result:";
ViewBag.Result = Calculation.Execute(a, b, operation);
return View();
}
MVC görünümünde, görünümün http veya http post için olup olmadığını nasıl belirleyebilirim?
Görünümleri IsPost
@{
var Message="";
if(IsPost)
{
Message ="This is from the postback";
}
else
{
Message="This is without postback";
}
}