ASP.NET 4.0路由和子文件夹

编程入门 行业动态 更新时间:2024-10-18 19:29:30
本文介绍了ASP.NET 4.0路由和子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这样的文件夹结构:

I have a folder structure like this:

www.mysite/About/About.aspx

我在用户控件中有这样的链接:

I have a link in a user control like this:

<a href="~/About/About" id="aboutLink" title="About" runat="server">About</a>

在我的RegisterRoutes()方法中,我有以下内容:

And in my RegisterRoutes() method, I have this:

routes.MapPageRoute("", "About/About/", "~/About/About.aspx");

它可以工作,但是会产生以下URL:

It works but produces the following URL:

www.mysite/About/About

什么我想这样:

www.mysite/About

开箱即用的4.0路由是否可能?

Is this possible with out-of-the-box 4.0 routing?

更新2 -2010年5月14日: 显然,我引入了一个额外的问题,将.aspx Web窗体命名为与包含文件夹相同。最后,这对我有用:

UPDATE 2 - 05-14-2010: Apparently, I introduced an extra issue by naming the .aspx Web Form the same as the containing folder. Finally, this is what worked for me:

RouteTable.Routes.MapPageRoute("", "About/", "~/AboutUs/About.aspx"); <asp:HyperLink ID="aboutLink" NavigateUrl="~/About" Text="About" runat="server"></asp:HyperLink>

Raj提供的链接帮助我找到了答案:-) msdn.microsoft/en-us/library/cc668201。 aspx

The links provided by Raj helped me find the answer :-) msdn.microsoft/en-us/library/cc668201.aspx

推荐答案

我不清楚您的问题。 试试这个

Your question is not clear to me. Try this

routes.MapPageRoute("", "About/", "~/About/About.aspx");

另外,考虑使用RouteURl表达式。

Also, consider using RouteURl expressions.

msdn.microsoft/en-us/library/dd329551 .aspx

msdn.microsoft/en-us/library/cc668176.aspx

更多推荐

ASP.NET 4.0路由和子文件夹

本文发布于:2023-10-31 13:18:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546197.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路由   文件夹   ASP   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!