2012-07-09 91 views
0

我正在使用UltiDev Web服务器专业版,并让我所有的aspx文件都位于子文件夹'WebForms'中。将网页请求重定向到默认子文件夹

我希望能够为页面的所有请求默认使用此文件夹,以便他们可以只类型: http://myserver/somepage.aspx代替

http://myserver/WebForms/somepage.aspx

这可能吗?

编辑:

这里是解决方案的VB.NET版本低于包括大小写检查:

If Not HttpContext.Current.Request.Path.ToUpper.Contains("/WEBFORMS/") Then 
    Context.RewritePath("/WebForms" + HttpContext.Current.Request.Path, False) 
End If 

回答

2

可以使用Global.asax,并最终目的地的Application_BeginRequestRewritePath和仍然有链接没有WebForm路径。

protected void Application_BeginRequest(Object sender, EventArgs e) 
{ 
    if(!HttpContext.Current.Request.Path.Contain("/WebForms/")) 
     RewritePath("/WebForms" + HttpContext.Current.Request.Path, false); 
} 
+0

可爱的解决方案 - 在思想中,我将不得不在网络服务器上这样做。我做了一个小小的修改来检查区分大小写,但其他很好。 – 2012-07-09 11:34:54