Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HomeController : Controller
- {
- public ActionResult Index()
- {
- return View();
- }
- public ActionResult About()
- {
- return View();
- }
- //... a public method for every view.. :(
- }
- HomeController.About()
- HomeController.Features()
- HomeController.Index()
- HomeController.Testimonials()
- HomeController.ContactUs()
- HomeController.About()
- HomeController.Features()
- HomeController.Index()
- HomeController.Testimonials()
- HomeController.ContactUs()
- public class HomeController{
- public ActionResult ShowBasicView(){
- //HTTP GET:
- //site.com/about
- //site.com/features
- //site.com/
- //site.com/testimonials
- //All URLs above map to this action
- return View();
- }
- [AcceptVerbs(HttpVerbs.Post)]
- public ActionResult ContactUs(FormCollection data){
- //HTTP POST:
- //site.com/contact-us
- //POST URL maps here.
- SmtpClient.Send(new MailMessage()) //etc...
- return View()
- }
- }
- public class HomeController{
- public ActionResult ShowBasicView(){
- //HTTP GET:
- //site.com/about
- //site.com/features
- //site.com/
- //site.com/testimonials
- //All URLs above map to this action
- return View();
- }
- [AcceptVerbs(HttpVerbs.Post)]
- public ActionResult ContactUs(FormCollection data){
- //HTTP POST:
- //site.com/contact-us
- //POST URL maps here.
- SmtpClient.Send(new MailMessage()) //etc...
- return View()
- }
- }
- routes.MapRoute(
- "ShowBasic",
- "{id}",
- new { controller = "Home", action = "ShowBasicView", id = "home" }
- );
- public class HomeController: Controller{
- public ActionResult ShowBasicView(string pageName){
- // Do something here to get the page data from the Model,
- // and pass it into the ViewData
- ViewData.Model = GetContent(pageName);
- // All URLs above map to this action
- return View();
- }
- }
- public class HomeController: Controller{
- public ActionResult ShowBasicView(string pageName){
- // All URLs above map to this action
- // Pass the page name to the view method to call that view.
- return View(pageName);
- }
- }
Add Comment
Please, Sign In to add comment