반응형
ASP.Net MVC 앵커가 있는 작업으로 리디렉션
다음과 같은 문제가 있습니다.예를 들어 다음과 같은 경로가 있습니다.
routes.Add(new Route("forums/thread/{threadOid}/last", new MvcRouteHandler())
Defaults = new RouteValueDictionary(
new { controller = "Thread", action ="ShowThreadLastPostPage"}),
Constraints = new RouteValueDictionary(new { threadOid = @"^\d+$" })
}
);
RedirectToAction 메서드를 사용하여 다음과 같은 URL로 이동하는 방법이 있습니까?
forums/thread/{threadOid}/last#postOid
제 생각에 당신은 그것을 사용해야 할 것 같습니다.Redirect
와 함께 하는 방법Url.RouteUrl
그것을 성취하기 위해.
return Redirect(Url.RouteUrl(new { controller = "Thread", action = "ShowThreadLastPostPage", threadOid = threadId }) + "#" + postOid);
를 사용하는 또 다른 대안Url.Action
:
return Redirect(Url.Action("ShowThreadLastPostPage", "Thread", new { threadOid = threadOid }) + "last#" + postOid);
언급URL : https://stackoverflow.com/questions/602788/asp-net-mvc-redirecttoaction-with-anchor
반응형
'programing' 카테고리의 다른 글
스프링 부트:다른 jar 라이브러리에서 클래스를 자동으로 연결할 수 없음 (0) | 2023.07.10 |
---|---|
문서를 찾을 때 MongoDB가 객체 ID를 반환하지 않도록 방지하는 방법은 무엇입니까? (0) | 2023.07.10 |
치명적 오류: mysql.h: mariadb를 설치할 때 해당 파일 또는 디렉토리가 없습니다. (0) | 2023.07.05 |
Spring-data-mongodb는 하나의 Mongo 인스턴스에서 여러 데이터베이스에 연결합니다. (0) | 2023.07.05 |
SELECT 문에서 to_date 예외를 처리하여 해당 행을 무시하는 방법은 무엇입니까? (0) | 2023.07.05 |