Not able to access viewdata http://forums.asp.net/t/1194805.aspx/1?Not+able+to+access+viewdata+Mon, 17 Dec 2007 09:05:29 -050011948052061986http://forums.asp.net/p/1194805/2061986.aspx/1?Not+able+to+access+viewdata+Not able to access viewdata <p>&nbsp;why&nbsp; am i not able to access ViewData property in my aspx page. I did create a MVC View page item, and my partial class does derive from a ViewPage&lt;&gt; class.</p> <p>I can not figure out, what i am missing in my aspx page, but i dont get access to ViewData, Html htmlhelper members. in generall, it doesnt understand anything about the viewpage ?</p> <p>I am still on VS2008 beta, is this a problem with vs2008 beta ? or am i missing something in my aspx page ?</p> <p>&nbsp;</p> <p>neo.&nbsp;</p> 2007-12-16T01:28:51-05:002062012http://forums.asp.net/p/1194805/2062012.aspx/1?Re+Not+able+to+access+viewdataRe: Not able to access viewdata <p>How do you know you can't access it? Is it an intellisense issue or are you getting an exception? If it's intellisense - build your app and that should fix it.</p> <p>Next, check the web.config and make sure that &lt;system.web&gt;&lt;pages&gt;&lt;namespaces&gt; contains &quot;System.Web.Mvc&quot;.&nbsp;</p> 2007-12-16T02:56:37-05:002062017http://forums.asp.net/p/1194805/2062017.aspx/1?Re+Not+able+to+access+viewdataRe: Not able to access viewdata <p>Both,I get a an error&nbsp; (using ViewData i get Object reference not set to an instance ) when i run the page and also no intellisense. My web.config does have &quot;System.Web.Mvc&quot;. I did rebuild the whole project few times.<br> </p> <p>Any other ideas ?</p> <p>&nbsp;</p> 2007-12-16T03:09:50-05:002062023http://forums.asp.net/p/1194805/2062023.aspx/1?Re+Not+able+to+access+viewdataRe: Not able to access viewdata <p>Are you using a typed view ViewPage&lt;&gt;?</p> <p>If no, then there isnt any intellisence to be had for the ViewData since your just working against a Dictionary&lt;string,object&gt;. So you would access it like ViewData[&quot;ProductId&quot;]. If you want intellisence on the ViewData change the page to inherit from ViewPage&lt;Type&gt;.</p> <p>Also, when you get the &quot;object reference not set to an instance&quot; does your Url look like /Products/List or /Products/List.aspx?</p> <p>If it looks like /Products/List.aspx, try going to /Products/List and see if it works. Replacing Products/List with the appropriate controller/action.</p> 2007-12-16T03:17:36-05:002062024http://forums.asp.net/p/1194805/2062024.aspx/1?Re+Not+able+to+access+viewdataRe: Not able to access viewdata <p>I am using ViewPage&lt;&gt;.</p> <p>1.when i try to debug from VS2008 beta, the browser is infact trying to acess .aspx. Which im not sure why it does ? Instead if i open up a browser, and try to acess /controller/action i dont get the error.</p> <p>&nbsp;2. I think intellisense is a problem with VS2008 beta. I am not seeing Html helperclass object as well in my aspx, and am deriving my page class from ViewPage&lt;&gt;<br> </p> <p><br> &nbsp;</p> <p>&nbsp;</p> 2007-12-16T03:33:15-05:002062029http://forums.asp.net/p/1194805/2062029.aspx/1?Re+Not+able+to+access+viewdataRe: Not able to access viewdata <p>To allow for pressing F5 to debug you will want to set your default.aspx to the start page and then navigate to the page that you are trying to debug, since VS2008 is not aware that the pathing is different with an Mvc app then a normal WebForms website (though it would be nice). </p> 2007-12-16T03:44:13-05:002063187http://forums.asp.net/p/1194805/2063187.aspx/1?Re+Not+able+to+access+viewdataRe: Not able to access viewdata <p>Don't you only need to inherit from ViewPage&lt;&gt; if your using strongly typed objects? </p> <p>How are you setting the ViewData ?</p> <p>I mentioned the two ways in my post if thats any use: <a href="http://blog.benhall.me.uk/2007/12/first-play-with-aspnet-mvc.html"> http://blog.benhall.me.uk/2007/12/first-play-with-aspnet-mvc.html</a></p> 2007-12-17T09:02:05-05:002063197http://forums.asp.net/p/1194805/2063197.aspx/1?Re+Not+able+to+access+viewdataRe: Not able to access viewdata <p>Intellisense doesn't appear to work correctly with Microsoft MVC using Visual Studio 2008 Beta 2. As this thread outlines - <a href="http://forums.asp.net/t/1192768.aspx">http://forums.asp.net/t/1192768.aspx</a>&nbsp;- installing Visual Studio 2008 RTM (I'm using the 90 day trial) fixes this. You shouldn't need to add any extra references or changes to your .aspx files with the 2008 RTM version.</p> 2007-12-17T09:05:29-05:00