私の mvc サイトは、モバイル ブラウザーと非モバイル ブラウザーで正常に動作しています。私が抱えている問題はこれです。(ログの理由から) 実行したくないアクションがいくつかあるので、モバイルで試すまでこれreturn RedirectToAction(...);
を使用していましたが、OtherView.Mobile.cshtml が見つかりません。return View("OtherView", model);
これを機能させる方法はありますか?
これがビューです
Views/Account/Create.cshtml
Views/Account/Create.Mobile.cshtml
Views/Account/CreateSuccess.cshtml
Views/Account/CreateSuccess.Mobile.cshtml
これがアクションです
public ActionResult Create(FormCollection form)
{
TryUpdateModel(model);
if(!ModelState.IsValid) { return View(); } // this works correctly
var model = new Account();
var results = database.CreateAccount(model);
if(results) return View("CreateSuccess", model); // trying to make this dynamic
return View(model); // this works correctly
}
通常はreturn RedirectToAction(...);
、アカウントの詳細ページに対して行うだけですが、これにより (このユーザーが読み取られる) 追加のログ エントリが生成されるだけでなく、詳細ページにはパスワードへのアクセス権がありません。最初にパスワードを持っていたのでActionResult Create
、二度と見られないようにする前に、確認のためにそれをユーザーに表示できます。
明確にするために、私はやりたくありません。if (Request.Browser.IsMobileDevice) mobile else full
なぜなら、iPad などのために別のモバイル ビューのセットを追加することになるかもしれないからです。
Views/Account/Create.cshtml
Views/Account/Create.Mobile.cshtml
Views/Account/Create.iPad.cshtml
Views/Account/CreateSuccess.cshtml
Views/Account/CreateSuccess.Mobile.cshtml
Views/Account/CreateSuccess.iPad.cshtml