Add TestWebApp

This commit is contained in:
2022-07-14 03:42:10 +02:00
parent bf629a5ebe
commit bf8112d4ab
15 changed files with 225 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
using System;
using VAR.WebFormsCore.Code;
using VAR.WebFormsCore.Controls;
using VAR.WebFormsCore.Pages;
namespace VAR.WebFormsCore.TestWebApp;
public class FrmDefault: PageCommon
{
private CTextBox _txtText = new CTextBox { ID = "txtText", CssClassExtra = "width150px", AllowEmpty = false };
private Button _btnTest = new Button { ID = "btnTest", };
private Label _lblMessage = new Label { ID = "lblMessage", };
public FrmDefault()
{
MustBeAuthenticated = false;
Init += FrmLogin_Init;
}
private void FrmLogin_Init(object sender, EventArgs e)
{
InitializeControls();
}
private void InitializeControls()
{
Title = MultiLang.GetLiteral("Default");
var lblTitle = new Label { Text = Title, Tag = "h2" };
Controls.Add(lblTitle);
Controls.Add(FormUtils.CreateField(MultiLang.GetLiteral("Text"), _txtText));
_txtText.PlaceHolder = MultiLang.GetLiteral("Text");
Controls.Add(FormUtils.CreateField(string.Empty, _btnTest));
_btnTest.Text = MultiLang.GetLiteral("Test");
_btnTest.Click += BtnTest_Click;
Controls.Add(FormUtils.CreateField(string.Empty, _lblMessage));
}
private void BtnTest_Click(object? sender, EventArgs e)
{
_lblMessage.Text = $"Hello World: {_txtText.Text}";
}
}

View File

@@ -0,0 +1,20 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace VAR.WebFormsCore.TestWebApp
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

View File

@@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:14577",
"sslPort": 44334
}
},
"profiles": {
"VAR.WebFormsCore.TestWebApp": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7260;http://localhost:5128",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.DependencyInjection;
using VAR.WebFormsCore.Code;
namespace VAR.WebFormsCore.TestWebApp
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
// If using Kestrel:
services.Configure<KestrelServerOptions>(options =>
{
options.AddServerHeader = false;
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseGlobalRouterMiddleware(env);
}
}
}

View File

@@ -0,0 +1,24 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
using VAR.WebFormsCore.Code;
namespace VAR.WebFormsCore.TestWebApp;
public class TestWebAppGlobalConfig: IGlobalConfig
{
public string Title { get; } = "TestWebApp";
public string TitleSeparator { get; } = " :: ";
public string Author { get; } = "XXX";
public string Copyright { get; } = "Copyright (c) 2022 by XXX, All Right Reserved";
public string DefaultHandler { get; } = nameof(FrmDefault);
public string LoginHandler { get; }
public List<string> AllowedExtensions { get; } = new List<string> { ".png", ".jpg", ".jpeg", ".gif", ".ico", ".wav", ".mp3", ".ogg", ".mp4", ".webm", ".webp", ".mkv", ".avi" };
public bool IsUserAuthenticated(HttpContext context)
{
return false;
}
public void UserUnauthenticate(HttpContext context)
{
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\VAR.WebFormsCore\VAR.WebFormsCore.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}