A old web application needs to be migrated from ASP.NET Web Forms to .NET 8 Razor Pages on a private server. This application can't be access by any public search engine like google.
Current Setup:
- Private server name: myServer
- Old web application name: AnnualReport
- Old application uses: ASP.NET Web Forms
- Location: windows > wwwroot$
- Access URL: myServer/AnnualReport/Index.aspx
Current Situation:
The application has been successfully migrated to Razor Pages and runs locally through Visual Studion at https://localhost:7002/
Issue:
I have moved application over to private server But the challenge is: .NET 8 Razor Pages URLs don't use .cshtml in the path. My understanding is that by convention, the Index.cshtml file in the Pages folder acts as the default page for your application. This means you can access it from private server using the following URL: myServer/AnnualReport/.
This URL results in errors:
myServer/AnnualReport/- Error: 404 - File or directory not found.myServer/AnnualReport/Index- 'Error: 403 - Forbidden: Access is denied.
I haven't encountered a Startup.cs file in the project. There's only a Program.cs file.
Is there any configuration needed in the absence of a Startup.cs file (assuming Program.cs handles initialization)?
Program.cs File:
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// 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.UseAuthorization();
app.MapRazorPages();
app.Run();