Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在地址栏中显示路由url,而不是主url_C#_Asp.net_Url Routing - Fatal编程技术网

C# 在地址栏中显示路由url,而不是主url

C# 在地址栏中显示路由url,而不是主url,c#,asp.net,url-routing,C#,Asp.net,Url Routing,在这里,我在Global.asax文件中创建了一个url路由: protected void Application_Start(object sender, EventArgs e) { RegisterRoutes(RouteTable.Routes); } static void RegisterRoutes(RouteCollection routes) { routes.MapPageRoute("Default", "My Home Page", "~/Defaul

在这里,我在
Global.asax
文件中创建了一个url路由:

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

static void RegisterRoutes(RouteCollection routes)
{
    routes.MapPageRoute("Default", "My Home Page", "~/Default.aspx");
}
现在我想展示
https://www.example.com/My 当客户键入
https://www.example.com
在浏览器的地址栏中点击回车键。
对于每一个
.aspx
网页,我都希望做类似的事情。
在地址栏中显示路由url而不是主url的最简单方法是什么?
请给我两种c#web.config方式。

编辑:
我是asp.net web表单,不是core或MVC

您需要的是重定向而不是路由!此外,您还可以使用Url路由模块。您需要的是重定向,而不是路由!此外,您还可以使用Url路由模块。