DEV Community

Cover image for Please Check Out the CodeBehind Framework
elanatframework
elanatframework

Posted on

Please Check Out the CodeBehind Framework

As you know, Elanat content management system is based on CodeBehind framework and created under .NET Core. We at Elanat team want to release the new version of Elanat CMS; Elanat CMS version 2.2 will release with the latest version of the CodeBehind framework.

The CodeBehind framework is a powerful alternative to Razor Pages and the default MVC in ASP.NET Core; CodeBehind works up to 40% faster than them and has unique features.

Currently version 2.4.3 is the latest version of the CodeBehind framework. .NET developers are requested to check the latest version of the CodeBehind framework and report any undiscovered issues to us at Elanat.

Only view example

View section: aspx page (razor syntax)

@page
@{
    Random rand = new Random();
}

<div>
    <h1>Random value: @rand.Next(1000000)</h1>
</div>
Enter fullscreen mode Exit fullscreen mode

View section: aspx page (standard syntax)

<%@ Page %>
<%
    Random rand = new Random();
%>

<div>
    <h1>Random value: <%=rand.Next(1000000)%></h1>
</div>
Enter fullscreen mode Exit fullscreen mode

MVC example

View File: Default.aspx (razor syntax)

@page
@controller YourProjectName.DefaultController
@model YourProjectName.DefaultModel
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>@model.PageTitle</title>
</head>
<body>
    @model.BodyValue
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

View File: Default.aspx (standard syntax)

<%@ Page Controller="YourProjectName.DefaultController" Model="YourProjectName.DefaultModel" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title><%=model.PageTitle%></title>
</head>
<body>
    <%=model.BodyValue%>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

Model File: Default.aspx.Model.cs

using CodeBehind;

namespace YourProjectName
{
    public partial class DefaultModel : CodeBehindModel
    {
        public string PageTitle { get; set; }
        public string BodyValue { get; set; }
    }
}
Enter fullscreen mode Exit fullscreen mode

Controler File: Default.aspx.Controller.cs

using CodeBehind;

namespace YourProjectName
{
    public partial class DefaultController : CodeBehindController
    {
        public DefaultModel model = new DefaultModel();
        public void PageLoad(HttpContext context)
        {
            model.PageTitle = "My Title";
            model.BodyValue = "HTML Body";
            View(model);
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

CodeBehind Configure in ASP.NET Core

Program File: Program.cs

var builder = WebApplication.CreateBuilder(args);

var app = builder.Build();

+ SetCodeBehind.CodeBehindCompiler.Initialization();

app.Run(async context =>
{
+    CodeBehind.CodeBehindExecute execute = new CodeBehind.CodeBehindExecute();
+    await context.Response.WriteAsync(execute.Run(context));
});

app.Run();
Enter fullscreen mode Exit fullscreen mode

Documents

Programming

API and applied methods

Information

Creating high-level systems

Ready project

Related links

CodeBehind on GitHub:
https://github.com/elanatframework/Code_behind

CodeBehind in NuGet:
https://www.nuget.org/packages/CodeBehind/

CodeBehind page:
https://elanat.net/page_content/code_behind

Top comments (0)