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 8506761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:40:51+00:00 2026-06-11T02:40:51+00:00

I am making an ASP.NET MVC site which needs to serve a number of

  • 0

I am making an ASP.NET MVC site which needs to serve a number of single page apps.

A single page app is static html, css and javascript files a folder with an index.html file and a number of folders for css, images and javascript.

I have no problem serving the single page apps from a virtual directory in an IIS server, but I would like to serve them only to authenticated users in the ASP.NET MVC solution, and therefore I am right now trying serve the index.html files from a controller method.

When I do this by loading and serving the index.html file, then I cannot figure out how to serve all the css and javascript files used by the index.html file because they are referenced by the index.html with relative paths like “css/style.css” and “js/somejavascript.js”.

I am using the relative parts to make it easy to develop and debug the single page apps independently from the ASP.NET MVC solution.

So my question is basically, how can I serve static HTML files with relative urls to css and js files to only authenticated users in an ASP.NET MVC site?

  • 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-06-11T02:40:53+00:00Added an answer on June 11, 2026 at 2:40 am

    If I’m understanding: you have some static HTML files that you can’t/don’t want to change, with relative URL link. In that case, just construct your MVC route so that the relative paths work. For example, let’s say the relative paths are like this:

    js/script.js
    css/style.css
    

    When you send that back to the browser, it’s going to resolve those paths relative to the current path. So if you’re serving the HTML file from the route (say):

    • http://domain.com/myapp/home

    Then the browser will send requests to:

    • http://domain.com/myapp/home/js/script.js
    • http://domain.com/myapp/home/css/style.css

    So adjust the route accordingly, and make sure any alternate routes redirect to the main one, eg /home/index should redirect to /home.

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

Sidebar

Related Questions

I am writing a single page ajax app with ASP.NET MVC - making heavy
If another website is making a POST to my ASP.NET MVC 2 site, how
I am making an application using ASP.NET MVC 3 which contains form wizard, i.e.
I'm working on an ASP.NET MVC site, using EF4 and Automapper. I'm making good
I've been playing around with ASP.NET MVC with a site containing a Master Page.
After creating a proof of concept for an ASP.NET MVC site and making sure
I am building a site using ASP.NET MVC 2. The site itself needs to
I have a site written in ASP.NET MVC. I have a page where the
This one should be pretty simple. I am making a non-MVC ASP.NET 2.0 site.
I'm making an Asp.Net MVC 3 project which should have about 10-15 views. How

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.