mercredi 11 novembre 2015

MVC 3 Area Registration 302 Error

I have a 2 area which names called with "Admin" and "Services". My project structure as below image 1

I want to redirect all root url to Admin area. I changed my area registration files to resolve this problem as below code block.

//Root 
//Old Value
routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
//New Value
routes.MapRoute(
                "Default", // Route name
                "trash/{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                );

Now for redirecting the root url to Admin area I've updated AdminAreaRegistration.cs class as below.

//Admin
//Old Value
context.MapRoute(
                "Admin_default",
                "Admin/{controller}/{action}/{id}",
                 new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

//New Value
context.MapRoute(
                "Admin_default",
                "{controller}/{action}/{id}",
                 new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

After this update when i want to browse my web site it was ok I can see my admin area views. But I have a lot of AJAX call on Admin Area Views and when those ajax calls try to call Services Area controller it could not access to the Services Controller, I've monitored on network plugin to see what is my error I get a HTTP 302 error and then its redirect to 404 Not Found page.

I hope my explanation is understable.

Thank you in advance.

Project Structure

Aucun commentaire:

Enregistrer un commentaire