HOW TO REDIRECTTOACTION WITH ANCHOR TAG IN MVC?

Takeshi Okada

Total Post:89

Points:629
Posted by  Takeshi Okada
 5050  View(s)
Ratings:
Rate this:
I have the following problem: For example I have route like this.

routes.Add(new Route("forums/thread/{threadOid}/last", new MvcRouteHandler())

           Defaults = new RouteValueDictionary(

             new { controller = "Thread", action ="ShowThreadLastPostPage"}),

        Constraints = new RouteValueDictionary(new { threadOid = @"^\d+$" })

    }

);

Is there a way using RedirectToAction method navigate to the URL like this.
forums/thread/{threadOid}/last#postOid

  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: How to RedirectToAction with anchor tag in mvc?

    I think you should use the Redirect method along with Url.RouteUrl to accomplish it.


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

      Modified On Oct-09-2014 12:12:17 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!