データベースから URL を動的に取得し、それを 1 つのコントローラーで複数のルートに渡します。そしてViewのモデルにurl-itemsのコンテンツ本体を入れると。そしてポイントは、編集済みプロジェクトをコンパイルした後にのみ新しいページの読み込みを開始することです.404ページを表示する前に.
public class DynamicController : MenuController
{
//
// GET: /Dynamic/
s
public ActionResult Indexx(string routes) {
var str = service.Get().Single(x=>x.Url==routes);
return View(str);
}
}
ルート:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
/**/ IMenuService<Menu> service = new MenuEntityService();
foreach (var item in service.Get())
{
routes.MapRoute(
name: item.Url,
url: item.Url,
defaults: new { controller = "Dynamic", action = "Indexx",routes=item.Url },
namespaces: new[] { "MvcApplication1.Controllers" }
);
}