i'm starting out .net, , building test application. have homepage set using defaultcontroller, , index() action method. works expected, , homepage simple www.domain.com.
i have created 2 new pages (terms , privacy) under same defaultcontroller, using terms() , privacy() action methods.
i want able browse these url www.domain.com/terms , www.domain.com/privacy.
when use <li>@html.actionlink("terms of service", "terms", "default")</li> works, takes me url @ www.domain.com/default/privacy.
should creating seperate controllers each of these pages, or using @html.actionlink helper incorrectly? have used <li><a href="~/privacy">privacy policy</a></li> understand isn't best practice?
also, there way force links lowercase?
my controller code:
public class defaultcontroller : controller { public actionresult index() { return view(); } public actionresult terms() { return view(); } public actionresult privacy() { return view(); } }
if these in homecontroller don't believe you'd have same problem. however, think can around using routeconfig file:
routes.maproute( name: "default", url: "{action}/{id}", defaults: new { controller = "default", action = "index", id = urlparameter.optional } ); routes.maproute( name: "generic", url: "{controller}/{action}/{id}", defaults: new { action = "index", id = urlparameter.optional } );
Comments
Post a Comment