Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have following two routes registered in my global.asax file

routes.MapRoute(
    "strict",
    "{controller}.mvc/{docid}/{action}/{id}",
    new { action = "Index", id = "", docid = "" },
    new { docid = @"d+"}
);
routes.MapRoute(
    "default",
    "{controller}.mvc/{action}/{id}",
    new { action = "Index", id = "" },
    new { docConstraint = new DocumentConstraint() }
);

and I have a static "dashboard" link in my tabstrip and some other links that are constructed from values in db here is the code

 <ul id="globalnav" class = "t-reset t-tabstrip-items">
     <li class="bar" id = "dashboard">
         <%=Html.ActionLink("dash.board", "Index", pck.Controller,  new{docid =string.Empty,id = pck.PkgID }, new { @class = "here" })%>
     </li>
     <%  
         foreach (var md in pck.sysModules)
         {
     %>
     <li class="<%=liClass%>">
         <%=Html.ActionLink(md.ModuleName, md.ActionName, pck.Controller, new { docid = md.DocumentID}, new { @class = cls })%>
     </li>
     <%
         }
     %>
 </ul>

Now my launching address is localhost/oa.mvc/index/11 clearly matching the 2nd route. But when I visit any page that has mapped to first route and then come back to dash.board link it shows me localhost/oa.mvc/7/index/11 where 7 is docid and picked from previous Url.

I understand that my action method is after docid and changing it would not clear the docid.

My question here is, can I remove docid in this scenario without changing the route?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
651 views
Welcome To Ask or Share your Answers For Others

1 Answer

I have the same "not clearing out" value problem...

I've stepped into source code and I don't understand the reason for being of segment commented as : // Add all current values that aren't in the URL at all

@ SystemWebRoutingParsedRoute.cs, public BoundUrl Bind(RouteValueDictionary currentValues, RouteValueDictionary values, RouteValueDictionary defaultValues, RouteValueDictionary constraints) method from line 91 to line 100

While the clearing process is correctly handled in method preceding steps, this code "reinjects" the undesired parameter into acceptedValues dictionary!?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...