ASP.NET MVC Page Won't Load and says “The reso

2020-02-26 02:50发布

I am having a problem where I try to open my ASP.NET MVC application but I get the ASP.NET error page which says this:

Server Error in '/' Application.

The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /EventScheduler/account.aspx/login

Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053**

I am using the URL trick from this blog post and that is why I have the .aspx in the URL:

http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/

It works on my other sandbox server (not a dev machine), and now I just deployed it to my production site as a new virtual directory, but for some reason it seems like it's actually looking for a .aspx file.

Any ideas? I think I must be forgetting a step.

20条回答
▲ chillily
2楼-- · 2020-02-26 03:34

Had the same issue, in my case the cause was that the web.config file was missing in the virtual dir folder.

查看更多
再贱就再见
3楼-- · 2020-02-26 03:35

I found the solution for this problem, you don't have to delete the global.asax, as it contains some valuable info for your proyect to run smoothly, instead have a look at your controller's name, in my case, my controller was named something as MyController.cs and in the global.asax it's trying to reference a Home Controller.

Look for this lines in the global asax

routes.MapRoute(
   "Default", // Route name
   "{controller}/{action}/{id}", // URL with parameters
   new { controller = "Home", action = "Index", id = UrlParameter.Optional } 

in my case i had to get like this to work

    new { controller = "My", action = "Index", id = UrlParameter.Optional }
查看更多
小情绪 Triste *
4楼-- · 2020-02-26 03:41

In your Project open Global.asax.cs then right click on Method RouteConfig.RegisterRoutes(RouteTable.Routes); then click Go To Definition then at defaults: new { controller = "Home", action = "Index", id =UrlParameter.Optional} then change then Names of "Home" to your own controller Name and Index to your own View Name if you have changed the Names other then "HomeController" and "Index" Hope your Problem will be Solved.

查看更多
劳资没心,怎么记你
5楼-- · 2020-02-26 03:43

I got the same error when building. The default is to use URLRoute settings for navigating. If you select the "Set as Startup Page" property by right clicking any cshtml page, that throws this error because there are always a routing to the current page under the Global.asax file.

Look at Project Properties for Startup Path and delete it.

查看更多
等我变得足够好
6楼-- · 2020-02-26 03:43

If you're running IIS 6 and above, make sure the application pool your MVC app. is using is set to Integrated Managed Pipeline Mode. I had mine set to Classic by mistake and the same error occurred.

查看更多
Lonely孤独者°
7楼-- · 2020-02-26 03:43

I got the same error while building a MVC application.
In my case it happened because I forgot to add the string "Controller" in my controller name.

Error With

public class ProductType : BaseController
{
    public ProductType()
    {
    }
}

Resolved

public class ProductTypeController : BaseController
{
    public ProductTypeController ()
    {
    }
}
查看更多
登录 后发表回答