gpt4 book ai didi

带有子文件夹的 C# ASP.NET MVC Controller

转载 作者:太空宇宙 更新时间:2023-11-03 20:58:28 25 4
gpt4 key购买 nike

我想为我的 Controller 创建一个子文件夹。

这是我的文件夹结构:

This is my folder structure.

获得以下结果的最佳方法是什么?

localhost/home

Controller: Common/Home
View: Common/Home


localhost/product

Controller: Catalog/Product
View: Catalog/Product

最佳答案

在 asp.net MVC Controllers 中,文件夹被忽略,只要 cs 文件被设置为编译它们将被编译成 DLL 文件并通过获取类名(即 ProductController)并从中删除 Controller 一词来引用结尾。

因此,文件夹结构在很大程度上取决于您自己,只要对您自己的项目管理有意义即可。

如果您试图让某些 URL 指向某些 Controller ,请查看 Routing反而。

关于带有子文件夹的 C# ASP.NET MVC Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48032460/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com