如何在ASP.NET中使用routecollection? [英] How to use routecollection in ASP.NET ?

查看:89
本文介绍了如何在ASP.NET中使用routecollection?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我想在我的asp.net网站上使用RouteCollection。



我尝试了什么:


Global.asax中的




  void  Application_Start( object  sender,EventArgs e)
{
RouteConfig.RegisterRoutes(RouteTable。路线);
}

public static void RegistRoute(RouteCollection routes)
{
routes.MapPageRoute( 主页 主页 〜/ ClientSide / Forms / Index.aspx);
}





但是当我想在href =Home中解决它时,我得到页面不存在的错误。



我该怎么办?

解决方案

你必须调用EnableFriendlyUrls来路由才能在WebForms中工作应用...

Hello
I want to use RouteCollection in my asp.net web site.

What I have tried:

in Global.asax :

void Application_Start(object sender, EventArgs e)
{
   RouteConfig.RegisterRoutes(RouteTable.Routes);
}

public static void RegistRoute(RouteCollection routes)
{
   routes.MapPageRoute("HomePage", "Home", "~/ClientSide/Forms/Index.aspx");
}



but when I want to address it in href="Home", I get Error the Page does not Exist.

What should I do ?

解决方案

You have to call EnableFriendlyUrls to routing to work in WebForms application...


这篇关于如何在ASP.NET中使用routecollection?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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