Broken CSS Link When Published in Visual Studio 2017












9















I have problem when publishing a Visual Studio 2017, C#, ASP.Net MVC 5 project. I do publish with following settings :



enter image description hereenter image description here



Problem with the CSS content link, for example bootstrap :



@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);


If the bootstrap.min.css located in localhost/bower_components/css/bootstraps/bootstrap.min.css, that css will displayed as localhost/fonts/glyphicons-halflings-regular.eot at client.



If I just copy paste all project without publish it to the server, the link will displayed correctly as localhost/bower_components/css/fonts/glyphicons-halflings-regular.eot



This is happens for all css including images and other file in css.










share|improve this question























  • Do the css files get copied to the bower_components folder in the publish output? And do the font files also get copied into the bower_components folder? In other words, is the direcorty listing in the publish output folder correct.

    – ArieKanarie
    Nov 23 '18 at 11:32













  • @ariekanarie Yes, all files copied succesfully when published.

    – Jun Rikson
    Nov 23 '18 at 11:36











  • I don't have solution, so just some things to check. There must be some difference in het file/folder-structure when you copy by hand en when you use the publish method. Does disabling pre-compile help?

    – ArieKanarie
    Nov 23 '18 at 11:49











  • Is this the same issue? stackoverflow.com/q/34517032/495455

    – Jeremy Thompson
    Nov 27 '18 at 2:59











  • @Jeremy because I put it inside www folder, so it will included when published. And no, this is not related to bower_components. It is happens also outside bower. Thanks for reply.

    – Jun Rikson
    Nov 27 '18 at 3:09
















9















I have problem when publishing a Visual Studio 2017, C#, ASP.Net MVC 5 project. I do publish with following settings :



enter image description hereenter image description here



Problem with the CSS content link, for example bootstrap :



@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);


If the bootstrap.min.css located in localhost/bower_components/css/bootstraps/bootstrap.min.css, that css will displayed as localhost/fonts/glyphicons-halflings-regular.eot at client.



If I just copy paste all project without publish it to the server, the link will displayed correctly as localhost/bower_components/css/fonts/glyphicons-halflings-regular.eot



This is happens for all css including images and other file in css.










share|improve this question























  • Do the css files get copied to the bower_components folder in the publish output? And do the font files also get copied into the bower_components folder? In other words, is the direcorty listing in the publish output folder correct.

    – ArieKanarie
    Nov 23 '18 at 11:32













  • @ariekanarie Yes, all files copied succesfully when published.

    – Jun Rikson
    Nov 23 '18 at 11:36











  • I don't have solution, so just some things to check. There must be some difference in het file/folder-structure when you copy by hand en when you use the publish method. Does disabling pre-compile help?

    – ArieKanarie
    Nov 23 '18 at 11:49











  • Is this the same issue? stackoverflow.com/q/34517032/495455

    – Jeremy Thompson
    Nov 27 '18 at 2:59











  • @Jeremy because I put it inside www folder, so it will included when published. And no, this is not related to bower_components. It is happens also outside bower. Thanks for reply.

    – Jun Rikson
    Nov 27 '18 at 3:09














9












9








9








I have problem when publishing a Visual Studio 2017, C#, ASP.Net MVC 5 project. I do publish with following settings :



enter image description hereenter image description here



Problem with the CSS content link, for example bootstrap :



@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);


If the bootstrap.min.css located in localhost/bower_components/css/bootstraps/bootstrap.min.css, that css will displayed as localhost/fonts/glyphicons-halflings-regular.eot at client.



If I just copy paste all project without publish it to the server, the link will displayed correctly as localhost/bower_components/css/fonts/glyphicons-halflings-regular.eot



This is happens for all css including images and other file in css.










share|improve this question














I have problem when publishing a Visual Studio 2017, C#, ASP.Net MVC 5 project. I do publish with following settings :



enter image description hereenter image description here



Problem with the CSS content link, for example bootstrap :



