将网页请求重定向到默认子文件夹

时间:2012-07-09 10:42:44

标签: asp.net redirect webserver ultidev

我正在使用UltiDev Web Server Pro,并且我的所有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

1 个答案:

答案 0 :(得分:2)

您可以使用Global.asaxApplication_BeginRequestRewritePath到最终目的地,但仍然拥有不带 WebForm 路径的链接。

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