DEV Community

Sardar Mudassar Ali Khan
Sardar Mudassar Ali Khan

Posted on

After URL Rewire from Aspx to Html page is Not Found in MVC

If you have performed a URL rewrite from an ASPX page to an HTML page in an MVC (Model-View-Controller) application, and you're encountering a "Page Not Found" error, there are a few potential issues you can investigate:

  1. Ensure the HTML page exists: Verify that the HTML page you are rewriting to actually exists in the specified location. Double-check the file name, extension, and its placement within your project's directory structure.

  2. Routing configuration: In MVC, routing determines how URLs are mapped to controller actions. Make sure you have set up the routing correctly to handle the rewritten URL. Check your route configuration file (usually RouteConfig.cs in the App_Start folder) and ensure that the appropriate route pattern is defined to match the rewritten URL and route it to the correct controller and action.

  3. Controller and action setup: Confirm that you have a corresponding controller and action method to handle the rewritten URL. In MVC, the controller is responsible for processing requests and returning the appropriate response. Ensure that the controller and action method are properly defined and that the action method returns the HTML page you intend to display.

  4. HTTP status codes: Check the HTTP status code returned when the "Page Not Found" error occurs. If it is a 404 status code, it suggests that the URL rewrite or routing configuration might not be correctly set up. If it is a different status code, it may indicate another issue that needs to be addressed.

  5. Web server configuration: Ensure that your web server is configured to handle the rewritten URLs properly. Depending on the server you are using (e.g., IIS, Apache), you may need to configure URL rewriting rules or modules to process the rewritten URLs correctly.

By investigating these areas, you should be able to identify the cause of the "Page Not Found" error after rewriting the URL from ASPX to HTML and take the necessary steps to resolve it.

Top comments (0)