Created
September 7, 2023 15:09
-
-
Save bjoerntx/e93d409053f471f39ffab2f9360bd71b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var builder = WebApplication.CreateBuilder(args); | |
// Add services to the container. | |
builder.Services.AddControllersWithViews(); | |
builder.Services.AddCors(p => p.AddPolicy("corsapp", builder => | |
{ | |
builder.WithOrigins("*").AllowAnyMethod().AllowAnyHeader(); | |
})); | |
var app = builder.Build(); | |
// Configure the HTTP request pipeline. | |
if (!app.Environment.IsDevelopment()) { | |
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. | |
app.UseHsts(); | |
} | |
app.UseHttpsRedirection(); | |
app.UseStaticFiles(); | |
app.UseRouting(); | |
app.UseCors("corsapp"); | |
// enable Web Sockets | |
app.UseWebSockets(); | |
// adding the TX Text Control WebSocket middleware | |
app.UseTXWebSocketMiddleware(); | |
// adding the viewer endpoint routing | |
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapControllerRoute( | |
name: "default", | |
pattern: "{controller=TextControl}/{action}"); | |
}); | |
app.MapControllerRoute( | |
name: "default", | |
pattern: "{controller}/{action=Index}/{id?}"); | |
app.MapFallbackToFile("index.html"); ; | |
app.Run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment