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条回答
爷、活的狠高调
2楼-- · 2020-02-26 03:30

The page is not found cause the associated controller doesn't exit. Just create the specific Controller. If you try to show the home page, and use Visual Studio 2015, follow this steps:

  1. Right click on Controller folder, and then select Add > Controller;
  2. Select MVC 5 Controller - Empty;
  3. Click in Add;
  4. Put HomeController for the controller name;
  5. Build the project and after Run your project again

I hope this help

查看更多
神经病院院长
3楼-- · 2020-02-26 03:30

You should carefully review your Route Values.

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

In this case, ensure you have your Controller 'Home' as the application will fail to load if there is no HomeController with Index Action. In My case I had HomesController and I missed the 's' infront of the Home. I Fixed the Name mismatch and this resolved the issue on both my local environment and on my server.

查看更多
手持菜刀,她持情操
4楼-- · 2020-02-26 03:31

Open your Controller.cs file and near your public ActionResult Index(), in place of Index write the name of your page you want to run in the browser. For me it was public ActionResult Login().

查看更多
地球回转人心会变
5楼-- · 2020-02-26 03:31

you must check if you implemented the page in the controller for example:

   public ActionResult Register()
        {
            return View();
        } 
查看更多
乱世女痞
6楼-- · 2020-02-26 03:33

Remember to use PUBLIC for ActionResult:

public ActionResult Details(int id)
{
    return View();
}

instead of

 ActionResult Details(int id)
 {
     return View();
 }
查看更多
爷的心禁止访问
7楼-- · 2020-02-26 03:33

I had the same problem caused by my script below. The problem was caused by url variable. When I added http://|web server name|/|application name| in front of /Reports/ReportPage.aspx ... it started to work.

<script>
    $(document).ready(function () {
        DisplayReport();
    });

    function DisplayReport() {
        var url = '/Reports/ReportPage.aspx?ReportName=AssignmentReport';

        if (url === '')
            return;
        var myFrame = document.getElementById('frmReportViewer');
        if (myFrame !== null) {
            if (myFrame.contentWindow !== null && myFrame.contentWindow.location !== null) {
                myFrame.contentWindow.location = url;
            }
            else {
                myFrame.setAttribute('src', url);
            }
        }
    }
</script>

查看更多
登录 后发表回答