ASP.Net URL路由问题 [英] ASP.Net URL Routing Problem
问题描述
我在本地IIS上托管了一个Web应用程序,该应用程序具有3个不同的应用程序别名(使用相同的物理路径),例如我的应用程序名称为XYZ,并以xyz.com
,abc.com
和123.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/Route
或http://localhost/123.com/Route
.
我的要求是,每当用户浏览http://localhost [或计算机IP]/123.com/Route时,都应将其重定向到Route.aspx.
如果您打算浏览Route.aspx,则首先添加方法应该指向Route.aspx而不是RoutePage.aspx 我认为问题完全理解了您想要做的事情,主要是顶级域名或机器,还是依赖于从源头访问A1,我也想建立一个结构可能是AN''e A2等.
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屋!