我遇到了asp 4.0路由问题。没有MVC的ASP-Url路由问题
我有方法Global.cs
void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("cats","Categories/{ct}/{catname}","~/catwise.aspx");
}
和
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
,我的母版页
<a href="Categories/<%# Eval("Category_Id")%>/<%# Eval("Category_Name")%>">
这是在第一次路由,但现在后可以正常使用像Categories/1/Apple
上首先路由所有链接都是双向路由页面,如Categories/1/Apple/Categories/2/Banana
。
链接正在相互攀登,所以页面显示Resource not found
我试图设置Base
但它使情况变得更糟。 我不使用任何自定义处理程序
我应该如何解决这个问题?/为什么它不能正常工作?
使用/
的URL,然后像<a href="/Categories/<%# Eval("Category_Id")%>/<%# Eval("Category_Name")%>">
尝试,但它说resource not found
在routes.MapPageRoute("cats","/Categories/{ct}/{catname}","~/catwise.aspx");
所以添加/
但它扔编译时错误说法网址不能孔坦/
或~
或?
。
什么是主页URL时,要测试的网站?它是像'http:// localhost:1234'还是'http:// localhost:1234/mysite'。如果它的前者'/'应该可以工作 – lalibi
主页的url是'http:// localhost:14268/mysite' –
这就是'/'不起作用的原因。它提供了'http:// localhost:14268/Categories/1/Apple',而不是正确的'http:// localhost:14268/mysite/Categories/1/Apple'。有趣的是,在制作过程中会发挥作用......无论如何,在我的帖子下面看到我最后一次编辑,它应该做到这一点。 – lalibi