ASP.Net URL路由问题 [英] ASP.Net URL Routing Problem

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

问题描述

我在本地IIS上托管了一个Web应用程序,该应用程序具有3个不同的应用程序别名(使用相同的物理路径),例如我的应用程序名称为XYZ,并以xyz.comabc.com123.com的形式托管在IIS上.
Global.asax中,我添加了这样的代码.

 RouteTable.Routes.Add(
      " 路由("  PageRouteHandler("  span>)));

 RouteTable.Routes.Add(
                " 路由(" 跨度>,
                 PageRouteHandler("  span>)));



用于URL路由.当应用程序在调试模式下运行时,它可以正常工作.它显示http://localhost:1234/Route之类的路径并显示RoutePage.aspx
但是在通过IIS浏览时,它不起作用,因为URL为http://localhost/abc.com/Routehttp://localhost/123.com/Route.

我的要求是,每当用户浏览http://localhost [或计算机IP]/123.com/Route时,都应将其重定向到Route.aspx.

解决方案

如果您打算浏览Route.aspx,则首先添加方法应该指向Route.aspx而不是RoutePage.aspx


I have a web application hosted on local IIS with 3 different application aliases (using same physical path) e.g. My application name is XYZ and hosted on IIS as xyz.com, abc.com and 123.com.

In Global.asax I have added code like this.

RouteTable.Routes.Add(
      "RouteName",
      new Route("Route",
      new PageRouteHandler("~/RoutePage.aspx")));

 RouteTable.Routes.Add(
                "DetailRoute",
                new Route("Route/{RouteID}",
                new PageRouteHandler("~/RouteDetailsPage.aspx")));



for URL routing. Its working fine while application runs in debug mode. It shows path like http://localhost:1234/Route and displays RoutePage.aspx
but while browsing through IIS it doesn''t work because the url will be http://localhost/abc.com/Route or http://localhost/123.com/Route.

My requirement is that whenever user browse http://localhost[or machine IP]/123.com/Route it should be redirected to Route.aspx.
How to solve this?

解决方案

If your intention is to browse Route.aspx, then first add method should be pointing to Route.aspx instead of RoutePage.aspx


I think the problem fully understand them you want to do the thing, a main top source Domain or machine, or dependent upon access to the A1 at its source, I also want to set up a structure that might as AN''e A2 and so on.


这篇关于ASP.Net URL路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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