c# - RedirectToRoute doesn't work -
i'm making first web app. until haven't got problems redirecttoroute or redirecttoaction. @ end of post action want redirect, doesn't work @ here code:
[httppost] public actionresult delete(int id) { var post = this.data .posts .all() .where(x => x.id == id) .firstordefault(); if (post != null) { var thread = this.data .threads .all() .where(x => x.id == post.threadid) .firstordefault(); this.data .posts .delete(post); this.data.savechanges(); return this.redirecttoroute(commonconstants.redirecttorouteshowthread, new { area = "", id = thread.id, title = thread.subcategory.title, name = thread.title, action = "display" }); //return this.redirecttoroute(commonconstants.redirecttorouteshowallthreadsinsubcategory, new { area = "", title = thread.subcategory.title }); // return this.redirect("red/red"); } return this.view(); }
i tried different redirects test, still doesn't work. i'am calling action js if matters. have checked if goes inside if conditional, seems fine. error?
edit: here routes
public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "show thread", url: "subcategory/{title}/{action}/{id}-{name}/{page}", defaults: new { controller = "post", action = "display", page = urlparameter.optional }, namespaces: new[] { "forumsystem.web.controllers" }); routes.maproute( name: "create , display threads", url: "subcategory/{title}/{action}/{page}", defaults: new { controller = "subcategory", page = urlparameter.optional }, namespaces: new[] { "forumsystem.web.controllers" }); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional }, namespaces: new[] { "forumsystem.web.controllers" }); }
and const
public static readonly string redirecttorouteshowthread = "show thread";
what mean doesn't work doesn't redirect else working expected.
Comments
Post a Comment