DEV Community

Cover image for The largest .NET CMS is migrating to .NET Core
elanatframework
elanatframework

Posted on

The largest .NET CMS is migrating to .NET Core

Elanat announced in the news that the migration from ASP.NET Standard to ASP.NET Core is currently underway and in the near future Elanat will be provided using the ASP.NET Core infrastructure. As stated in the news, changing the codes on the server side is done in the best possible and simple way, and most of the codes can be changed by applying global Replase; the reason for the simplicity of the migration process is the independence feature of the server side, which was given special attention when creating Elanat on the .NET standard. Interestingly, it has been announced that the use of a powerful Code-Behind library makes Elanat more server-side independent in .NET Core than before; therefore, it greatly increases its independence from the server's infrastructure and programming language.

Elanat, the largest .NET CMS, gives developers a lot of power for web development. Elanat is so powerful that it is called Elanat framework. Supporting 8 types of add-ons: Component, Module, Plugin, Patch, Page, Fetch, Extra Helper, Editor, as well as Elanat's add-on-oriented nature, allows web developers to have the most freedom to create the most powerful websites or portals.

The powerful Code-Behind library allows Elanat to have more freedom in presenting new features compared to the default dot net core MVC structure, which includes cshtml pages, and avoids the unnecessary limitations of Microsoft's aspdotnet core that are used by similar dot net systems.

An example of .NET Standard code changes to .NET Core

View

aspx file in .NET Standard

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="elanat.MemberChangeEmail" %>
<div id="div_ChangeEmailPostBack">

    <div class="el_head">
        <%=model.MemberLanguage%>
    </div>

    <form id="frm_MemberChangeEmail" method="post" action="<%=elanat.AspxHtmlValue.SitePath()%>page/member/change_profile/change_email/Default.aspx">

        <div class="el_part_row">
            <div id="div_ChangeEmailTitle" class="el_title" onclick="el_HidePart(this); el_SetIframeAutoHeight()">
                <%=model.ChangeEmailLanguage%>
                <div class="el_dash"></div>
            </div>
            <div class="el_item">
                <%=model.UserEmailLanguage%>
            </div>
            <div class="el_item">
                <input id="txt_UserEmail" name="txt_UserEmail" type="text" value="<%=model.UserEmailValue%>" class="el_text_input el_left_to_right<%=model.UserEmailCssClass%>" <%=model.UserEmailAttribute%> />
            </div>
            <div class="el_item">
                <%=model.RepeatEmailLanguage%>
            </div>
            <div class="el_item">
                <input id="txt_RepeatEmail" name="txt_RepeatEmail" type="text" value="<%=model.RepeatEmaiValue%>" class="el_text_input el_left_to_right<%=model.RepeatEmailCssClass%>" <%=model.RepeatEmailtAttribute%> />
            </div>
            <div class="el_item">
                <input id="btn_ChangeEmail" name="btn_ChangeEmail" type="submit" class="el_button_input" value="<%=model.ChangeEmailLanguage%>" onclick="el_AjaxPostBack(this, false, 'frm_MemberChangeEmail')" />
            </div>
        </div>

    </form>
</div>
Enter fullscreen mode Exit fullscreen mode

aspx file in .NET Core

<%@ Page Controller="Elanat.MemberChangeEmailController" Model="Elanat.MemberChangeEmailModel" %>
<div id="div_ChangeEmailPostBack">

    <div class="el_head">
        <%=model.MemberLanguage%>
    </div>

    <form id="frm_MemberChangeEmail" method="post" action="<%=Elanat.AspxHtmlValue.SitePath()%>page/member/change_profile/change_email/Default.aspx">

        <div class="el_part_row">
            <div id="div_ChangeEmailTitle" class="el_title" onclick="el_HidePart(this); el_SetIframeAutoHeight()">
                <%=model.ChangeEmailLanguage%>
                <div class="el_dash"></div>
            </div>
            <div class="el_item">
                <%=model.UserEmailLanguage%>
            </div>
            <div class="el_item">
                <input id="txt_UserEmail" name="txt_UserEmail" type="text" value="<%=model.UserEmailValue%>" class="el_text_input el_left_to_right<%=model.UserEmailCssClass%>" <%=model.UserEmailAttribute%> />
            </div>
            <div class="el_item">
                <%=model.RepeatEmailLanguage%>
            </div>
            <div class="el_item">
                <input id="txt_RepeatEmail" name="txt_RepeatEmail" type="text" value="<%=model.RepeatEmaiValue%>" class="el_text_input el_left_to_right<%=model.RepeatEmailCssClass%>" <%=model.RepeatEmailtAttribute%> />
            </div>
            <div class="el_item">
                <input id="btn_ChangeEmail" name="btn_ChangeEmail" type="submit" class="el_button_input" value="<%=model.ChangeEmailLanguage%>" onclick="el_AjaxPostBack(this, false, 'frm_MemberChangeEmail')" />
            </div>
        </div>

    </form>
