asp.net-mvc - 如何在 asp.net mvc 中有通配符子域
问题描述
我想在我的项目中拥有动态通配符子域。我希望每个提供商都有特殊的子域。例如,provider1.mydomain.com 更改为 mydomain.com/provider1,我想将 provider1 作为参数传递给我的操作。
public ActionResult Details(string provider1){
//there is some code for show provider details
return view();
}
如何在我的项目中执行此操作以及如何在 localhost 中执行此操作?
解决方案
将此代码添加到 App_start 文件夹中的 RouteConfig 中:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.Add(new SubdomainRoute());
}
推荐阅读
- sql-server - SQL:遍历表中的每个条目,并使用行名、列名和条目创建一个新条目
- python - 提取数据时如何处理列名的不同拼写?
- typescript - 遍历 TypeScript 中指定的 getter / setter
- numpy - 如何在 cython 循环中有效地使用 numpy 函数?
- java - 如何删除已扫描的空白 pdf 页面。我正在使用 java 和 apache pdfbox
- c++ - 如何“重置” gsl::owner
? - python - 如何让用户输入的详细信息进入 python 文本文件中的新行?
- python - 并行网络请求:比较不同的方法
- hpc - 准备科学程序员/HPC 程序员面试
- python - 用于有效源代码控制的气流文件夹结构