简体   繁体   中英

Redirect Web Page Requests to a Default Sub Folder

I am using UltiDev Web Server Pro and have all my aspx files are located in a sub folder 'WebForms'.

I want to be able to default all requests for pages to this folder such that they can just type: http://myserver/somepage.aspx instead of

http://myserver/WebForms/somepage.aspx .

Is this possible?

EDIT:

Here is the VB.NET version of the solution below including a check for case sensitivity:

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

You can use the Global.asax and the Application_BeginRequest to RewritePath to the final destination and still have the link without the WebForm path.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM