Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67527

How to communicate with backend in an empty ASP.NET web application template?

$
0
0

I am used to working with PHP in the past as well as ASP.NET MVC. Now I am trying to learn to create an ASP.NET Framework web application, from scratch. I tried creating a project in accordance with the following steps:

Firstly I defined my project: Project template

I clicked "ASP.NET Web Application (.NET Framework)" and then clicked the "OK" button: ASP.NET 4.7.2 Templates

I clicked on "Empty" and made sure any references are ticked off and then I hit the "OK" button once more.

Now I have been provided with this simple as possible structure in my IDE: Simple file structure within solution explorer

I know from my experience with PHP I used to be able to call backend code from within my HTML file (which is then a PHP file when I started developing in PHP). I also know from my experience with ASP.NET MVC I used to be able to reach backend code through the usage of controllers and Razor Views.

How would I achieve the same with the given template (empty ASP.NET Framework)? I know I could add like an HTML file (with controls such as buttons) and perhaps make calls using JavaScript and JSON. Would that be the way to go and if so, how would I start developing in that way?

How could I call a simple class in my HTML file? Or should I use something else than a simple HTML for doing this?

My class:

public class Sample
{
    public static string Foo()
    {
        return "This is a foo string through C#";
    }
}

My HTML:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <!--Call the C# class foo() method-->
</body>
</html>

Folder structure:

New file folder structure


Viewing all articles
Browse latest Browse all 67527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>