【发布时间】:2020-10-26 18:42:56
【问题描述】:
我在我的 RouteConfig.cs 中注册了这个 MapPageRoute
routes.MapPageRoute(
"ProfileRoute",
"Profile/{userid}",
"~/Profile.aspx"
);
这就是我使用 id 参数重定向到个人资料页面的方式(从登录到个人资料)
Response.Redirect(GetRouteUrl("ProfileRoute", new { userid = usersign.Text }));
但是,它显示错误“'/' 应用程序中的服务器错误。”和“找不到资源” 请求的 URL 看起来像“请求的 URL:/Profile/id”
我之前用过下面的Route方法
Response.Redirect(String.Format("Profile.aspx?id={0}", id));
但我想将其更改为更好、更稳定的路由方法,它在某种程度上类似于 MVC 路由。
我可以在我的代码中修复哪些错误?以及如何在 Web 表单中实现我的目标?
【问题讨论】:
标签: c# asp.net asp.net-mvc webforms routes