By default does not redirect to controller index action method

I recently created a controller call DashboardVideos

and action method called Index

.

And after Add

Or Update

, I redirect it to the index page with

RedirectToAction("Index", "DashboardVideos")

...

but this code redirects it to /DashboardVideos/

and it says

HTTP Error 403.14 - Forbidden The web server is configured to not display the contents of this directory.

so the issue defaults to the page loading Index

when I say /Dashboard

But its not, the same url pattern works with all other controller (so I don't think there is anything wrong with the routing pattern).

Any help would be appreciated.

code:

 public class DashboardVideosController : BaseController
    {
        private readonly IDashboardVideosComponent socialTagComponent;

        public DashboardVideosController()
        {
            socialTagComponent = ComponentFactory.Get<IDashboardVideosComponent>();
        }

        // GET: DashboardVideos
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
    public ActionResult AddUpdate(DashboardVideosModel socialTagChannel)
    {
       //Save data to database
        return RedirectToAction("Index", "DashboardVideos");
    }
     }

      

+3


source to share


2 answers


Just write this if both actions are in the same controller.



public ActionResult AddUpdate(DashboardVideosModel socialTagChannel)
{
   //Save data to database
    return RedirectToAction("Index");
}

      

+2


source


Try looking at your "RouteConfig" class and you can specify specific routes there. It's also possible if the call is coming from AJAX it can jump directly to the action without redirecting. Have you tried to debug your code?



0


source







All Articles