Solved

Page Routing or Redirection...

Posted on 2011-09-20
5
254 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

Independent Software Vendors: 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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 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