I am doing my final year project in Computer Science and the project is a system for managing a college, like openSIS, but using ASP.NET Core to build it.
I need help on how to Add, Update, and Remove data using regular HTML forms, such as via <form/>
and <input type="submit"/>
. I knew how to do this in WebForms, but not in ASP.NET Core.
ASP.NET Web Forms isn't supported in ASP.NET Core (nor are ASP.NET Web Pages). Typically, the functionality of these pages must be rewritten when porting to ASP.NET Core. There are, however, some strategies you can apply before or during such migration to help reduce the overall effort required.
Blazor has a lot in common with ASP.NET Web Forms. Both frameworks offer component-based, event-driven, stateful UI programming models. The main architectural difference is that ASP.NET Web Forms runs only on the server. Blazor can run on the client in the browser.
ASP.NET Web Forms is a web application framework and one of several programming models supported by the Microsoft ASP.NET technology. Web Forms applications can be written in any programming language which supports the Common Language Runtime, such as C# or Visual Basic.
What you're asking to do is possible "out of the box" with ASP.NET Core and does not require a third-party solution.
Microsoft - Introduction to Razor Pages
This is probably the most direct approach with the least to learn, and it is the modern equivalent to "Classic ASP.NET Web Forms." You are probably asking about this:
The basic idea is you create an "ASP.NET Core Web Application" project in Visual Studio and select the "Web Application" project template (confirming that ".NET Core" is selected in the template selection dialog before you click OK.)
You can then add "Razor Pages" containing HTML, CSS, and JavaScript, and use a simple post-back method via a regular HTML Form with a Submit Button. The link above has a topic on doing just that.
Microsoft - Overview of ASP.NET Core MVC
This is the second-most direct approach but does require you to grasp MVC concepts: Models, Views and Controllers. Implementing Razor Pages would only require you to grasp HTML and Razor Page code-behind, however, MVC as a pattern will provide your resulting project with a more maintainable and testable approach to the project.
The basic idea is to scaffold an "ASP.NET Core Web Application" project in Visual Studio, then select the "Web Application (Model-View-Controller)" project template.
Instead of adding Pages you add Views, to do anything useful these Views will have corresponding Controllers. There will also be Models defined, as you would see in a Razor Pages solution. In the case of MVC the Models are posted to your Controllers via Actions.
The link above covers the subject in detail, and there are numerous Stack Overflow posts on general MVC concepts.
Microsoft - Building Web APIs
This is probably the least direct and most-technical approach. You will want to be familiar with "JavaScript" and "XHRs", "JSON" (or XML, but JSON has become de facto), and you will want to be versed in what it means to be a "RESTful Web Service" ie. that HTTP supports basic verbs to POST, GET, and DELETE a resource.
The basic idea is you create an "ASP.NET Core Web Application" project in Visual Studio using the MVC scaffold. You then implement Controllers to behave as RESTful web services. You can add Razor Pages and/or MVC Views to deliver the HTML and JavaScript.
With this approach you can create "Single-Page Applications" that never need to reload, where the HTML and JavaScript for the entire application can be delivered up-front and then RESTful web services used to modify the UI at the client. This can get advanced, and most developers will want to look into using a client-side templating engine. The leanest and simplest to use is probably going to be KnockoutJS, but others are more popular (and more complex.) Knockout has the value of solving a very specific problem: data-binding an HTML UI to JavaScript objects.
Regardless of the approach you take, start here: Microsoft - Get Started with ASP.NET Core
If you like the Web Forms way of development, or if you have a large ASP.NET Web Forms application and you need to implement new pages in it, you can try DotVVM.
It is not "Web Forms on .NET Core", but:
Disclaimer: I am one of the authors of DotVVM. This post is not meant to advertise the project, I just believe it responds to the question because the main motivation to build DotVVM was the fact that Web Forms are not ported to ASP.NET Core, and many people is looking for the similar way of building web applications. DotVVM is not a port of Web Forms to .NET Core. Our intent is to build a framework which is conceptually similar, but which avoids the things Web Forms were criticized for (viewstate, testability and ugly HTML output).
If you are referring to WebForms from ASP.NET (before MVC webstack came), there is no WebForms for ASP.NET Core and unlikely to ever be ported.
There is however a similar project (usually referred as Razor Pages or View Pages, see RazorPages GitHub repository) which allows to create Razor views which are not backed by a controller.
But as far as I know it's not release ready (there is no nuget package for it on nuget.org) and you'd have to use some previous from nightly builds or stable myget repositories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With