1

I got very strange situation. I cannot get value from RouteData. It's very simple Controller:

public async Task<JsonResult> Create(int id)
{
    var userid = (int)RouteData.Values["id"];
    var answer = await uccr.CreateUserCategory(id, userid);
    return answer.result == IsSuccess.Success ? Json(new { IsSuccess = true }) : Json(new { DataError = answer.DataError });
}

But there is no value in userid variable. Here is RouteConfig (in Area):

public override void RegisterArea(AreaRegistrationContext context) 
{
    context.MapRoute(
        "AdminDefault",
        "Admin/{controller}/{action}/{id}",
        new { action = "Index", id = UrlParameter.Optional }
    );
}
Sam FarajpourGhamari
  • 14,601
  • 4
  • 52
  • 56
andrey.shedko
  • 3,128
  • 10
  • 61
  • 121

0 Answers0