How to add new aspx page in asp net 5 application

Introduction

ASP.NET is a popular programming language used for developing web applications. In this article, we will discuss how to add a new ASPX page in an ASP.NET 5 application.

Step 1: Create a New ASP.NET 5 Application

To begin, let's create a new ASP.NET 5 application. Open Visual and select “New Project” from the File menu. Choose the ASP.NET Web Application template and provide a name for your project. Click “OK” to create the project.


// ASP.NET 5 application code

Step 2: Add a New ASPX Page

Once the project is , right-click on the project in the Solution Explorer and select “Add” > “New Item”. In the Add New Item dialog, choose “Web Form” and provide a name for your ASPX page. Click “Add” to add the new page to your project.


// ASPX page code

Step 3: Configure Routing

By default, ASP.NET 5 uses the MVC for routing. To configure routing for the new ASPX page, open the .cs file in your project. In the Configure , add a new route for the ASPX page using the MapPageRoute method.


// Configure method in Startup.cs
 void Configure(IApplicationBuilder app,  env)
{
    //  configuration code
    
    app.UseRouting();
    
    app.( =>
    {
        endpoints.MapPageRoute("MyPage", "mypage", "~/MyPage.aspx");
    });
}

Step 4: Access the New ASPX Page

Now that the ASPX page is added and routing is configured, you can access the page by navigating to the specified route in your web browser. In this example, you can access the page by visiting “http://localhost:port/mypage”.


// Accessing the ASPX page

Conclusion

Adding a new ASPX page in an ASP.NET 5 application is a straightforward process. By following the steps outlined in this article, you can easily add and access a new ASPX page in your application.

Rate this post

Leave a Reply

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

Table of Contents