【问题标题】:How to route folder in ASP.NET MVC with all relative paths?如何在 ASP.NET MVC 中使用所有相对路径路由文件夹?
【发布时间】:2018-07-03 08:43:38
【问题描述】:

例如,我的 ASP.NET MVC 4 项目文件夹中有一个 Angular 项目文件夹。

MyAspProjectFolder/App/AngularFolder/dist/index.html

当我从操作重定向到这个文件时,使用

return Redirect(Url.Content("App/angularproj/dist/index.html"));

在打开 html 文件时,该 html 文件中的路径理解错误。例如,在这个 HTML 文件中,我有一个脚本链接

<script type="text/javascript" src="polyfills.bundle.js">

ASP 试图从 localhost 获取它的相对值,例如

http://localhost:53131/polyfills.bundle.js 

但它不在本地主机中,它在下面

App/angularproj/dist/polyfills.bundle.js

是否可以说 ASP,当我执行某些路线(例如 App/angularproj/ )时,这意味着该路线下的所有内容也与该路线相关。

【问题讨论】:

  • 您找到解决方案了吗?

标签: asp.net asp.net-mvc-4 routing


【解决方案1】:

Check this link

尝试使用@Url.Content("~/path/file.htm") 或

@Url.Action("ActionName", "ControllerName", new { variable = value })

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-02
    • 2011-02-26
    • 2014-10-05
    • 2013-12-20
    • 2014-08-23
    • 1970-01-01
    • 2019-05-12
    相关资源
    最近更新 更多