[英]URL Routing doesn't work when I don't include a parameter
So am trying to do some Routing and I seem to have an issue when I don't include any parameters. 所以我正在尝试做一些路由,当我不包含任何参数时似乎出现了问题。 I am not sure if this is because I am linking from the master page or what.
我不确定这是因为我是从母版页链接还是其他链接。
Here is what is in my Global.asax App_Start Method 这是我的Global.asax App_Start方法中的内容
routes.MapPageRoute("Ninja", "SalesRep", "~/SalesRep/SalesRepHome.aspx");
My link from my master page is 我的主页链接是
<asp:HyperLink ID="hlFashion" runat="server" CssClass="navSubFont" Width="100%" NavigateUrl="~/SalesRep" Text="Test">
When I run it like this, it just gives the 403.14 directory not found error. 当我像这样运行它时,它只会显示403.14目录未找到错误。 However if I add a parameter on it seems to work fine
但是,如果我在上面添加一个参数,它似乎可以正常工作
<asp:HyperLink ID="hlFashion" runat="server" CssClass="navSubFont" Width="100%" NavigateUrl="~/SalesRep/TestParam" Text="Test">
Does anyone know why it wouldn't work without a parameter? 有谁知道为什么没有参数就无法使用?
所以问题是,目录与路由URL的名称相同,所以我将路由URL重命名为Rep,并且工作正常。
routes.MapPageRoute("Ninja", "Rep", "~/SalesRep/SalesRepHome.aspx");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.