c# - 在其他 MVC 项目中构建 URL

标签 c# asp.net-mvc

我有 2 个 MVC 网站(和一个公共(public)库)。

在项目“A”中,我需要来自项目“B”的 URL。在项目“B”中,我可以使用 Url.Action("Method", "Controller") 来构建 URL。

我如何才能跨网站引用另一个项目的路线? 那么单元测试呢?

最佳答案

将 RouteConfig 类放在 Common 库中定义路由的位置,然后在两个网站的 Global.asax 文件中调用该类的 RegisterRoutes 方法。

关于c# - 在其他 MVC 项目中构建 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25714007/

相关文章:

c# - 如何在我的 ASP.NET 应用程序中长时间使用 Session

c# - WCF 客户端安全 header 错误 "An invalid security token was provided"

asp.net-mvc - MVC Action Controller 生成一个带有 token 的 url,供用户在不登录的情况下单击并查看页面

c# - 将数据添加到缓存时出现重复的键

c# - 尽管存在错误 View ,但找不到错误页面 ASP.NET MVC

c# - 从表中删除一行似乎失败

c# - Entity Framework 性能问题

c# - 可以分机 : Window be constrained in framelike Master markup?

c# - 如何使用异步任务获取数据并在 View 中显示?

javascript - jquery.click 之后更新 HTML 页面