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

  • SEARCH
  • Home
  • 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 390025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:55:27+00:00 2026-05-12T15:55:27+00:00

I am continually testing the new feature of ASP.NET MVC 2 Preview 2 called:

  • 0

I am continually testing the new feature of ASP.NET MVC 2 Preview 2 called: “Areas within one project”.
Currently I have a problem with linking to css and js files from within aspx code.

When the url points to an url without the id, everything works fine:

http://mysite.com/area/controller/action

The problem appears when the url contains the parameter:

http://mysite.com/admin/controller/action/id

then the page cannot find css and js files from /content and /scripts.

I think the problem is related to routing. I have standard routing rules set, eg:

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        AreaRegistration.RegisterAllAreas();

        routes.MapRoute(
            "Default",                                              // Route name
            "{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );

and in the area’s route config:

        public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "admin_default",
            "Admin/{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = "" }
            );
    }

An example resource href in aspx file:

    <link href="../../Content/datatables.css" rel="stylesheet" type="text/css" />

Can anyone suggest a solution to resolve the problem of bad resource href?

  • 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-12T15:55:27+00:00Added an answer on May 12, 2026 at 3:55 pm

    When you are using URL routing, you don’t know how/many/path/parts there are going to be in your URL in advance. So you can’t use path-relative URLs at all: you don’t know how many ‘..’ segments you are going to need.

    Instead, use rooted URLs:

    <link href="/Content/datatables.css" rel="stylesheet" type="text/css" />
    

    If your application can be mounted on a non-root URL (eg. under one of your area​s, you must output that area name as part of the rooted URL. (Presumably this is obtained using AreaRegistrationContext.AreaName.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

One thing I have continually found very confusing about using an object database like
I currently have a Windows Service which continually runs throughout the day. It has
I currently I have an unbound service that is running continually grabbing my gps
I'm using TeamCity Professional for building and testing my code continually. I have some
I have a shopping cart that continually logs slow queries like this one... #
I have an InnoDB table that continually refreshes with a new set of data.
I have these two data structures that I continually find myself choosing between when
I have an English language forum site written in perl that is continually bombarded
I find myself continually sifting through the net to keep up with Python/Django/web development
I have a MySQL database that is continually growing. Every once in a while

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.