</div>
Enter fullscreen mode Exit fullscreen mode

As you can see, only the first line of the aspx page information has changed and the rest of the data has remained unchanged.

Controller section in .NET Standard

using System;

namespace elanat
{
    public partial class MemberChangeEmail : System.Web.UI.Page
    {
        public MemberChangeEmailModel model = new MemberChangeEmailModel();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.Form["btn_ChangeEmail"]))
                btn_ChangeEmail_Click(sender, e);


            model.SetValue();


            // Set Required Field Validation
            model.SetImportantField();
        }

        protected void btn_ChangeEmail_Click(object sender, EventArgs e)
        {
            model.IsFirstStart = false;

            model.UserEmailValue = Request.Form["txt_UserEmail"];
            model.RepeatEmaiValue = Request.Form["txt_RepeatEmail"];


            // Evaluate Field Check
            model.EvaluateField(Request.Form);
            if (model.FindEvaluateError)
            {
                ResponseForm rf = new ResponseForm(StaticObject.GetCurrentSiteGlobalLanguage());

                foreach (string EvaluateError in model.EvaluateErrorList)
                    rf.AddLocalMessage(EvaluateError, "problem");

                rf.RedirectToResponseFormPage();
            }


            if (Request.Form["txt_UserEmail"] != Request.Form["txt_RepeatEmail"])
            {
                model.EmailEqualityErrorView();
                return;
            }

            model.ChangeEmail();

            model.SuccessView();
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Controller

Controller section in .NET Core

using CodeBehind;

namespace Elanat
{
    public partial class MemberChangeEmailController : CodeBehindController
    {
        public MemberChangeEmailModel model = new MemberChangeEmailModel();

        public void PageLoad(HttpContext context)
        {
            if (!string.IsNullOrEmpty(context.Request.Form["btn_ChangeEmail"]))
                btn_ChangeEmail_Click(context);


            model.SetValue();


            // Set Required Field Validation
            model.SetImportantField();

            View(model);
        }

        protected void btn_ChangeEmail_Click(HttpContext context)
        {
            model.IsFirstStart = false;

            model.UserEmailValue = context.Request.Form["txt_UserEmail"];
            model.RepeatEmaiValue = context.Request.Form["txt_RepeatEmail"];


            // Evaluate Field Check
            model.EvaluateField(context.Request.Form);
            if (model.FindEvaluateError)
            {
                ResponseForm rf = new ResponseForm(StaticObject.GetCurrentSiteGlobalLanguage());

                foreach (string EvaluateError in model.EvaluateErrorList)
                    rf.AddLocalMessage(EvaluateError, "problem");

                rf.RedirectToResponseFormPage(context);
            }


            if (context.Request.Form["txt_UserEmail"] != context.Request.Form["txt_RepeatEmail"])
            {
                model.EmailEqualityErrorView();
                return;
            }

            model.ChangeEmail();

            model.SuccessView();
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

Controller section changes have also been done simply
The following are the controller changes:

Added CodeBehind namespace
System.Web.UI.Page has been removed and CodeBehindController has been added instead
The underline of the main method has been remove(Page_Load to PageLoad)
The main method has been changed from private to public
The following input arguments were omitted
object sender, EventArgs e
And the following new argument is added
HttpContext context

View(model) method; Added before the end of the main method

To access the current HttpContext, the HttpContext context argument has been added inside the btn_ChangeEmail_Click method.
Added context prefix to Request

Please note that the capitalization of the first letter of the project name and the addition of Controller to the name of the MemberChangeEmail class are for arranging the naming and are not required!

Model

CodeBehind namespace has been added in the model section class
The parent class name of CodeBehindModel is also added in front of the model class name
public partial class MemberChangeEmailModel : CodeBehindModel

Top comments (2)

Collapse
 
d_inventor profile image
Dennis

Hi there! I have a small question about this section of your article:

The powerful Code-Behind library allows Elanat to have more freedom in presenting new features compared to the default dot net core MVC structure, which includes cshtml pages, and avoids the unnecessary limitations of Microsoft's aspdotnet core that are used by similar dot net systems.

Can you explain what kind of unnecessary limitations you experience that code behind does not have? I personally have been using MVC approach with razor most of the time and I feel quite the opposite. Not to mention, razor pages seem quite similar in the sense that you have a razor page coupled with a C# file with a similar page load method. They just have somewhat different syntax. I'm curious about how aspx pages with code behind are better in your opinion.

Collapse
 
elanatframework profile image
elanatframework

Dear Dennis

We have answered you in this article:
dev.to/elanatframework/why-should-...