使用#重定向到页面中的div [英] Redirect to div in page with #
问题描述
在控制器中处理了一些数据后,我想重定向到网页的某个div.他们有什么方法可以在网址末尾添加#"吗?还是应该使用javascript处理它?</p>
示例:
[HttpPost]
public async Task<IActionResult> Edit(ViewModel model){
....
return RedirectToAction("Info", new { id = model.Id, "#" = "item_55" });
}
=>应该重定向到/Info/id = 4#item_55
请注意,就像我上面所做的那样,您还需要将控制器指定为参数之一. I want to redirect to a certain div of a webpage after handling some data in a controller. Is their any way to add the '#' to the end of the url? Or should I handle it with javascript? Example: => Should redirect to /Info/id=4#item_55 Note that you also need to specify the controller as one of the arguments, as I've done above. 这篇关于使用#重定向到页面中的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!RedirectToAction
具有[HttpPost]
public async Task<IActionResult> Edit(ViewModel model){
....
return RedirectToAction("Info", new { id = model.Id, "#" = "item_55" });
}
RedirectToAction
has an overload that allows you to specify the fragment. Here's an example:return RedirectToAction("Info", "Controller", new { id = model.Id }, "item_55");