0

I am working on a MVC project using Ext.Net TreeGrid. I have the treegrid on a page "PieChart2". When I first load PieChart2, I load the tree with root nodes. When I click on one of the nodes I want to pass the node id in the same url (/Home/PieChart2/nodeid).I am trying achieve this by redirecting to a URL using the following code in the click event of the treegrid.

idVal is node id of the treenode that was clicked.

string newUrl = "/Home/PieChart2/" + idVal ;

Response.RedirectToRoutePermanent("PieRoute", new { id = idVal });

PieRoute looks like this in Global.asax.

routes.MapRoute("PieRoute", "{controller}/{action}/{id}", new { controller = "Home", action = "PieChart2", id = UrlParameter.Optional });

I see two requests to the server on redirection 1) 301 status code with original URL and 2) the new URL. The Url is processed correctly also, but the browser still shows "/Home/PieChart2" instead of "Home/PieChart2/nodeid".

Am I doing it the right way? If yes, what could be the reason for it to not work?

Rob
  • 45,296
  • 24
  • 122
  • 150
  • A silly question - does the original HTTP request happen via AJAX or by a standard synchronous HTTP post? If by an AJAX request, are you handling the HTTP 301 redirect within your AJAX code? – Shan Plourde Apr 25 '11 at 04:16
  • Shan, it is a sync HTTP request. Thanks – Sophie Raphel Apr 25 '11 at 17:52
  • I see - on the client side how are you handling the redirect request within your Ajax code? If you haven't accommodated it, you'll probably have to. See http://stackoverflow.com/questions/199099/how-to-manage-a-redirect-request-after-a-jquery-ajax-call as an example. – Shan Plourde Apr 25 '11 at 19:23

1 Answers1

0

The browser should update unless this is either an ajax call or call from within a frame element. In those cases, it won't by design.

Adam Tuliper
  • 29,982
  • 4
  • 53
  • 71
  • Adam, It certainly is from a frame element. Is there a way to update the main window's URL from within a frame? Thanks! – Sophie Raphel Apr 25 '11 at 17:52
  • nope - that would be a big security issue.. I could then make it say www.google.com when you were on some other 'bad' site. If you want it to update your main window has to be the URI in question that you are loading. In firefox for ex though you can right click on a particular page section and view the info for it to see the link. Such is the fun with frames. I think you can change the end of the parents URI for ex. xyz.com/default.aspx#sometag but that of course isn't changing the entire URI – Adam Tuliper Apr 30 '11 at 03:41