Skip to content

Can't access index page/static web assets for .NET 9 deployment to AL2023

0

I am deploying a .NET 9 application to Amazon Linux 2023 (single instance). It is an MVC application which imports a controller from a Web API project. Pretty simple stuff.

However, when I try to access the page, it returns a 404 error. I can find no further information on the issue. I can access the /api endpoints just fine, so I am pretty sure everything is working up to the actual application itself (no reverse proxy issues), but the index page is either encountering an error of some kind, or the routing is not working. I'm not sure how to proceed.

asked a year ago145 views

2 Answers
0
Accepted Answer

If you have two .NET applications in your bundle, EB will create a Procfile for you which runs the first application alphabetically (in this case, my API) even if that's not the application you are publishing. In order to fix this, you need to create your own Procfile that runs the correct .NET Core application.

answered a year ago

-1

Based on your description, you're experiencing a common issue where your .NET 9 MVC application is working for API endpoints but returning 404 errors for static content and the index page. Since your API endpoints are accessible, the core application is running correctly, which suggests this is likely a routing or static file serving issue.

Here are some potential causes and solutions:

  1. Static Website Hosting Configuration: Ensure that your application is properly configured to serve static files. In your .NET application, check that you have services like app.UseStaticFiles() in your Program.cs or Startup.cs file.

  2. URL Access Issues: Verify you're accessing the correct URL. Sometimes applications expect specific routes that don't match what you're trying to access.

  3. Routing Configuration: Check your MVC routing configuration. The default route might not be properly set up to handle the root path or specific paths you're trying to access.

  4. Content-Type Headers: Ensure that the content types for your static files are correctly set.

  5. File Permissions: If you're hosting on AL2023, check that the application has proper permissions to access and serve the static files.

  6. Application Preview Issues: If you're trying to access the application through a preview feature, ensure you're not using localhost or 127.0.0.1 in your URLs, as these would attempt to access resources on your local computer rather than on the server.

  7. Host Header Configuration: Some hosting setups require specific Host headers to properly route traffic. This is particularly important if you're using a reverse proxy or load balancer.

To troubleshoot further:

  • Check your application logs for specific error messages
  • Verify your routing configuration in your .NET application
  • Try accessing the application with explicit paths rather than relying on default routing
  • Use network tools like telnet to check connectivity to your application on the appropriate port
  • Review your web server configuration (if using IIS, Nginx, or Apache in front of your .NET app)
    Sources
    Rendering problem of the static website hosting | AWS re:Post
    Troubleshooting AWS Cloud9 - AWS Cloud9

answered a year ago

  • Useless. Can I get an answer from a human being?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.