Using ispost in asp net core razor page to display text after form submission


ASP.NET is a popular language used for building web . One common requirement in web development is to text after a form submission. In ASP.NET Core Razor Pages, you can achieve this by using the IsPost property.


When a form is submitted in ASP.NET Core Razor Pages, the page is typically reloaded. However, you may want to display a message or perform some action only after the form is submitted. This is where the IsPost property comes in handy.

The IsPost property is a boolean property that indicates whether the current request is a POST request or not. By the value of this property, you can conditionally display text or perform certain actions only when the form is submitted.


Let's consider a simple example where we have a form with a text input and a . After the form is submitted, we want to display the entered text on the page.

@model IndexModel

@if (IsPost) {

The entered text is: @Request.Form["message"]


In the above example, we define a form with a text input and a submit button. The form has the method="post" attribute, indicating that it will be submitted using the POST method.

Inside the @if (IsPost) block, we check if the current request is a POST request. If it is, we display the entered text using the @Request.Form["message"] syntax. The Request.Form property allows us to access the form data submitted in the request.

By using the IsPost property, we can conditionally display the entered text only after the form is submitted.


The IsPost property in ASP.NET Core Razor Pages is a useful tool for text or performing actions only after a form submission. By checking the value of this property, you can easily control the of your web application on the request method.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents