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.
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") > 0 Then
objHttpContext.RewritePath("products.aspx?ID=123")
Else
objHttpContext.RewritePath(httpContext)
End If
End Sub
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.
Thanks
Tom
Why do you want use rewriting, when you can do it really easy using asp.net routing?
Please, look at the following link for more info:
http://msdn.microsoft.com/en-us/library/cc668201.aspx