Solved

Page Routing or Redirection...

Posted on 2011-09-20
5
251 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
Comment Utility
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
Comment Utility
sorry.  this is non-mvc...
0
 
LVL 25

Accepted Solution

by:
kevp75 earned 0 total points
Comment Utility
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
Comment Utility
anyone got anything better?  otherwise I'm gonna roll with it...
0
 
LVL 25

Author Closing Comment

by:kevp75
Comment Utility
answered it myself
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now