1

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
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143

1 Answers1

2

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);  
}
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • 1
    Lovely solutions - In thought I would have to do this on the web server. I made a slight ammendment to check case sensitivity but otherwise great. – Matt Wilko Jul 09 '12 at 11:34