How to set default route in asp.net mvc application from web.config

How to set default route in asp.net mvc application from web.config

Solution:

Add Key web.config as below

  <add key="DeafaultPageAfterLogin" value="/MyOrderedMeals" />


in controller or route.config file set redirect url to


 if (ConfigurationManager.AppSettings["DeafaultPageAfterLogin"]!=null)
                    {
                       
                        return Redirect(ConfigurationManager.AppSettings["DeafaultPageAfterLogin"].ToString());
                    }


in else part you can set default route.

By  Junaid A    28-Jan-2023    2

Solutions


Your Answer

10349