Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6909143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:39:08+00:00 2026-05-27T08:39:08+00:00

I have an ASP.NET 4 WebForms-based application, and I want to use routing to

  • 0

I have an ASP.NET 4 WebForms-based application, and I want to use routing to allow multi-tenancy, such that http://www.example.com/site/foo/Default.aspx is for the client named “foo” and http://www.example.com/site/bar/Default.aspx is for the client named bar.

I got as far as:

// Global.asax in Application_Start
routes.Add("ClientSelector", new System.Web.Routing.Route
(
   "site/{client}/{*path}",
   new Lcmp.Web.Configuration.ClientRoute()
));


public class ClientRoute : System.Web.Routing.IRouteHandler
{
    private string m_Path;
    private string m_Client;

    public ClientRoute() { }

    public bool IsReusable
    {
        get { return true; }
    }

    public IHttpHandler GetHttpHandler(System.Web.Routing.RequestContext requestContext)
    {
        this.m_Path = (string)requestContext.RouteData.Values["path"];
        this.m_Client = (string)requestContext.RouteData.Values["client"];

        string virtualPath = "~/" + this.m_Path;

        bool shouldValidate = false;

        if (shouldValidate && !UrlAuthorizationModule.CheckUrlAccessForPrincipal(
            virtualPath, requestContext.HttpContext.User,
                          requestContext.HttpContext.Request.HttpMethod))
        {
            requestContext.HttpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
            requestContext.HttpContext.Response.End();
            return null;
        }
        else
        {
            HttpContext.Current.RewritePath(virtualPath);
            HttpContext.Current.Items.Add("Client", this.m_Client);
            return (IHttpHandler)BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page));
        }
    }
}

and it seems to work for the initial .aspx page. But the routing is picking up .js and other non-compilable resources and throwing exceptions. What is the best way to avoid routing those?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:39:09+00:00Added an answer on May 27, 2026 at 8:39 am

    You can use the StopRoutingHandler() to ignore requests for certain files.

    routes.Add(new Route("*{js}", new {js=@".*\.js(/.*)?", new StopRoutingHandler()));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET 3.5 SP1 Webforms Application. I use the MVP pattern (supervising
I've got an old WebForms-based ASP.NET app that I have upgraded to ASP.NET 4.0
I have an ASP.NET webforms application with a Menu control. How does one hide
I have an existing asp.net webforms project that uses Microsoft's Enterprise DAAB for the
Retrofitting ASP.NET WebForms themes to an old application I have a need to theme
We have an ASP.NET 2.0 WebForms app that uses MS Ajax 1.0. It's working
I have a web site that runs both classic ASP and ASP.NET Webforms. The
I have an ASP.NET Webforms site that is regularly having features added. The majority
I have a reporting module in an ASP.NET webforms app (C#) that uses dynamic
In an ASP.NET WebForms application I would like to allow the end-user to browse

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.