Мое приложение показывает это странное поведение.Допустим, что ссылка на него выглядит так:
http://<serverhere>
Но когда пользователи используют эту ссылку, появляется другая:
http://<serverhere>/Access/Login/?login=<somevalue>
А так как у меня этого нетМаршрут сопоставлен, он выдает ошибку «Ресурс не найден».
Вот мой конфигурационный маршрут:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Access",
url: "Access/",
defaults: new { controller = "Access", action = "Index" }
);
routes.MapRoute(
name: "AccessIndex",
url: "Access/Index",
defaults: new { controller = "Access", action = "Index" }
);
routes.MapRoute(
name: "Main",
url: "Main/",
defaults: new { controller = "Main", action = "Index" }
);
routes.MapRoute(
name: "MainIndex",
url: "Main/Index",
defaults: new { controller = "Main", action = "Index" }
);
//padrão
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Access", action = "Index", id = UrlParameter.Optional }
);
}
А вот мой контроллер доступа:
public class AccessController: BaseController
{
public ActionResult Index()
{
LimparSession();
RepositorioAcesso repositorio = new RepositorioAcesso();
string login = System.Web.HttpContext.Current.User.Identity.Name.Split(new[] { "\\" }, StringSplitOptions.None)[1].ToLower();
Acesso acesso = repositorio.RecuperarAcesso(login, false);
if (acesso == null)
{
ViewBag.mensagem = "User Not Found";
return View();
}
else
{
return RedirectToAction("Login", "Access", new { @login = login });
}
}
private void LimparSession()
{
Session.Clear();
}
private RedirectToRouteResult Login(string login)
{
//Get info and then redirect
return RedirectToAction("Index", "Principal");
}
}
Что я могу сделать, чтобы предотвратить такое поведение?