英文:
Razor page redirect to another folder page
问题
我遇到了与Razor页面导航相关的问题。我当前位于https://localhost:7154/Application/setupAccount页面,需要重定向到https://localhost:7154/Loan/setupLoan页面。
因此,我使用了RedirectToPage("setupLoan", new { id = 123 })。但问题是,它看起来像是Application文件夹中的setupLoan页面(URL - https://localhost:7154/Application/setupLoan),然后我收到一个页面未找到的错误。
我可以使用重定向功能,但问题是我无法发送动态查询参数。所以如果有人知道正确的路径来在Razor页面之间导航,请告诉我。
英文:
I'm facing an issue with razor page navigation. I'm in the https://localhost:7154/Application/setupAccount page and i have to redirect to https://localhost:7154/Loan/setupLoan page.
So I used RedirectToPage("setupLoan", new{id=123}. but the issue is that it's looking like a setupLoan page inside the Application folder. ( URL - https://localhost:7154/Application/setupLoan )
Then I'm getting an error like page not found
I can use redirect functionality. But the thing is, I can't send dynamic query parameters.
So let me know if anyone know a correct path to navigate razor page into another folder
答案1
得分: 1
尝试:
return RedirectToPage("setupLoan", new { area = "Application", id = 1 });
结果:
[![在此输入图像说明][1]][1]
[1]: https://i.stack.imgur.com/pD3dn.png
您可以阅读[使用Razor页面的区域](https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/areas?view=aspnetcore-7.0#areas-with-razor-pages)以了解更多信息。
**更新**
return RedirectToPage("setupLoan", new { area = "Loan", id = 1 });
**更新2**
Loan是一个页面文件夹,而不是一个区域文件夹,
尝试:
return RedirectToPage("/Loan/setupLoan", new { id = 1 });
英文:
Try:
return RedirectToPage("setupLoan", new { area = "Application",id=1 });
result:
You can read Areas with Razor Pages to know more.
Update
return RedirectToPage("setupLoan", new { area = "Loan",id=1 });
Update 2
Loan is a page folder. not area folder ,
try:
return RedirectToPage("/Loan/setupLoan", new { id = 1 });
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论