Home > DeveloperSection > Forums > How to RedirectToAction with anchor tag in mvc?
Takeshi Okada
Takeshi Okada

Total Post:89

Points:629
Posted on    October-09-2014 12:10 AM

 ASP.NET MVC ASP.Net  ASP.NET MVC 
Ratings:


 1 Reply(s)
 3648  View(s)
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



Kamlakar Singh
Kamlakar Singh

Total Post:194

Points:1396
Posted on    October-09-2014 12:11 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick