MVC剃须刀中的普通HTML链接 [英] Ordinary html links in mvc razor

查看:65
本文介绍了MVC剃须刀中的普通HTML链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很好用的mvc剃须刀应用程序,我只是尝试放入一个静态html条款页面.当我尝试使用

I have an mvc razor app that's humming along nicely, and I just tried to drop in a static html Terms and Conditions page. When I try to link to it from my opt-in cshtml with

<a href="~/Views/UserPromotion/TechFundTnC.html">Terms and Conditions</a>

在运行时显示404s,显示找不到资源".

It 404s at runtime with "resource cannot be found".

它在已编译的文件夹中.路径和名称是正确的(我是用intellisense选择的,所以它知道它在那里).链接cshtml页面和目标html页面甚至位于同一文件夹中(我也尝试过仅使用文件名).

It's in the compiled folder. The path and name are correct (I picked it with intellisense, so it knows it's there). The link cshtml page and destination html page are even in the same folder (I've tried using just the filename too).

这只是纯HTML.它不需要摆弄路由之类的东西.为什么找不到它?

It's just plain html. It shouldn't need any fiddling with routing or anything. Why can't it find it?

推荐答案

〜/Views 默认情况下不可访问,并且在静态HTML中不起作用,您可以使用它,它应该为您提供相对的路径和工作

~/Views is inaccessible by default and ~ doesn't work in static HTML, you can use this and it should get you the relative path and work

将静态HTML文件放入〜/Content/UserPromotion 并使用

Put your static HTML file in ~/Content/UserPromotion and use

<a href="@Url.Content("~/Content/UserPromotion/TechFundTnC.html")">Terms and Conditions</a>

这篇关于MVC剃须刀中的普通HTML链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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