发布项目时mvc中的URL错误 [英] error in urls in mvc while publishing project

查看:73
本文介绍了发布项目时mvc中的URL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们!

i开发了一个asp.net mvc项目,其中我在我的主要Layout.cshtml中使用的页脚css如下:

< link href =../ stylesheet / footer.css =stylesheettype =text / css/>

当我在本地部署项目时我工作正常。但是当我在托管服务器或本地服务器上发布项目时,它会出错。上面的css文件无法呈现。当我从上面的链接中删除../。然后它工作正常。我不知道原因是什么。有什么想法错了吗?

谢谢

Hey Guys!
i have developed an asp.net mvc project in which the footer css i have use in my main Layout.cshtml like:
<link href="../stylesheet/footer.css" rel="stylesheet" type="text/css" />
when i deploy the project locally i works fine. but when i publish the project on hosting server or local server, it gives error. that above css file can''t be rendered. when i remove "../" form my above link. then it works fine. i dont know whats the reason. Any idea whats wrong?
Thanks

推荐答案

问题是相对路径引用问题。盯着当前页面路径的../已解析对等体。因此,当您将其部署到托管服务器时,其当前页面路径的对等方与您的本地环境不同。如果您阅读链接,则可以轻松了解该问题。
The issue is relative path referencing issue. Staring with ../ resolved peer of the current page path. So when you deploy it to hosting server then its peer of the current page path is difference then your local environment. If you read link then you can easily understand the issue.


拿那个..并替换它〜代号。
Take that .. and replace it ~ tilde symbol.


这篇关于发布项目时mvc中的URL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