Well my site local working well, but when is deployed to production the RedirectToAction fail and show a blank page.
I have tried these Redirect to Action is not working With ASP.NET core
here is the code:
public ActionResult Login()
{
return View();
}
[HttpPost]
public ActionResult Login(Models.UserViewModel person)
{
var booleanlog = Models.Security.User.login.DoLogin(person);
if (booleanlog!=0) {
...
return View("Index");
}
else {
return View("Login");
}
}
I already tried this code too and doesn´t work
[HttpPost]
public ActionResult Login(Models.UserViewModel person)
{
var booleanlog = Models.Security.User.login.DoLogin(person);
if (booleanlog != 0) {
var serializeSession = JsonConvert.SerializeObject(booleanlog);
HttpContext.Session.Set("Rol", Encoding.ASCII.GetBytes(serializeSession));
return RedirectToAction("Index","Home");
}
else {
return RedirectToAction("Index", "Home");
}
}
there are my routes configuration public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else if(env.IsProduction()) {
app.UseExceptionHandler("/Error");
} else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Login}/{id?}");
});
}
and show this
redirect to a root locahost and show error 404 not found
in addition, this work in my local VisualStudio IIS Express, My Local IIS, but doesn´t work in my production IIS
HomeController.Index()
look like? – Valuator