Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Page Routing or Redirection...

Posted on 2011-09-20
5
Medium Priority
?
269 Views
Last Modified: 2012-05-12
I have a situation.

I find myself needing to redirect any request that contains the path '/Sites/' to '/Sites/' & VariableID

For example:
/Sites/Images/test_image.jpg

needs to become
/Sites/SITEID123456/Images/test_image.jpg

note, there are many folders inside /Sites/SITEID123456 that can contain anything from .exe to .jpg, to even fonts... so I need a wildcard solution

I thought I would be able to do this with .MapPageRoute, however, the more I read up on it, the more it seems I can only route to a page

How can I do this then?
(.Net 4, I am using VB, but I can translate a C# solution...)
0
Comment
Question by:kevp75
  • 4
5 Comments
 
LVL 14

Expert Comment

by:binaryevo
ID: 36569791
I think you can just setup a custom route in your global.asax file.  This link may help.

http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx
0
 
LVL 25

Author Comment

by:kevp75
ID: 36569837
sorry.  this is non-mvc...
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 0 total points
ID: 36570026
got it.

In global.asax:
 
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires at the beginning of each request
        Dim app As HttpApplication = TryCast(sender, HttpApplication)
        Dim _Path As String = app.Request.Path
        If _Path.ToLower.Contains("sites/") Then
            app.Context.RewritePath(_Path.Replace("Sites/", "Sites/" & Settings.SiteID & "/"))
        End If
    End Sub

Open in new window

0
 
LVL 25

Author Comment

by:kevp75
ID: 36570038
anyone got anything better?  otherwise I'm gonna roll with it...
0
 
LVL 25

Author Closing Comment

by:kevp75
ID: 36708105
answered it myself
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Loops Section Overview
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question