Part 144 How to check if the request method is a GET or a POST in MVC

preview_player
Показать описание
Text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

Slides

All ASP .NET Text Articles

All ASP .NET Slides

ASP.NET Playlist

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic

2. Add HomeController using "Empty MVC controller" scaffolding template
3. Copy and paste the following code
public class HomeController : Controller
{
// Action method that responds to the GET request
[HttpGet]
public ActionResult Index()
{
ViewBag.IsPostBack = IsPostBack();
return View();
}

// Action method that responds to the POST request
[HttpPost]
[ActionName("Index")]
public ActionResult Index_Post()
{
ViewBag.IsPostBack = IsPostBack();
return View();
}

// This method checks if a request is a GET or a POST request
private bool IsPostBack()
{
return Request.HttpMethod == "POST";
}
}

4. Right click on the Index() action method in HomeController and select "Add View" from the context menu. Set
View name = Index
View engine = Razor
Create a strongly typed view = unchecked
Create a partial view = unchecked
Use a layout or master page = unchecked
Click Add.

[h3 style="font-family:Arial"]
IsPosback = @ViewBag.IsPostback
[/h3]

{
[input type="submit" value="Submit" /]
}

Рекомендации по теме
Комментарии
Автор

Hi Baskar, sure will do it very soon. In the description of this video, I have included the link for ASP .NET, C#, and SQL Server playlists. All the videos are arranged in logical sequence in these playlists, which could be useful to you. Please share the link with your friends who you think would also benefit from them. If you like these videos, please click on the THUMBS UP button below the video. For email alerts, when new videos are uploaded, you may subscribe to my channel.

Csharp-video-tutorialsBlogspot
Автор

After watching a lot of video on youtube. I just find this helpfull. Great.

Uzair_Anwar
Автор

Hi Venkat,
What is the disadvantage of ASP.Net Web Forms. Why are we going for MVC Architecture. I went through lot of article, But i am not clear. I request you to upload a video on this.

BaskarMsholinghur
Автор

Excellent tutorial on this topic! basic stuff seldom overlooked. Keep up the great work. Subscribed : )

theITvideos
Автор

very simply explained sir...thnx a lot

saagarsoni
Автор

Good afternoon! a note: This video is saved in the playlist of asp.net. But it should be on the playlist of asp.net MVC. already thanks.

izaiaszanotti
Автор

Sir plz upload videos on AJAX.JQUERY, CSS plz ASAP....Thanku

umeshhande
Автор

sir could you provide videos on THREADS in C#

rajeshthangalapally
Автор

remote validation is covered in mvc tutorial.could u explain us how to do in asp.net pls

harikaaakutota