In Microsoft ASP.net MVC, the routing mechanism used to parse incoming and outgoing URLs is designed with the idea of ββconvention in configuration. This means that if you follow the rules (rules) that the routing mechanism uses, you do not need to change the configuration.
The routing mechanism for ASP.net MVC does not serve web pages (.cshtml). It provides a way for a URL to process a class in your code that can display text / html in the output stream, or parse and serve .cshtml files in a consistent manner using the Convention.
The convention used for routing must correspond to a controller for a class with a name similar to ControllerNameController ie controller="MyAccount" means looking for a class named MyAccountController . Next comes the action that maps to a function in the controller class, which usually returns an ActionResult . those. action="LoginRegister" will look for the public ActionResult LoginRegister(){} function in the controller class. This function can return View() , which would be in accordance with the Convention with the name LoginRegister.cshtml and would be stored in the folder /Views/MyAccount/ .
To summarize, you will get the following code:
/Controllers/MyAccountController.cs:
public class MyAccountController : Controller { public ActionResult LoginRegister() { return View(); } }
/Views/MyAccount/LoginRegister.cshtml: your view file.
Claies Aug 16 '13 at 13:13 2013-08-16 13:13
source share