I noticed today that both namespaces System.Web.Mvc
and System.Web.WebPages.Html
have a SelectListItem. What is the difference between the too and is there times you should use one over the other?
Asked
Active
Viewed 1,786 times
5

hutchonoid
- 32,982
- 15
- 99
- 104

Matthew Verstraete
- 6,335
- 22
- 67
- 123
1 Answers
4
System.Web.Mvc
is specific to the MVC framework.
System.Web.WebPages.Html
is for use with Web Pages that use Razor.
To be honest I've never used them in Web Pages but the examples I have seen they look identical, I just remember to never select the WebPages namespace.
There is an example available here:
http://www.mikesdotnetting.com/Article/184/HTML-Helpers-For-Forms-In-Razor-Web-Pages

hutchonoid
- 32,982
- 15
- 99
- 104
-
So in the controller for my MVC web app (using Razor on the views) which one should I go with? – Matthew Verstraete Jan 25 '14 at 20:04
-
Always go with the System.Web.Mvc. :) – hutchonoid Jan 25 '14 at 20:05
-
3Actually, both classes are identical according to the Microsoft docs here. http://msdn.microsoft.com/en-us/library/system.web.mvc(v=vs.99).aspx I'd still use the mvc namespace though for the above reasons. – hutchonoid Jan 25 '14 at 20:09