ASP.NET 4.0路由和子文件夹 [英] ASP.NET 4.0 Routing and Subfolders

查看:81
本文介绍了ASP.NET 4.0路由和子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的文件夹结构:

I have a folder structure like this:

www.mysite.com/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.com/About/About

什么我想这样:

www.mysite.com/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提供的链接帮助我找到了答案:-)

http://msdn.microsoft.com/en-us/library/cc668201。 aspx

The links provided by Raj helped me find the answer :-)
http://msdn.microsoft.com/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.

http://msdn.microsoft.com/en-us/library/dd329551 .aspx

http://msdn.microsoft.com/en-us/library/cc668176.aspx

这篇关于ASP.NET 4.0路由和子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