MVCとRazorについての私の知識は非常に基本的なものなので、私は何か簡単なことを望んでいます。基本的には、Controllers
は正常ですが、Views
フォルダは入れ子構造です。たとえば、代わりの:MVCをネストしたフォルダのビューをルックアップする方法
Views -> Index.cshtml
Views -> BrandName -> Index.cshtml
ように私はこの問題を回避するためのカスタムヘルパーを作成しているが、私はそれは、クエリ文字列のURLでどのように動作するかわからないんだけど?ここでは例として、コントローラである:
private DataService ds = new DataService();
//
// GET: /Collections/
public ActionResult Index()
{
return View();
}
//
// GET: /Collections/Collection?id=1
public ActionResult Collection(int id)
{
var collectionModel = ds.GetCollection(id);
return View(collectionModel);
}
しかし、どのように私は見にActionResult Collection
を得るのです:
public static string ResolvePath(string pageName)
{
string path = String.Empty;
//AppSetting Key=Brand
string brand = ConfigurationManager.AppSettings["Brand"];
if (String.IsNullOrWhiteSpace(brand))
path = "~/Views/Shared/Error.cshtml"; //Key [Brand] was not specified
else
path = String.Format("~/Views/{0}/{1}", brand, pageName);
return path;
}
不明。回避策がありますが(ほとんどの場合はうまくいきますが)代わりに非常に単純なコントローラを投稿していますか? –
@HenkHoltermanおそらく自然に行う方法があるので、回避策を進めることはあまりありません。 – ediblecode
@HenkHolterman質問がどうにかクリアされないのを見ないでください – ediblecode