I read the article http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/view-without-controller-action-in-mvc/
I also want to implement same thing but not able to achieve it. I followed the same steps as in the link. My controller is
Code
public class PublicController : Controller { // GET: Public protected override void HandleUnknownAction(string actionName) { try { View(actionName).ExecuteResult(this.ControllerContext); } catch (Exception e) { Response.Write("PageNotFound"); } } } public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
name: "NoAction",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Public", action = "HandleUnknownAction", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
My master file from where i am calling my view without controller is asCode
ul> li>a href="@Url.RouteUrl("Public", new { name = "History.cshtml" })">History/a>/li>
Rahul ChavanRank #2,671 · 521 reputationPosted Apr 17, 2016, 2:28 AM EDT
Nasir Saeed23 reputationPosted Apr 17, 2016, 5:51 AM EDT
Nasir Saeed23 reputationPosted Apr 17, 2016, 5:51 AM EDT
Nasir Saeed23 reputationPosted Apr 17, 2016, 5:51 AM EDT
Nasir Saeed23 reputationPosted Apr 17, 2016, 5:51 AM EDT
Nasir Saeed23 reputationPosted Apr 17, 2016, 5:51 AM EDT
Nasir Saeed23 reputationPosted Apr 17, 2016, 5:51 AM EDT
Nasir Saeed23 reputationPosted Apr 17, 2016, 5:58 AM EDT