I've been exploring ASP.NET MVC 5 these days and got stuck into some basics. As an example, we create controller called 'HomeController' and in this regard, a view is created called 'Index' in the 'Home' folder. Now suppose we create another folder into the 'Home' folder named 'Data' and again it has a view called 'ViewData' . In the 'HomeController' , I've a method named 'ViewData' as follows (I want this method to be referred to the view 'ViewData'):
public ActionResult ViewData()
{
MainDbContext db = new MainDbContext();
var con = (from c in db.Lists
where c. Public == "No"
select c). ToList();
return View("Data/ViewData", con);
}
When I run the project, it works as desired I mean giving me the output and the URL looks like this: http://localhost:2361/Home/ViewNoData
But I want to show it like this: http://localhost:2361/Home/Data/ViewNoData as it is under 'Home' folder. One more thing - when I right click on the 'ViewData()' to match the view, it shows 'Unable to find the matching view'. How could I resolve it? Just to clarify if it is possible.
So below is the folder structure:
Views/Home/Data/ViewData.cshtml
And in the controller, the below:
Controllers/HomeController.cs
@Html.ActionLink("Click Here To Proceed", "Home/Data/ViewNoData")
– DOTNET Rocker May 29 '16 at 07:49