title: Rewrite URLS using global.asax
body: <p>I'm trying to make some friendlyurls in my vb.net (.net 4) project and I'm trying to do it using something I read about global.asax and Application_Beginrequest but I can't get it to compile.</p>
  
  <pre><code>Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
      Dim httpContext As System.Web.HttpContext = httpContext.Current
      Dim currentURL As String = currentURL.Request.Path.ToLower()
      If currentURL.IndexOf("widgets") &gt; 0 Then
          objHttpContext.RewritePath("products.aspx?ID=123")
      Else
          objHttpContext.RewritePath(httpContext)
      End If
  End Sub
  </code></pre>
  
  <p>Above is what i'm trying but it's erroring on the objHttpContext. is there another method? Ideally once I get the above method working I'm going to be attempting to use a database call to work out the URLs. So any suggestions in that direction will also be very welcome. I'm trying to get away from having to install anything on IIS as it's a load balenced enviroment that I'd rather not install something on every server.</p>
  
  <p>Thanks</p>
  
  <p>Tom</p>