0

In VS 2012 my project is running fine. But when I hosted it local IIS it does not find the css and js file. In my project files are linked like

<link href="~/CSS/layout.css" rel="stylesheet" type="text/css" />
<link href="~/CSS/color.css" rel="stylesheet" type="text/css" />

and after hosting I get like

<link href="/ApplicationTemplate/CSS/color.css " rel="stylesheet" type="text/css" />
<link href="/ApplicationTemplate/CSS/bootstrap.css " rel="stylesheet" type="text/css"/>

I also tried to solve the problem to put css in @Url.Content() and scripts in @Scripts.Render(). But it did not work for me. Then somebody told me to change the published web config . But also did not work.

1 Answer 1

1

you should be using Url.Content() helper to avoid this type of issues. It generates url using the relative path and there will be no chance of issue like these.

<link href="@Url.Content("~/CSS/layout.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/CSS/color.css")" rel="stylesheet" type="text/css" />

Also make sure that CSS and Scripts folder is in root directory of project.

NOTE: Sometimes this also happens that in publish some css and js files are not published in the published folder so copy the css,scripts and js folder from your solution to published folder to make sure it.

Sign up to request clarification or add additional context in comments.

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.