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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:30:29+00:00 2026-05-12T22:30:29+00:00

I am working in an ASP.NET MasterPage and am having trouble with <link href="…"

  • 0

I am working in an ASP.NET MasterPage and am having trouble with <link href="..." />.

I am trying to substitute in a stylesheet with a specific name:

<link href="/Content/Styles/<%=Model.Style%>.css" rel="stylesheet" type="text/css" />

Unfortunately, this creates the HTML output:

<link href="/Content/Styles/&lt;%=Model.Style%>.css" rel="stylesheet" type="text/css" />

Which is clearly not what was intended.

If I put the same code in a View placeholder, it works perfectly. This is not a good solution though as I have many pages where I just want it to do the same thing.

It looks like it’s trying to automatically correct the URL – is there a way to switch this off?


Edit 1:

I have fixed this temporarily using:

<link href=<%=String.Format("\"/Content/Styles/{0}.css\"", Model.Style)%> rel="stylesheet" type="text/css" />
  • 1 1 Answer
  • 1 View
  • 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-12T22:30:29+00:00Added an answer on May 12, 2026 at 10:30 pm

    All the links in your question and in the solution posted thus far will fail if your site is deployed in a virtual folder. Instead, do:

    <link href="<%= Url.Content("~/Content/Styles/" + Model.Style + ".css") %>" rel="stylesheet" type="text/css" />
    

    This (1) fixes the problem in your question, and (2) allows your site to work in a virtual folder.

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

Sidebar

Related Questions

I am working with an ASP.NET MVC application. I have one master page having
I am working with ASP.net. I am trying to call a method that exists
I'm fairly new to ASP.NET MVC, and I'm having a little trouble with scripts...
I am working with master page in ASP.NET (3.5) MVC Framework (1.0). I am
When working on ASP.NET 1.1 projects I always used the Global.asax to catch all
After working with ASP.Net MVC, it has me thinking about Rails. I worked with
I've been working with ASP.NET MVC for the last few weeks, learning as I
I am working with ASP.NET doing some client side javascript. I have the following
I am working with asp.net website project that some of pages need authentication. I
I've been working with asp.net MVC and am still not very good at it.

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.