asp.net mvc dropdownlist onchange routing
-
13-09-2019 - |
Question
I have a problem with transfer of my project to iis server. At the asp.net development server all routing went smoothly. Now i want to migrate to iis server and my onchange attribute on select tag doesnt work. When i try to get from https://www.web.com/Manager/Authorized/Accounts/0 using the
onchange="location.href='<%= Manager.MyConfiguration.Prefix %>/Authorized/Authorized/Accounts/'+this.value"
at the obvious page, i end up at https://www.web.com/Manager/Authorized/Accounts/0/Manager/Authorized/Authorized/Accounts/13424
The same problem was with every href attribute and the Html.Actionlink pretty much solved most of it, but i still dont know, how to route onchange or onclick.
<%= Manager.MyConfiguration.Prefix %> was my idea how to add the /Manager/ part of the route there (in order not to use it on the local devserver). Without this part, i get just https://www.web.com/Authorized/Accounts/13424 which is also wrong.
Solution
?:
<%= Url.Content("~/Authorized/Authorized/Accounts/") %>
OTHER TIPS
I'm not quite sure if I fully understand the problem, but it seems to be you could use the VirtualPathUtility class and do something like
'<%=VirtualPathUtiliy.ToAbsolute("~/Authorized/Authorized/Accounts/")%>'
+ this.value