【发布时间】:2020-10-26 02:54:46
【问题描述】:
我有一个名为 Submit 的剃须刀页面,它给了我一个 Value cannot be null. Parameter name : viewData 错误,所以我删除了我的代码顶部的 @page,因为 this 帖子已定向。我现在的问题是,当我加载页面时出现以下错误:
InvalidOperationException:相对页面路径“索引”只能在执行 Razor 页面时使用。指定带有前导“/”的根相对路径以在 Razor 页面之外生成 URL。如果您使用的是 LinkGenerator,那么您必须提供当前的 HttpContext 才能使用相关页面。>
我希望我的页面的 URL 为 https://localhost:44369/Submit 我该怎么做?这是我在 Startup.cs 文件中的路由:
app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
});
【问题讨论】:
标签: asp.net-mvc asp.net-core routes asp.net-core-mvc asp.net-mvc-routing