asp.net mvc 5 - How can I add .htm at the end of URL in when using attribute routing in MVC 5 -
[route("{page?}/{category?}/{detail?}")] public actionresult index(string page, string category, string detail) { navigation _nav = nav.getitembyalias(module_code, page, "vn"); viewbag.template = _nav.template_code; viewbag.page = page; viewbag.category = category; viewbag.detail = detail; viewbag.lang = "vn"; if(_nav.template_code == "goldencity_news" && detail != null && detail != "") { viewbag.template = _nav.template_code + "_detail"; } return view(); }
normally.
local:port
local:port/home
local:port/page/category
local:port/page/category/detail
all above right
but, when change (add .htm @ route config)
[route("{page?}/{category?}/{detail?}.htm")] public actionresult index(string page, string category, string detail) { navigation _nav = nav.getitembyalias(module_code, page, "vn"); viewbag.template = _nav.template_code; viewbag.page = page; viewbag.category = category; viewbag.detail = detail; viewbag.lang = "vn"; if(_nav.template_code == "goldencity_news" && detail != null && detail != "") { viewbag.template = _nav.template_code + "_detail"; } return view(); }
only 1 case right:
local:port/page/category/detail.htm
.
this list below need:
local:port
local:port/page
local:port/page.htm
local:port/page/category
local:port/page/category.htm
local:port/page/category/detail
local:port/page/category/detail.htm
Comments
Post a Comment