2009-03-02 27 views
77

Ho il seguente problema: Per esempio io ho percorso come questo:ASP.Net MVC RedirectToAction con ancora

routes.Add(new Route("forums/thread/{threadOid}/last", new MvcRouteHandler()) 
      Defaults = new RouteValueDictionary(
      new { controller = "Thread", action ="ShowThreadLastPostPage"}), 
     Constraints = new RouteValueDictionary(new { threadOid = @"^\d+$" }) 
    } 
); 

c'è un modo con il metodo RedirectToAction passare alla URL come questo:

forums/thread/{threadOid}/last#postOid

risposta

141

credo che si dovrebbe utilizzare il metodo Redirect insieme Url.RouteUrl per realizzarlo.

return Redirect(Url.RouteUrl(new { controller = "Thread", action = "ShowThreadLastPostPage", threadOid = threadId }) + "#" + postOid); 
+0

Grazie mille, aiuta! – inikulin

+3

Grazie mille per la risposta, mi sono chiesto questo per un po '! – thebrokencube

+0

Heh .. stava cercando di capirlo ... dimenticavo che il # thingy era un'ancora. Grazie per il post! –

14

un'altra alternativa con Url.Action:

return Redirect(Url.Action("ShowThreadLastPostPage", "Thread", new { threadOid = threadOid }) + "last#" + postOid); 
Problemi correlati