asp.net mvc - Why is Hardcoding URL strings into an MVC app is a bad idea? (Or is it?) -



asp.net mvc - Why is Hardcoding URL strings into an MVC app is a bad idea? (Or is it?) -

in comment on question, phil mentions

hardcoding url strings mvc app bad idea. helpers there reason

is so? if so, why?

url generation result of route configuration in application's global.asax. when utilize helpers actionlink, inspect route configuration , generate routes accordingly.

if alter route configuration later, or install application virtual directory, urls generated helpers in whole application changed dynamically, don't have inspect , alter every hardcoded url string hand, , application less break.

if want markup anchors, can utilize urlhelper.action method. internally of helpers depend on url generation, utilize method.

<a href="@url.action("logon", "account")">logon<a>

asp.net-mvc model-view-controller

Comments

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -