【发布时间】:2019-05-17 04:50:39
【问题描述】:
我无法重定向到某个区域,出现一条消息“处理请求时发生未处理的异常。InvalidOperationException:没有路由与提供的值匹配”。没有路由与提供的值匹配。
Startup.cs
我创建了这些路线:
routes.MapRoute("areaRoute","area:exists}/{controller=Admin}/{action=Index}/{id?}");
LoginController.cs
public async Task<IActionResult> GravarCadastro(CadastroModel novoUsuario)
{
RedirectToActionResult redirecionar;
switch (novoUsuario.perfil)
{
case 1:
//not Working
redirecionar = RedirectToAction("Index", "Paciente");
break;
case 2:
//not Working
redirecionar = RedirectToAction("Index", "medico");
break;
case 3:
//not Working
redirecionar = RedirectToAction("Index", "farmacia");
break;
case 4:
//not Working
redirecionar = RedirectToAction("Index", "laboratorio");
break;
default:
//not Working
redirecionar = RedirectToAction("Index", "paciente");
break;
}
return redirecionar;
}
PacienteController.cs
我正在使用这些属性
[AllowAnonymous]
[Area("Paciente")]
[Route("Paciente")]
public class PacienteController : Controller
{
//[Authorize]
public ActionResult Index()
{
return View();
}
}
【问题讨论】:
标签: c# asp.net-core asp.net-core-mvc