ASP.NET MVC Page Won't Load and says “The resource cannot be found”

前端 未结 21 1718
猫巷女王i
猫巷女王i 2020-12-09 14:51

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 \'/\' Applicati

相关标签:
21条回答
  • 2020-12-09 15:33

    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.

    0 讨论(0)
  • 2020-12-09 15:36

    Go to any page you want to see it in browser right click--> view in browser. this way working with me.

    0 讨论(0)
  • 2020-12-09 15:36

    For me its solved follow the following steps :

    One reason for this occur is if you don't have a start page or wrong start page set under your web project's properties. So do this:

    1- Right click on your MVC project

    2- Choose "Properties"

    3- Select the "Web" tab

    4- Select "Specific Page"

    Assuming you have a controller called HomeController and an action method called Index, enter "home/index" in to the text box corresponding to the "Specific Page" radio button.

    Now, if you launch your web application, it will take you to the view rendered by the HomeController's Index action method.

    0 讨论(0)
  • 2020-12-09 15:37

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

       public ActionResult Register()
            {
                return View();
            } 
    
    0 讨论(0)
  • 2020-12-09 15:37

    In my case, I needed to replace this:

    @Html.ActionLink("Return license", "Licenses_Revoke", "Licenses", new { id = userLicense.Id }, null)
    

    With this:

    <a href="#" onclick="returnLicense(event)">Return license</a>
    
    <script type="text/javascript">
        function returnLicense(e) {
            e.preventDefault();
    
            $.post('@Url.Action("Licenses_Revoke", "Licenses", new { id = Model.Customer.AspNetUser.UserLicenses.First().Id })', getAntiForgery())
                .done(function (res) {
                    window.location.reload();
                });
        }
    </script>
    

    Even if I don't understand why. Suggestions are welcome!

    0 讨论(0)
  • 2020-12-09 15:37

    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>

    0 讨论(0)
提交回复
热议问题