February 2015 - Digital Tool Factory blog February 2015 - Digital Tool Factory blog

The Digital Tool Factory Blog

How to use query strings in framesets with asp.net mvc 5 routing

The problem – I was working on a project that required frames – and I was trying to pass a querystring value to the frameset, as in /FramePage/?page=/SomePageOffSite.aspx – my first thought was to just pass the url of one of the frames to the frameset page as a string.  I made the model for the view a string and attempted to pass it via the usual way in the controller, i.e.

return View(“MyFramedInPage.aspx”);

My thought was that I could just use the Model property as the url, as in

frame src=”@Model” name=”main” noresize scrolling=”auto” marginheight=”0″ marginwidth=”0″

However, whenever I did that MVC would try to find a view with the url of the string (in this case SomePageOffSite.aspx – which did not exist) I was passing in the model.  I eventually figured it out – there is a feature I never use on return View – to wit – you can redirect it to another view simply by passing in the view name (I always used the redirect option) – therefore you can’t ever use a model as a string.  Lesson learned.


11
Feb 15


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.