Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The resource cannot be found (Error in ASP.NET MVC 5)

I've manually added a view in the Home folder called "Test.cshtml".

When I opened that view in the browser it shows me the error: The resource cannot be found.

I tried the following solutions but still getting that error:

1- Right click on The Project Name > Properties > Specific Page > set it to: "Home/Test".

2- In RouteConfig class > RegisterRoutes method > Default MapRoute > set: controller = "Home", action = "Test".

like image 765
kareemborai Avatar asked Oct 04 '14 11:10

kareemborai


People also ask

How can we solve resources Cannot be found?

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.

Is a problem with the resource you are looking for and it Cannot be displayed?

There is a problem with the resource you are looking for, and it cannot be displayed. To resolve this issue, set the Enable 32-bit Applications to "False": Open the Internet Information Services (IIS) Manager. Select Application Pools.


1 Answers

You need to add an Action called Test in your Home controller.

public class HomeController : Controller
{
    public ActionResult Test()
    {
        return View();
    }
}

Visual Studio can help you generating the view for the action, right click on the Test method and Add View...

You can read more about Routing and Attribute Routing in this MSDN article.

Also a good read - How URLs Are Matched to Routes

like image 65
Ofiris Avatar answered Nov 14 '22 21:11

Ofiris