Razor页面重定向到另一个文件夹页面。

huangapple go评论64阅读模式
英文:

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:

Razor页面重定向到另一个文件夹页面。

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 });

huangapple
  • 本文由 发表于 2023年6月2日 12:49:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76387202.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定