ASP.NET MVC3 プロジェクトには、2 つのコントローラーがあります。
HomeController.cs
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
//
// POST: /Home/CheckLogin/
[HttpPost]
public ActionResult CheckLogin()
{
// setting the session variable if login is correct
// and redirecting to /ReWeb/
// else, reloading the login.
}
}
もう1つはReWebController.csです
public class ReWebController : Controller
{
//
// GET: /ReWeb/
public ActionResult Index()
{
// Session verification
if (Session["_ReWeb"] != null)
{
return View();
}
// If session is null or not valid,
// redirect to login page
return RedirectToAction("Index", "Home");
}
}
HomeController Indexアクションによって返されるビューであるログイン ページには、次のフォームがあります。
<div id="loginPanel">
<form enctype="application/x-www-form-urlencoded" id="login" method="post">
<h1>Log In</h1>
<fieldset id="inputs">
<input id="Utente" name="Utente" type="text" placeholder="Utente" autofocus="true" required="true" />
<input id="Password" name="Password" type="password" placeholder="Password" required="true" />
</fieldset>
<fieldset id="actions">
<input type="submit" id="submit" value="Log in" onclick="javascript:window.open('/Home/CheckLogin/', 'WebClient', 'width=500,height=250,left=100,top=100')"/>
</fieldset>
</form>
</div>
私がやろうとしているのは、ユーザーが[ログイン] ボタンをクリックすると、アプリケーションがポップアップ ページでReWebControllerのビューを返すことです。ここで行ったことから、ポップアップが開きますが、404 エラーが表示されます: '/' アプリケーションでサーバー エラーが発生しました。リソースが見つかりません。要求された URL: /Home/CheckLogin/。
どうすればこのアプローチを実現できますか? 私はそれを正しくやっていますか?
どうもありがとう!