ASP.Net MVC 中的个性化——友好的 URL 和换肤

发布于 2024-09-03 07:26:05 字数 292 浏览 6 评论 0原文

我还没有深入研究 ASP.Net MVC 中友好 URL 的自定义生成,并且想知道是否有人有建议。例如,如果 John Smith 要在 www.example.com 上创建一个帐户,我希望他的主页显示为 www.example.com/JohnSmith —— 以及让他选择 URL 的选项。理想的情况是在我不干预路线图的情况下实现这一点。

另外,是否有人有关于基于 URL 自定义 MVC 站点的好方法的指南?再次,使用 example.com,我希望 John 为其主页选择颜色主题和徽标,然后相应地应用它。

感谢您的提示和建议。

I haven't delved into custom generation of friendly URLs in ASP.Net MVC, and was wondering if anyone had suggestions. For example, if John Smith were to create an account on www.example.com, I'd like for his homepage to read www.example.com/JohnSmith -- along with the option for him to choose his URL. The ideal is for this to happen with no intervention on my part in the route maps.

Also, does anyone have guidelines on good ways to go to customize an MVC site based on URL? Again, using example.com I'd like for John to choose a color theme and logo for his homepage, then apply it accordingly.

Thanks for your tips and suggestions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情绪 2024-09-10 07:26:05

您可以使用 路由 来实现此目的第二部分是它所在站点的关键。

routes.MapRoute(
            "Default",                                              // Route name
            "{site}/{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );

这样该站点就成为每个操作都可用的变量。

You can use routing for this where the second part is a key to which site it is.

routes.MapRoute(
            "Default",                                              // Route name
            "{site}/{controller}/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );

so that site becomes a variable available to every action.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文