[英]asp net web application under IIS 7.5 redirect to a login page but gives error http 404.0 after log-in
我有一個使用ASP NET MVC開發的應用程序,並且已經在IIS中配置了虛擬目錄。
我可以訪問服務器文件夾,也可以訪問位於http:localhost:8081 / application的應用程序
我已按預期重定向到位於/ Account / Login的登錄頁面,但是當我使用用戶名/密碼登錄時,我得到了Erro HTTP 404.0-Not Found。
為什么會這樣呢?
編輯:
控制器:
//
// POST: /Account/Login
[HttpPost]
[ValidateAntiForgeryToken]
[AllowAnonymous]
public ActionResult Login(LoginModel model, string returnUrl)
{
MembershipProvider mp = Membership.Provider;
if (ModelState.IsValid && mp.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, false);
return RedirectToAction("Index", "Home");
}
// If we got this far, something failed, redisplay form
ModelState.AddModelError("", "Username ou Password incorreto!.");
return View(model);
}
RouteConfig:
namespace tgpwebged { public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
);
}
}
}
您的web.config可能應在其loginUrl1
屬性中包含虛擬目錄。
嘗試像這樣更改web.config:
<authentication mode="Forms">
<forms loginUrl="tgpwebged/Account/Login" />
</authentication>
問題不在於我的asp net應用,而在於IIS配置。 IIS負責人解決了該問題。 謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.