Konrad Viltersten
Konrad Viltersten

Reputation: 39068

Can't access (404) ASPX from a View directory while HTML and (normal) ASPX are accessible

I can access Ping.HTML and Ping.ASPX but when I try to access the view from my MVC (4.0) project (deployed to the same server, the bogus one, by F5), I get 404.

It's a vanilla project created from the template for MVC 4 with a very default view and controller (no model).

Hints on how to resolved it? I'm out of ideas...

EDIT

My RouteConfig.cs is like this

public class RouteConfig
{
  public static void RegisterRoutes(RouteCollection routes)
  {
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapRoute(
      name: "Default",
      url: "{controller}/{action}/{id}",
      defaults: new { 
        controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
  }
}

Controllers folder contains only one, single file called ÄDefault1Controller.cs*. It only does this:

public class Default1Controller : Controller
{
  public ActionResult Index()
  {
    return View();
  }

  public ActionResult Test()
  {
    return View();
  }
}

EDIT

The exact URLs typed in (besides the server name alone, of course) are:

> http://localhost:49642/Index  
> http://localhost:49642/Index.aspx  
> http://localhost:49642/Home/Index  
> http://localhost:49642/Home/Index.aspx  
> http://localhost:49642/Default/Index  
> http://localhost:49642/Default/Index.aspx

Upvotes: 0

Views: 1394

Answers (1)

Matt Griffiths
Matt Griffiths

Reputation: 1142

Based on the information you've given, it sounds like a routing problem. The URL you are requesting isn't firing a controller.

EDIT

MVC works by convention, so by naming your controller Default1Controller the matching URL would start with /Default1.

In the example you've given, you can only access the Test() method by navigating to http://localhost:49642/Default1/Test, which will return the view typically located at /Views/Default1/Test.aspx (or /Views/Default1/Test.cshtml for razor-based views).

Please check out the routing overview at ASP.NET for more information about how the route table maps to controllers and actions. I should point out that the link is for the older versions of MVC, but you should get the idea.

Let me know if I can help further.

Matt

Upvotes: 1

Related Questions