c# - Why does RedirectToAction redirects to <param>.com -
we have mvc4 site homecontroller.index() has following code
redirectiontoaction("page", new { id = "home" } );
where action page defined as
public actionresult page(string id) .....
on debug, starts localhost:xxxxx
redirects www.home.com
on setting breakpoint, not hit method page(string id )
any clues on ?
looks may have routing issues. routeconfig.cs file in app_start folder in mvc4 project.
one other thing, if page action in different controller homecontroller, need code this:
public actionresult index() { return redirecttoaction("othercontroller", "page", new { id = "home" }); }
created basic mvc4 project redirection have , works me. user ends @ following url: [http://localhost:47272/home/page/home]
here's homecontroller.cs
public class homecontroller : controller { // // get: /home/ public actionresult index() { return redirecttoaction("page", new { id = "home" }); } public actionresult page(string id) { return view(); } }
here's routeconfig.cs
public class routeconfig { public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); } }
Comments
Post a Comment