请教一个问题哈,我的url是类似于http://localhost/{username}/{controler}/{action},username是个参数,如何做到每次ActionLink("action","controller")自动等于http://localhost/{username(它等于=httpcontext.user.identify.name)}/controller/action呢?大虾请赐教!
可以这样试试
routes.MapRoute(
"Default",
"{username}/{controller}/{action}",
new {
controller = "Home",
action = "Index",
username= httpcontext.user.identify.name
}
);