@font-face{font-family:'Glyphicons Halflings';src:url(../fonts/glyphicons-halflings-regular.eot);


If the bootstrap.min.css located in localhost/bower_components/css/bootstraps/bootstrap.min.css, that css will displayed as localhost/fonts/glyphicons-halflings-regular.eot at client.



If I just copy paste all project without publish it to the server, the link will displayed correctly as localhost/bower_components/css/fonts/glyphicons-halflings-regular.eot



This is happens for all css including images and other file in css.







c# asp.net-mvc-5 visual-studio-2017






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 '18 at 0:54









Jun RiksonJun Rikson

1,55811330




1,55811330













  • Do the css files get copied to the bower_components folder in the publish output? And do the font files also get copied into the bower_components folder? In other words, is the direcorty listing in the publish output folder correct.

    – ArieKanarie
    Nov 23 '18 at 11:32













  • @ariekanarie Yes, all files copied succesfully when published.

    – Jun Rikson
    Nov 23 '18 at 11:36











  • I don't have solution, so just some things to check. There must be some difference in het file/folder-structure when you copy by hand en when you use the publish method. Does disabling pre-compile help?

    – ArieKanarie
    Nov 23 '18 at 11:49











  • Is this the same issue? stackoverflow.com/q/34517032/495455

    – Jeremy Thompson
    Nov 27 '18 at 2:59











  • @Jeremy because I put it inside www folder, so it will included when published. And no, this is not related to bower_components. It is happens also outside bower. Thanks for reply.

    – Jun Rikson
    Nov 27 '18 at 3:09



















  • Do the css files get copied to the bower_components folder in the publish output? And do the font files also get copied into the bower_components folder? In other words, is the direcorty listing in the publish output folder correct.

    – ArieKanarie
    Nov 23 '18 at 11:32













  • @ariekanarie Yes, all files copied succesfully when published.

    – Jun Rikson
    Nov 23 '18 at 11:36











  • I don't have solution, so just some things to check. There must be some difference in het file/folder-structure when you copy by hand en when you use the publish method. Does disabling pre-compile help?

    – ArieKanarie
    Nov 23 '18 at 11:49











  • Is this the same issue? stackoverflow.com/q/34517032/495455

    – Jeremy Thompson
    Nov 27 '18 at 2:59











  • @Jeremy because I put it inside www folder, so it will included when published. And no, this is not related to bower_components. It is happens also outside bower. Thanks for reply.

    – Jun Rikson
    Nov 27 '18 at 3:09

















Do the css files get copied to the bower_components folder in the publish output? And do the font files also get copied into the bower_components folder? In other words, is the direcorty listing in the publish output folder correct.

– ArieKanarie
Nov 23 '18 at 11:32







Do the css files get copied to the bower_components folder in the publish output? And do the font files also get copied into the bower_components folder? In other words, is the direcorty listing in the publish output folder correct.

– ArieKanarie
Nov 23 '18 at 11:32















@ariekanarie Yes, all files copied succesfully when published.

– Jun Rikson
Nov 23 '18 at 11:36





@ariekanarie Yes, all files copied succesfully when published.

– Jun Rikson
Nov 23 '18 at 11:36













I don't have solution, so just some things to check. There must be some difference in het file/folder-structure when you copy by hand en when you use the publish method. Does disabling pre-compile help?

– ArieKanarie
Nov 23 '18 at 11:49





I don't have solution, so just some things to check. There must be some difference in het file/folder-structure when you copy by hand en when you use the publish method. Does disabling pre-compile help?

– ArieKanarie
Nov 23 '18 at 11:49













Is this the same issue? stackoverflow.com/q/34517032/495455

– Jeremy Thompson
Nov 27 '18 at 2:59





Is this the same issue? stackoverflow.com/q/34517032/495455

– Jeremy Thompson
Nov 27 '18 at 2:59













@Jeremy because I put it inside www folder, so it will included when published. And no, this is not related to bower_components. It is happens also outside bower. Thanks for reply.

– Jun Rikson
Nov 27 '18 at 3:09





@Jeremy because I put it inside www folder, so it will included when published. And no, this is not related to bower_components. It is happens also outside bower. Thanks for reply.

– Jun Rikson
Nov 27 '18 at 3:09












3 Answers
3






active

oldest

votes


















5





+50









With what is available of code knowledge in your question and what shown and explained. I can see in your code your relative path has the issue.



You are using ../ change it to ./ or ~/. That should fix the issue.



By using ../ you are stepping the css path over.






share|improve this answer
























  • ../ meaning parent directory and it will working great actually. Not meaning back to root. / is back to root directory. I think you read the question wrongly. Nothing wrong with the path since if I just copy all the code to the server, it will working great. Problem if I publish it. ../ act like / . Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:07



















0














In the {YourProjectName}App_StartBundleConfig.Cs



Add Instance of CssRewriteUrlTransform Class when adding Bootstrap Bundle Like This:



public static void RegisterBundles(BundleCollection bundles)
{
StyleBundle bootCss = new StyleBundle("~/styles/bootstrap");
bootCss.Include("~/Content/bootstrap/styles/bootstrap.css",
new CssRewriteUrlTransform());
bootCss.Include("~/Content/bootstrap/styles/bootstrap-theme.min.css", new CssRewriteUrlTransform());
bundles.Add(bootCss);
}





share|improve this answer
























  • Hi there this is doesnt work, actually all link is working great if I view the code in browser. It just act like / back to root directory which I want is back to parent directory. Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:09



















0














Build action set to None by Default so you need to change it to Content.



Right click in affected file > properties > set Build Action to Content



I hope this can help






share|improve this answer
























  • hi there, just like I said in comment, all files published correctly and Yes all files Build Action is Content, thats why all files copied correctly. Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:04











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244885%2fbroken-css-link-when-published-in-visual-studio-2017%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









5





+50









With what is available of code knowledge in your question and what shown and explained. I can see in your code your relative path has the issue.



You are using ../ change it to ./ or ~/. That should fix the issue.



By using ../ you are stepping the css path over.






share|improve this answer
























  • ../ meaning parent directory and it will working great actually. Not meaning back to root. / is back to root directory. I think you read the question wrongly. Nothing wrong with the path since if I just copy all the code to the server, it will working great. Problem if I publish it. ../ act like / . Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:07
















5





+50









With what is available of code knowledge in your question and what shown and explained. I can see in your code your relative path has the issue.



You are using ../ change it to ./ or ~/. That should fix the issue.



By using ../ you are stepping the css path over.






share|improve this answer
























  • ../ meaning parent directory and it will working great actually. Not meaning back to root. / is back to root directory. I think you read the question wrongly. Nothing wrong with the path since if I just copy all the code to the server, it will working great. Problem if I publish it. ../ act like / . Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:07














5





+50







5





+50



5




+50





With what is available of code knowledge in your question and what shown and explained. I can see in your code your relative path has the issue.



You are using ../ change it to ./ or ~/. That should fix the issue.



By using ../ you are stepping the css path over.






share|improve this answer













With what is available of code knowledge in your question and what shown and explained. I can see in your code your relative path has the issue.



You are using ../ change it to ./ or ~/. That should fix the issue.



By using ../ you are stepping the css path over.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 11:01









maytham-ɯɐɥʇʎɐɯmaytham-ɯɐɥʇʎɐɯ

10.7k74568




10.7k74568













  • ../ meaning parent directory and it will working great actually. Not meaning back to root. / is back to root directory. I think you read the question wrongly. Nothing wrong with the path since if I just copy all the code to the server, it will working great. Problem if I publish it. ../ act like / . Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:07



















  • ../ meaning parent directory and it will working great actually. Not meaning back to root. / is back to root directory. I think you read the question wrongly. Nothing wrong with the path since if I just copy all the code to the server, it will working great. Problem if I publish it. ../ act like / . Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:07

















../ meaning parent directory and it will working great actually. Not meaning back to root. / is back to root directory. I think you read the question wrongly. Nothing wrong with the path since if I just copy all the code to the server, it will working great. Problem if I publish it. ../ act like / . Thank you for your answer.

– Jun Rikson
Nov 29 '18 at 20:07





../ meaning parent directory and it will working great actually. Not meaning back to root. / is back to root directory. I think you read the question wrongly. Nothing wrong with the path since if I just copy all the code to the server, it will working great. Problem if I publish it. ../ act like / . Thank you for your answer.

– Jun Rikson
Nov 29 '18 at 20:07













0














In the {YourProjectName}App_StartBundleConfig.Cs



Add Instance of CssRewriteUrlTransform Class when adding Bootstrap Bundle Like This:



public static void RegisterBundles(BundleCollection bundles)
{
StyleBundle bootCss = new StyleBundle("~/styles/bootstrap");
bootCss.Include("~/Content/bootstrap/styles/bootstrap.css",
new CssRewriteUrlTransform());
bootCss.Include("~/Content/bootstrap/styles/bootstrap-theme.min.css", new CssRewriteUrlTransform());
bundles.Add(bootCss);
}





share|improve this answer
























  • Hi there this is doesnt work, actually all link is working great if I view the code in browser. It just act like / back to root directory which I want is back to parent directory. Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:09
















0














In the {YourProjectName}App_StartBundleConfig.Cs



Add Instance of CssRewriteUrlTransform Class when adding Bootstrap Bundle Like This:



public static void RegisterBundles(BundleCollection bundles)
{
StyleBundle bootCss = new StyleBundle("~/styles/bootstrap");
bootCss.Include("~/Content/bootstrap/styles/bootstrap.css",
new CssRewriteUrlTransform());
bootCss.Include("~/Content/bootstrap/styles/bootstrap-theme.min.css", new CssRewriteUrlTransform());
bundles.Add(bootCss);
}





share|improve this answer
























  • Hi there this is doesnt work, actually all link is working great if I view the code in browser. It just act like / back to root directory which I want is back to parent directory. Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:09














0












0








0







In the {YourProjectName}App_StartBundleConfig.Cs



Add Instance of CssRewriteUrlTransform Class when adding Bootstrap Bundle Like This:



public static void RegisterBundles(BundleCollection bundles)
{
StyleBundle bootCss = new StyleBundle("~/styles/bootstrap");
bootCss.Include("~/Content/bootstrap/styles/bootstrap.css",
new CssRewriteUrlTransform());
bootCss.Include("~/Content/bootstrap/styles/bootstrap-theme.min.css", new CssRewriteUrlTransform());
bundles.Add(bootCss);
}





share|improve this answer













In the {YourProjectName}App_StartBundleConfig.Cs



Add Instance of CssRewriteUrlTransform Class when adding Bootstrap Bundle Like This:



public static void RegisterBundles(BundleCollection bundles)
{
StyleBundle bootCss = new StyleBundle("~/styles/bootstrap");
bootCss.Include("~/Content/bootstrap/styles/bootstrap.css",
new CssRewriteUrlTransform());
bootCss.Include("~/Content/bootstrap/styles/bootstrap-theme.min.css", new CssRewriteUrlTransform());
bundles.Add(bootCss);
}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 9:10









Amirhossein_SAmirhossein_S

1




1













  • Hi there this is doesnt work, actually all link is working great if I view the code in browser. It just act like / back to root directory which I want is back to parent directory. Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:09



















  • Hi there this is doesnt work, actually all link is working great if I view the code in browser. It just act like / back to root directory which I want is back to parent directory. Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:09

















Hi there this is doesnt work, actually all link is working great if I view the code in browser. It just act like / back to root directory which I want is back to parent directory. Thank you for your answer.

– Jun Rikson
Nov 29 '18 at 20:09





Hi there this is doesnt work, actually all link is working great if I view the code in browser. It just act like / back to root directory which I want is back to parent directory. Thank you for your answer.

– Jun Rikson
Nov 29 '18 at 20:09











0














Build action set to None by Default so you need to change it to Content.



Right click in affected file > properties > set Build Action to Content



I hope this can help






share|improve this answer
























  • hi there, just like I said in comment, all files published correctly and Yes all files Build Action is Content, thats why all files copied correctly. Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:04
















0














Build action set to None by Default so you need to change it to Content.



Right click in affected file > properties > set Build Action to Content



I hope this can help






share|improve this answer
























  • hi there, just like I said in comment, all files published correctly and Yes all files Build Action is Content, thats why all files copied correctly. Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:04














0












0








0







Build action set to None by Default so you need to change it to Content.



Right click in affected file > properties > set Build Action to Content



I hope this can help






share|improve this answer













Build action set to None by Default so you need to change it to Content.



Right click in affected file > properties > set Build Action to Content



I hope this can help







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 28 '18 at 5:55









SaifSaif

1,0631824




1,0631824













  • hi there, just like I said in comment, all files published correctly and Yes all files Build Action is Content, thats why all files copied correctly. Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:04



















  • hi there, just like I said in comment, all files published correctly and Yes all files Build Action is Content, thats why all files copied correctly. Thank you for your answer.

    – Jun Rikson
    Nov 29 '18 at 20:04

















hi there, just like I said in comment, all files published correctly and Yes all files Build Action is Content, thats why all files copied correctly. Thank you for your answer.

– Jun Rikson
Nov 29 '18 at 20:04





hi there, just like I said in comment, all files published correctly and Yes all files Build Action is Content, thats why all files copied correctly. Thank you for your answer.

– Jun Rikson
Nov 29 '18 at 20:04


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244885%2fbroken-css-link-when-published-in-visual-studio-2017%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Create new schema in PostgreSQL using DBeaver

Deepest pit of an array with Javascript: test on Codility

Costa Masnaga