2

I have Created New MVC2 ViwUserControl and I have added new css file to ~/Content/Styles folder in my solution explorer. but my user control is not retrieving CSS files

 <link href="~/Content/Styles/demo_page.css" rel="stylesheet" type="text/css" />
        <link href="~/Content/Styles/demo_table.css" rel="stylesheet" type="text/css" />
        <link href="~/Content/Styles/demo_validation.css" rel="stylesheet" type="text/css" />
        <link href="~/Content/Styles/jquery.alerts.css" rel="stylesheet" type="text/css" />
        <link href="~/Content/Styles/jquery-ui.css" rel="stylesheet" type="text/css" />
        <link href="~/Content/Styles/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" />

any ideas/help appreciated?

when i debug through the firbug i'm seeing 404 not found error for these files

2 Answers 2

1

The preceding tilde is throwing your code off ...

Change:

<link href="~/ ...

To:

<link href="/ ...

The tilde ~ is a server-side construct commonly used in ASP.Net WebForms with code like:

<img runat="server" src="~/Images/foo.png" />.

In MVC the standard is to use @Url.Content(" ... "); so:

<link href="@Url.Content("~/Content/Styles/demo_page.css")"
      rel="stylesheet" type="text/css" />
Sign up to request clarification or add additional context in comments.

Comments

0

You cannot use ~/ in html. the only works with server-side function that support that vritual path. Remove ~

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.