Solved

Page Routing or Redirection...

Posted on 2011-09-20
5
256 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

738 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