Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

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

Автор: kudvenkat

Загружено: 2013-09-16

Просмотров: 43352

Описание:

Text version of the video
http://csharp-video-tutorials.blogspo...

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.
   / @aarvikitchen5572  

Slides
http://csharp-video-tutorials.blogspo...

All ASP .NET Text Articles
http://csharp-video-tutorials.blogspo...

All ASP .NET Slides
http://csharp-video-tutorials.blogspo...

ASP.NET Playlist
   • ASP.NET Tutorial for beginners in arabic  

All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenka...

All Dot Net and SQL Server Tutorials in Arabic
   / kudvenkatarabic  

In asp.net webforms, IsPostBack page property is used to check if the request is a GET or a POST request. If IsPostBack property returns true, then the request is POST, else the request is GET.

In asp.net mvc, use Request object's HttpMethod property to check if the request is a GET or a POST request. Let's discuss using Request.HttpMethod with an example.
1. Create a new asp.net mvc application and name MVCDemo.
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.

5. Copy and paste the following code in Index.cshtml view.
[h3 style="font-family:Arial"]
IsPosback = @ViewBag.IsPostback
[/h3]

@using (@Html.BeginForm())
{
[input type="submit" value="Submit" /]
}

Build the project and navigate to http://localhost/MVCDemo/Home/Index. Notice that when you first visit the Page, a GET request is issued and hence IsPostBack = False. Now click Submit button and notice that IsPostBack = True is displayed, as a POST request is issued upon clicking the Submit button.

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

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Part 145   Implementing autocomplete textbox in asp net web forms

Part 145 Implementing autocomplete textbox in asp net web forms

Http Get And Post In C#

Http Get And Post In C#

Часть 143. Разница между методами http get и http post

Часть 143. Разница между методами http get и http post

SHAZAM Top 50🏖️Лучшая Музыка 2025🏖️Зарубежные песни Хиты🏖️Популярные Песни Слушать Бесплатно #40

SHAZAM Top 50🏖️Лучшая Музыка 2025🏖️Зарубежные песни Хиты🏖️Популярные Песни Слушать Бесплатно #40

Hi-Fi - TOP 20 - Лучшие песни

Hi-Fi - TOP 20 - Лучшие песни

Илья Матвеев*: Персонально ваш / 20.01.26

Илья Матвеев*: Персонально ваш / 20.01.26

Музыка лечит сердце и сосуды🌸 Успокаивающая музыка восстанавливает нервную систему,расслабляющая

Музыка лечит сердце и сосуды🌸 Успокаивающая музыка восстанавливает нервную систему,расслабляющая

Как правильно заводить двигатель в мороз?

Как правильно заводить двигатель в мороз?

Python if __name__ == '__main__': наглядное объяснение

Python if __name__ == '__main__': наглядное объяснение

Гости из будущего - Лучшие песни - The Best @MELOMAN-MUSIC

Гости из будущего - Лучшие песни - The Best @MELOMAN-MUSIC

ХИТЫ 2026🔝Лучшая музыка 2026 🏖️ Зарубежные песни Хиты 🏖️ Популярные песни Слушать бесплатно 2026

ХИТЫ 2026🔝Лучшая музыка 2026 🏖️ Зарубежные песни Хиты 🏖️ Популярные песни Слушать бесплатно 2026

Я в опасности

Я в опасности

Превращение старого ноутбука в домашний сервер! (2026)

Превращение старого ноутбука в домашний сервер! (2026)

ASP NET Core Model Binding

ASP NET Core Model Binding

Python  - Полный Курс по Python [15 ЧАСОВ]

Python - Полный Курс по Python [15 ЧАСОВ]

Reloading or refreshing cache automatically, when cached data is removed   Part 130

Reloading or refreshing cache automatically, when cached data is removed Part 130

Методы GET и POST в Express JS | Обработка HTTP-запросов GET и POST с помощью Express JS | Simpli...

Методы GET и POST в Express JS | Обработка HTTP-запросов GET и POST с помощью Express JS | Simpli...

The Windows 11 Disaster Microsoft Didn’t See Coming

The Windows 11 Disaster Microsoft Didn’t See Coming

Caching in asp.net   Part 119

Caching in asp.net Part 119

🎙️ Честное слово с Фёдором Крашенинниковым

🎙️ Честное слово с Фёдором Крашенинниковым

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com