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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:03:33+00:00 2026-05-23T14:03:33+00:00

I have an ASP.NET MVC Web application that needs to include several other html

  • 0

I have an ASP.NET MVC Web application that needs to include several other html files using the include directive, like so:

<!--#include virtual=/include/bottom.shtml -->

My problem is that I will need to deploy this application on servers where the application path will differ. For example, in one place I might have the application mapped on, say, localhost/myapp/ and in another I might have just localhost/.

In the localhost/ scenario, the code example I gave above works just fine. But when my app is on localhost/myapp, I get a parser error message which lets me know it could not find the file.

How can I customize the directive to take into account the relative path of the application (preferably without using find and replace every time) ?

Thank you!

  • 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-23T14:03:33+00:00Added an answer on May 23, 2026 at 2:03 pm

    Kill the leading slash — that is forcing the path to calculate from the root, not your page.

    But like @mare said, there is no reason to be using a #include in 2011. What you probably want to do is render it as a partial using Razor’s @Html.Partial().


    Given the updated constraints, there is still a much cleaner way to handle this in MVC than using the old #include. What you want to do is setup a controller action to read the file off disk and spit back the content. Then render that action like a normal MVC action.

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

Sidebar

Related Questions

I currently have a ASP.Net MVC web application that needs to upload large files
I have an Asp.Net MVC application that works in the vs.net development web server.
I have an asp.net mvc 2 web application that connects to a WCF web
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008
I have an asp.net Web Forms application that needs to send emails. I like
I am using ASP.Net mvc 3 C# to make a web application. I have
I have an ASP.NET MVC web application that makes REST style web service calls
I have a hybrid asp.net web forms / mvc application that I recently converted
I have a Asp.net MVC web application, containing mostly text. I want to put
Here's what I'm trying to do. I have an ASP.NET MVC web application, where

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.