Skip to content
Browse files

MVC RTM Source Checkin

git-svn-id: https://aspnet.svn.codeplex.com/svn@22929 e17a0e51-4ae3-4d35-97c3-1a29b211df97
  • Loading branch information...
1 parent 2f96d94 commit 7daafc6d7e05a2c4b032e6608ecf124c53405c4b SND\AspNetExtensions_cp committed Apr 8, 2009
Showing with 2,036 additions and 1,529 deletions.
  1. +0 −2 MVC/{MVC.sln → MvcDev.sln}
  2. +4 −4 MVC/src/MicrosoftMvcAjaxScript/Properties/Script.jst
  3. +0 −2 MVC/src/MvcFutures/Internal/ExpressionHelper.cs
  4. +18 −0 MVC/src/MvcFutures/Mvc/AcceptAjaxAttribute.cs
  5. +22 −0 MVC/src/MvcFutures/Mvc/AjaxExtensions.cs
  6. +0 −3 MVC/src/MvcFutures/Mvc/AsyncActionDescriptor.cs
  7. +0 −2 MVC/src/MvcFutures/Mvc/AsyncCallback`1.cs
  8. +0 −3 MVC/src/MvcFutures/Mvc/AsyncController.cs
  9. +0 −2 MVC/src/MvcFutures/Mvc/AsyncControllerActionInvoker.cs
  10. +0 −3 MVC/src/MvcFutures/Mvc/AsyncManager.cs
  11. +0 −2 MVC/src/MvcFutures/Mvc/AsyncResultWrapper.cs
  12. +0 −3 MVC/src/MvcFutures/Mvc/AsyncRouteCollectionExtensions.cs
  13. +1 −3 MVC/src/MvcFutures/Mvc/AsyncTimeoutAttribute.cs
  14. +0 −2 MVC/src/MvcFutures/Mvc/BeginInvokeCallback.cs
  15. +30 −0 MVC/src/MvcFutures/Mvc/BinaryHtmlExtensions.cs
  16. +0 −2 MVC/src/MvcFutures/Mvc/ButtonBuilder.cs
  17. +0 −2 MVC/src/MvcFutures/Mvc/ButtonsAndLinkExtensions.cs
  18. +31 −0 MVC/src/MvcFutures/Mvc/ByteArrayModelBinder.cs
  19. +0 −1 MVC/src/MvcFutures/Mvc/CacheExtensions.cs
  20. +0 −3 MVC/src/MvcFutures/Mvc/ContentTypeAttribute.cs
  21. +0 −3 MVC/src/MvcFutures/Mvc/Controls/ActionLink.cs
  22. +123 −23 MVC/src/MvcFutures/Mvc/Controls/DropDownList.cs
  23. +0 −3 MVC/src/MvcFutures/Mvc/Controls/Hidden.cs
  24. +30 −15 MVC/src/MvcFutures/Mvc/Controls/Label.cs
  25. +0 −35 MVC/src/MvcFutures/Mvc/Controls/ListBoxHelper.cs
  26. +1 −5 MVC/src/MvcFutures/Mvc/Controls/MvcControl.cs
  27. +76 −20 MVC/src/MvcFutures/Mvc/Controls/MvcInputControl.cs
  28. +0 −3 MVC/src/MvcFutures/Mvc/Controls/Password.cs
  29. +2 −3 MVC/src/MvcFutures/Mvc/Controls/Repeater.cs
  30. +0 −3 MVC/src/MvcFutures/Mvc/Controls/RepeaterItem.cs
  31. +1 −6 MVC/src/MvcFutures/Mvc/Controls/RouteValues.cs
  32. +0 −3 MVC/src/MvcFutures/Mvc/Controls/TextBox.cs
  33. +0 −2 MVC/src/MvcFutures/Mvc/CookieTempDataProvider.cs
  34. +60 −5 MVC/src/MvcFutures/Mvc/ExpressionInputExtensions.cs
  35. +0 −2 MVC/src/MvcFutures/Mvc/FileCollectionModelBinder.cs
  36. +0 −1 MVC/src/MvcFutures/Mvc/FormExtensions.cs
  37. +0 −3 MVC/src/MvcFutures/Mvc/IAsyncActionDescriptor.cs
  38. +0 −3 MVC/src/MvcFutures/Mvc/IAsyncActionInvoker.cs
  39. +0 −3 MVC/src/MvcFutures/Mvc/IAsyncController.cs
  40. +0 −4 MVC/src/MvcFutures/Mvc/IAsyncManagerContainer.cs
  41. +0 −2 MVC/src/MvcFutures/Mvc/ImageExtensions.cs
  42. +0 −2 MVC/src/MvcFutures/Mvc/LinkBuilder.cs
  43. +0 −2 MVC/src/MvcFutures/Mvc/LinkExtensions.cs
  44. +6 −24 MVC/src/MvcFutures/Mvc/LinqBinaryModelBinder.cs
  45. +0 −3 MVC/src/MvcFutures/Mvc/MailToExtensions.cs
  46. +0 −2 MVC/src/MvcFutures/Mvc/MvcAsyncHandler.cs
  47. +0 −3 MVC/src/MvcFutures/Mvc/MvcAsyncRouteHandler.cs
  48. +0 −2 MVC/src/MvcFutures/Mvc/MvcHttpAsyncHandler.cs
  49. +0 −1 MVC/src/MvcFutures/Mvc/MvcSubstitutionCallback.cs
  50. +0 −3 MVC/src/MvcFutures/Mvc/NoAsyncTimeoutAttribute.cs
  51. +0 −2 MVC/src/MvcFutures/Mvc/ObjectAsyncResult`1.cs
  52. +0 −3 MVC/src/MvcFutures/Mvc/OutstandingAsyncOperations.cs
  53. +0 −2 MVC/src/MvcFutures/Mvc/RadioExtensions.cs
  54. +0 −3 MVC/src/MvcFutures/Mvc/ReflectedAsyncControllerDescriptor.cs
  55. +0 −3 MVC/src/MvcFutures/Mvc/ReflectedAsyncPatternActionDescriptor.cs
  56. +0 −3 MVC/src/MvcFutures/Mvc/ReflectedDelegatePatternActionDescriptor.cs
  57. +0 −3 MVC/src/MvcFutures/Mvc/ReflectedEventPatternActionDescriptor.cs
  58. +40 −0 MVC/src/MvcFutures/Mvc/RequireSslAttribute.cs
  59. +0 −3 MVC/src/MvcFutures/Mvc/SingleFireEvent.cs
  60. +0 −2 MVC/src/MvcFutures/Mvc/SkipBindingAttribute.cs
  61. +0 −1 MVC/src/MvcFutures/Mvc/ViewExtensions.cs
  62. +9 −2 MVC/src/MvcFutures/MvcFutures.csproj
  63. +1 −2 MVC/src/MvcFutures/Properties/AssemblyInfo.cs
  64. +21 −3 MVC/src/MvcFutures/Resources/MvcResources.Designer.cs
  65. +9 −3 MVC/src/MvcFutures/Resources/MvcResources.resx
  66. +0 −2 MVC/src/SystemWebMvc/Mvc/AcceptVerbsAttribute.cs
  67. +0 −3 MVC/src/SystemWebMvc/Mvc/ActionDescriptor.cs
  68. +0 −3 MVC/src/SystemWebMvc/Mvc/ActionExecutedContext.cs
  69. +0 −3 MVC/src/SystemWebMvc/Mvc/ActionExecutingContext.cs
  70. +0 −3 MVC/src/SystemWebMvc/Mvc/ActionFilterAttribute.cs
  71. +0 −3 MVC/src/SystemWebMvc/Mvc/ActionMethodSelectorAttribute.cs
  72. +0 −3 MVC/src/SystemWebMvc/Mvc/ActionNameAttribute.cs
  73. +0 −5 MVC/src/SystemWebMvc/Mvc/ActionNameSelectorAttribute.cs
  74. +0 −2 MVC/src/SystemWebMvc/Mvc/ActionResult.cs
  75. +0 −3 MVC/src/SystemWebMvc/Mvc/ActionSelector.cs
  76. +7 −8 MVC/src/SystemWebMvc/Mvc/Ajax/AjaxExtensions.cs
  77. +0 −3 MVC/src/SystemWebMvc/Mvc/Ajax/AjaxOptions.cs
  78. +0 −3 MVC/src/SystemWebMvc/Mvc/AjaxHelper.cs
  79. +0 −4 MVC/src/SystemWebMvc/Mvc/AjaxHelper`1.cs
  80. +0 −4 MVC/src/SystemWebMvc/Mvc/AjaxRequestExtensions.cs
  81. +28 −5 MVC/src/SystemWebMvc/Mvc/{AntiForgeryToken.cs → AntiForgeryData.cs}
  82. +4 −4 MVC/src/SystemWebMvc/Mvc/{AntiForgeryTokenSerializer.cs → AntiForgeryDataSerializer.cs}
  83. +0 −4 MVC/src/SystemWebMvc/Mvc/AuthorizationContext.cs
  84. +0 −2 MVC/src/SystemWebMvc/Mvc/AuthorizeAttribute.cs
  85. +0 −2 MVC/src/SystemWebMvc/Mvc/BindAttribute.cs
  86. +0 −2 MVC/src/SystemWebMvc/Mvc/ContentResult.cs
  87. +2 −4 MVC/src/SystemWebMvc/Mvc/Controller.cs
  88. +0 −2 MVC/src/SystemWebMvc/Mvc/ControllerActionInvoker.cs
  89. +0 −3 MVC/src/SystemWebMvc/Mvc/ControllerBase.cs
  90. +0 −3 MVC/src/SystemWebMvc/Mvc/ControllerBuilder.cs
  91. +0 −2 MVC/src/SystemWebMvc/Mvc/ControllerContext.cs
  92. +0 −3 MVC/src/SystemWebMvc/Mvc/ControllerDescriptor.cs
  93. +0 −3 MVC/src/SystemWebMvc/Mvc/CustomModelBinderAttribute.cs
  94. +0 −2 MVC/src/SystemWebMvc/Mvc/DefaultControllerFactory.cs
  95. +28 −9 MVC/src/SystemWebMvc/Mvc/DefaultModelBinder.cs
  96. +0 −5 MVC/src/SystemWebMvc/Mvc/DefaultViewLocationCache.cs
  97. +0 −3 MVC/src/SystemWebMvc/Mvc/EmptyResult.cs
  98. +0 −3 MVC/src/SystemWebMvc/Mvc/ExceptionContext.cs
  99. +0 −2 MVC/src/SystemWebMvc/Mvc/FileContentResult.cs
  100. +0 −2 MVC/src/SystemWebMvc/Mvc/FilePathResult.cs
  101. +0 −2 MVC/src/SystemWebMvc/Mvc/FileResult.cs
  102. +0 −2 MVC/src/SystemWebMvc/Mvc/FileStreamResult.cs
  103. +0 −3 MVC/src/SystemWebMvc/Mvc/FilterAttribute.cs
  104. +0 −4 MVC/src/SystemWebMvc/Mvc/FilterInfo.cs
  105. +0 −3 MVC/src/SystemWebMvc/Mvc/FormCollection.cs
  106. +0 −3 MVC/src/SystemWebMvc/Mvc/HandleErrorAttribute.cs
  107. +0 −3 MVC/src/SystemWebMvc/Mvc/HandleErrorInfo.cs
  108. +2 −5 MVC/src/SystemWebMvc/Mvc/Html/FormExtensions.cs
  109. +15 −2 MVC/src/SystemWebMvc/Mvc/Html/InputExtensions.cs
  110. +2 −3 MVC/src/SystemWebMvc/Mvc/Html/LinkExtensions.cs
  111. +0 −2 MVC/src/SystemWebMvc/Mvc/Html/MvcForm.cs
  112. +0 −1 MVC/src/SystemWebMvc/Mvc/Html/RenderPartialExtensions.cs
  113. +13 −12 MVC/src/SystemWebMvc/Mvc/Html/SelectExtensions.cs
  114. +0 −1 MVC/src/SystemWebMvc/Mvc/Html/TextAreaExtensions.cs
  115. +49 −10 MVC/src/SystemWebMvc/Mvc/Html/ValidationExtensions.cs
  116. +35 −15 MVC/src/SystemWebMvc/Mvc/HtmlHelper.cs
  117. +0 −2 MVC/src/SystemWebMvc/Mvc/HtmlHelper`1.cs
  118. +0 −1 MVC/src/SystemWebMvc/Mvc/HttpAntiForgeryException.cs
  119. +0 −2 MVC/src/SystemWebMvc/Mvc/HttpPostedFileBaseModelBinder.cs
  120. +0 −3 MVC/src/SystemWebMvc/Mvc/HttpUnauthorizedResult.cs
  121. +0 −3 MVC/src/SystemWebMvc/Mvc/IActionFilter.cs
  122. +0 −4 MVC/src/SystemWebMvc/Mvc/IActionInvoker.cs
  123. +0 −3 MVC/src/SystemWebMvc/Mvc/IAuthorizationFilter.cs
  124. +0 −3 MVC/src/SystemWebMvc/Mvc/IController.cs
  125. +0 −3 MVC/src/SystemWebMvc/Mvc/IControllerFactory.cs
  126. +0 −3 MVC/src/SystemWebMvc/Mvc/IExceptionFilter.cs
  127. +0 −4 MVC/src/SystemWebMvc/Mvc/IModelBinder.cs
  128. +0 −3 MVC/src/SystemWebMvc/Mvc/IResultFilter.cs
  129. +1 −2 MVC/src/SystemWebMvc/Mvc/ITempDataProvider.cs
  130. +0 −3 MVC/src/SystemWebMvc/Mvc/IView.cs
  131. +0 −3 MVC/src/SystemWebMvc/Mvc/IViewDataContainer.cs
  132. +0 −4 MVC/src/SystemWebMvc/Mvc/IViewEngine.cs
  133. +0 −2 MVC/src/SystemWebMvc/Mvc/IViewLocationCache.cs
  134. +0 −5 MVC/src/SystemWebMvc/Mvc/JavaScriptResult.cs
  135. +0 −2 MVC/src/SystemWebMvc/Mvc/JsonResult.cs
  136. +0 −2 MVC/src/SystemWebMvc/Mvc/ModelBinderAttribute.cs
  137. +0 −3 MVC/src/SystemWebMvc/Mvc/ModelBinderDictionary.cs
  138. +0 −1 MVC/src/SystemWebMvc/Mvc/ModelBinders.cs
  139. +0 −3 MVC/src/SystemWebMvc/Mvc/ModelBindingContext.cs
  140. +0 −4 MVC/src/SystemWebMvc/Mvc/ModelError.cs
  141. +0 −3 MVC/src/SystemWebMvc/Mvc/ModelErrorCollection.cs
  142. +0 −3 MVC/src/SystemWebMvc/Mvc/ModelState.cs
  143. +0 −3 MVC/src/SystemWebMvc/Mvc/ModelStateDictionary.cs
  144. +0 −2 MVC/src/SystemWebMvc/Mvc/MultiSelectList.cs
  145. +0 −2 MVC/src/SystemWebMvc/Mvc/MvcHandler.cs
  146. +0 −4 MVC/src/SystemWebMvc/Mvc/MvcHttpHandler.cs
  147. +0 −2 MVC/src/SystemWebMvc/Mvc/MvcRouteHandler.cs
  148. +0 −2 MVC/src/SystemWebMvc/Mvc/NameValueCollectionExtensions.cs
  149. +0 −2 MVC/src/SystemWebMvc/Mvc/NonActionAttribute.cs
  150. +0 −2 MVC/src/SystemWebMvc/Mvc/OutputCacheAttribute.cs
  151. +0 −4 MVC/src/SystemWebMvc/Mvc/ParameterBindingInfo.cs
  152. +0 −3 MVC/src/SystemWebMvc/Mvc/ParameterDescriptor.cs
  153. +0 −3 MVC/src/SystemWebMvc/Mvc/PartialViewResult.cs
  154. +85 −0 MVC/src/SystemWebMvc/Mvc/PathHelpers.cs
  155. +2 −4 MVC/src/SystemWebMvc/Mvc/RedirectResult.cs
  156. +4 −6 MVC/src/SystemWebMvc/Mvc/RedirectToRouteResult.cs
  157. +0 −3 MVC/src/SystemWebMvc/Mvc/ReflectedActionDescriptor.cs
  158. +0 −3 MVC/src/SystemWebMvc/Mvc/ReflectedControllerDescriptor.cs
  159. +0 −3 MVC/src/SystemWebMvc/Mvc/ReflectedParameterDescriptor.cs
  160. 0 MVC/src/SystemWebMvc/{ → Mvc}/Resources/MvcResources.Designer.cs
  161. 0 MVC/src/SystemWebMvc/{ → Mvc}/Resources/MvcResources.resx
  162. +0 −3 MVC/src/SystemWebMvc/Mvc/ResultExecutedContext.cs
  163. +0 −3 MVC/src/SystemWebMvc/Mvc/ResultExecutingContext.cs
  164. +0 −2 MVC/src/SystemWebMvc/Mvc/RouteCollectionExtensions.cs
  165. +14 −7 MVC/src/SystemWebMvc/Mvc/RouteValuesHelpers.cs
  166. +0 −2 MVC/src/SystemWebMvc/Mvc/SelectList.cs
  167. +0 −2 MVC/src/SystemWebMvc/Mvc/SelectListItem.cs
  168. +0 −4 MVC/src/SystemWebMvc/Mvc/SessionStateTempDataProvider.cs
  169. +0 −2 MVC/src/SystemWebMvc/Mvc/TagBuilder.cs
  170. +0 −3 MVC/src/SystemWebMvc/Mvc/TempDataDictionary.cs
  171. +25 −90 MVC/src/SystemWebMvc/Mvc/UrlHelper.cs
  172. +11 −11 MVC/src/SystemWebMvc/Mvc/ValidateAntiForgeryTokenAttribute.cs
  173. +0 −3 MVC/src/SystemWebMvc/Mvc/ValidateInputAttribute.cs
  174. +0 −3 MVC/src/SystemWebMvc/Mvc/ValueProviderDictionary.cs
  175. +0 −3 MVC/src/SystemWebMvc/Mvc/ValueProviderResult.cs
  176. +0 −3 MVC/src/SystemWebMvc/Mvc/ViewContext.cs
  177. +0 −3 MVC/src/SystemWebMvc/Mvc/ViewDataDictionary.cs
  178. +0 −2 MVC/src/SystemWebMvc/Mvc/ViewDataDictionary`1.cs
  179. +0 −4 MVC/src/SystemWebMvc/Mvc/ViewEngineCollection.cs
  180. +0 −3 MVC/src/SystemWebMvc/Mvc/ViewEngineResult.cs
  181. +0 −2 MVC/src/SystemWebMvc/Mvc/ViewEngines.cs
  182. +0 −2 MVC/src/SystemWebMvc/Mvc/ViewMasterPage.cs
  183. +0 −4 MVC/src/SystemWebMvc/Mvc/ViewMasterPage`1.cs
  184. +0 −34 MVC/src/SystemWebMvc/Mvc/ViewPage.cs
  185. +0 −4 MVC/src/SystemWebMvc/Mvc/ViewPage`1.cs
  186. +0 −3 MVC/src/SystemWebMvc/Mvc/ViewResult.cs
  187. +0 −2 MVC/src/SystemWebMvc/Mvc/ViewResultBase.cs
  188. +0 −2 MVC/src/SystemWebMvc/Mvc/ViewType.cs
  189. +0 −3 MVC/src/SystemWebMvc/Mvc/ViewUserControl.cs
  190. +0 −3 MVC/src/SystemWebMvc/Mvc/ViewUserControl`1.cs
  191. +0 −3 MVC/src/SystemWebMvc/Mvc/VirtualPathProviderViewEngine.cs
  192. +0 −3 MVC/src/SystemWebMvc/Mvc/WebFormView.cs
  193. +0 −2 MVC/src/SystemWebMvc/Mvc/WebFormViewEngine.cs
  194. +2 −1 MVC/src/SystemWebMvc/Properties/AssemblyInfo.cs
  195. +8 −7 MVC/src/SystemWebMvc/System.Web.Mvc.csproj
  196. +5 −32 MVC/test/MvcFuturesTest/Mvc/Controls/Test/DropDownListTest.cs
  197. +59 −0 MVC/test/MvcFuturesTest/Mvc/Test/AcceptAjaxAttributeTest.cs
  198. +40 −0 MVC/test/MvcFuturesTest/Mvc/Test/AjaxExtensionsTest.cs
  199. +85 −0 MVC/test/MvcFuturesTest/Mvc/Test/BinaryHtmlExtensionsTest.cs
  200. +1 −1 MVC/test/MvcFuturesTest/Mvc/Test/{ButtonTests.cs → ButtonTest.cs}
  201. +98 −0 MVC/test/MvcFuturesTest/Mvc/Test/ByteArrayModelBinderTest.cs
  202. +1 −1 MVC/test/MvcFuturesTest/Mvc/Test/{ContentTypeAttributeTests.cs → ContentTypeAttributeTest.cs}
  203. +1 −1 MVC/test/MvcFuturesTest/Mvc/Test/{CookieTempDataProviderTests.cs → CookieTempDataProviderTest.cs}
  204. +40 −8 MVC/test/MvcFuturesTest/Mvc/Test/{ExpressionHelperTests.cs → ExpressionHelperTest.cs}
  205. +188 −0 MVC/test/MvcFuturesTest/Mvc/Test/ExpressionInputExtensionsTest.cs
  206. +15 −2 MVC/test/MvcFuturesTest/Mvc/Test/ImageExtensionsTest.cs
  207. +1 −1 MVC/test/MvcFuturesTest/Mvc/Test/{MailToExtensionsTests.cs → MailToExtensionsTest.cs}
  208. +6 −6 MVC/test/MvcFuturesTest/Mvc/Test/ManualAsyncResultTest.cs
  209. +0 −191 MVC/test/MvcFuturesTest/Mvc/Test/PermissionTests.cs
  210. +1 −1 MVC/test/MvcFuturesTest/Mvc/Test/{RenderActionTests.cs → RenderActionTest.cs}
  211. +80 −0 MVC/test/MvcFuturesTest/Mvc/Test/RequireSslAttributeTest.cs
  212. +9 −2 MVC/test/MvcFuturesTest/Mvc/Test/SubmitImageExtensionsTest.cs
  213. +29 −33 MVC/test/MvcFuturesTest/Mvc/Test/{LinqBinaryModelBinderTests.cs → linqbinarymodelbindertest.cs}
  214. +13 −9 MVC/test/MvcFuturesTest/MvcFuturesTest.csproj
  215. +22 −1 MVC/test/SystemWebMvcTest/Mvc/{ → Ajax}/Test/AjaxExtensionsTest.cs
  216. +1 −2 MVC/test/SystemWebMvcTest/Mvc/{ → Ajax}/Test/AjaxOptionsTest.cs
  217. +44 −30 MVC/test/SystemWebMvcTest/Mvc/{Test/HtmlFormExtensionsTest.cs → Html/Test/FormExtensionsTest.cs}
  218. +25 −12 MVC/test/SystemWebMvcTest/Mvc/{Test/HtmlInputExtensionsTest.cs → Html/Test/InputExtensionsTest.cs}
  219. +16 −1 MVC/test/SystemWebMvcTest/Mvc/{Test/HtmlLinkExtensionsTest.cs → Html/Test/LinkExtensionsTest.cs}
  220. +1 −1 MVC/test/SystemWebMvcTest/Mvc/{ → Html}/Test/MvcFormTest.cs
  221. +1 −1 ...bMvcTest/Mvc/{Test/HtmlRenderPartialExtensionsTest.cs → Html/Test/RenderPartialExtensionsTest.cs}
  222. +27 −17 MVC/test/SystemWebMvcTest/Mvc/{Test/HtmlSelectExtensionsTest.cs → Html/Test/SelectExtensionsTest.cs}
  223. +1 −1 ...t/SystemWebMvcTest/Mvc/{Test/HtmlTextAreaExtensionsTest.cs → Html/Test/TextAreaExtensionsTest.cs}
  224. +41 −3 ...stemWebMvcTest/Mvc/{Test/HtmlValidationExtensionsTest.cs → Html/Test/ValidationExtensionsTest.cs}
  225. +1 −1 MVC/test/SystemWebMvcTest/Mvc/Test/AjaxRequestExtensionsTest.cs
  226. +9 −9 .../SystemWebMvcTest/Mvc/Test/{AntiForgeryTokenSerializerTest.cs → AntiForgeryDataSerializerTest.cs}
  227. +30 −8 MVC/test/SystemWebMvcTest/Mvc/Test/{AntiForgeryTokenTest.cs → AntiForgeryDataTest.cs}
  228. +0 −190 MVC/test/SystemWebMvcTest/Mvc/Test/AspNetHostingPermissionAttributeTest.cs
  229. +42 −24 MVC/test/SystemWebMvcTest/Mvc/Test/HtmlHelperTest.cs
  230. +228 −0 MVC/test/SystemWebMvcTest/Mvc/Test/PathHelpersTest.cs
  231. +22 −57 MVC/test/SystemWebMvcTest/Mvc/Test/UrlHelperTest.cs
  232. +13 −9 MVC/test/SystemWebMvcTest/Mvc/Test/ValidateAntiForgeryTokenAttributeTest.cs
  233. +0 −55 MVC/test/SystemWebMvcTest/Mvc/Test/ViewPageTest.cs
  234. +16 −16 MVC/test/SystemWebMvcTest/System.Web.Mvc.Test.csproj
  235. +2 −2 MVC/test/UnitTestUtil/UnitTestUtil.csproj
View
2 MVC/MVC.sln → MVC/MvcDev.sln
@@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Web.Mvc", "src\SystemWebMvc\System.Web.Mvc.csproj", "{3D3FFD8A-624D-4E9B-954B-E1C105507975}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{05D54317-D273-4B52-8F3A-027E049C4DB3}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Web.Mvc.Test", "test\SystemWebMvcTest\System.Web.Mvc.Test.csproj", "{8AC2A2E4-2F11-4D40-A887-62E2583A65E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestUtil", "test\UnitTestUtil\UnitTestUtil.csproj", "{57FFC134-7F9D-4B97-8692-8D2C16714663}"
View
8 MVC/src/MicrosoftMvcAjaxScript/Properties/Script.jst
@@ -1,5 +1,5 @@
-//----------------------------------------------------------
-// Copyright (C) Microsoft Corporation. All rights reserved.
-//----------------------------------------------------------
-// MicrosoftMvcAjax.js
+//!----------------------------------------------------------
+//! Copyright (C) Microsoft Corporation. All rights reserved.
+//!----------------------------------------------------------
+//! MicrosoftMvcAjax.js
#include[as-is] "%code%"
View
2 MVC/src/MvcFutures/Internal/ExpressionHelper.cs
@@ -2,12 +2,10 @@
using System;
using System.Linq.Expressions;
using System.Reflection;
- using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class ExpressionHelper {
public static RouteValueDictionary GetRouteValuesFromExpression<TController>(Expression<Action<TController>> action) where TController : Controller {
if (action == null) {
View
18 MVC/src/MvcFutures/Mvc/AcceptAjaxAttribute.cs
@@ -0,0 +1,18 @@
+namespace Microsoft.Web.Mvc {
+ using System;
+ using System.Reflection;
+ using System.Web.Mvc;
+
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
+ public sealed class AcceptAjaxAttribute : ActionMethodSelectorAttribute {
+
+ public override bool IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) {
+ if (controllerContext == null) {
+ throw new ArgumentNullException("controllerContext");
+ }
+
+ return controllerContext.HttpContext.Request.IsAjaxRequest();
+ }
+
+ }
+}
View
22 MVC/src/MvcFutures/Mvc/AjaxExtensions.cs
@@ -0,0 +1,22 @@
+namespace Microsoft.Web.Mvc {
+ using System;
+ using System.Text;
+ using System.Web;
+ using System.Web.Mvc;
+ using System.Web.Script.Serialization;
+
+ public static class AjaxExtensions {
+
+ public static string JavaScriptStringEncode(this AjaxHelper helper, string message) {
+ if (String.IsNullOrEmpty(message)) {
+ return message;
+ }
+
+ StringBuilder builder = new StringBuilder();
+ JavaScriptSerializer serializer = new JavaScriptSerializer();
+ serializer.Serialize(message, builder);
+ return builder.ToString(1, builder.Length - 2); // remove first + last quote
+ }
+
+ }
+}
View
3 MVC/src/MvcFutures/Mvc/AsyncActionDescriptor.cs
@@ -3,12 +3,9 @@
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
- using System.Web;
using System.Web.Mvc;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public abstract class AsyncActionDescriptor : ActionDescriptor, IAsyncActionDescriptor {
private readonly static MethodDispatcherCache _staticDispatcherCache = new MethodDispatcherCache();
View
2 MVC/src/MvcFutures/Mvc/AsyncCallback`1.cs
@@ -1,8 +1,6 @@
namespace Microsoft.Web.Mvc {
using System;
- using System.Web;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public delegate TResult AsyncCallback<TResult>(IAsyncResult ar);
}
View
3 MVC/src/MvcFutures/Mvc/AsyncController.cs
@@ -1,11 +1,8 @@
namespace Microsoft.Web.Mvc {
using System;
- using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public abstract class AsyncController : Controller, IAsyncController, IAsyncManagerContainer {
private delegate bool InvokeActionDelegate(ControllerContext controllerContext, string actionName);
View
2 MVC/src/MvcFutures/Mvc/AsyncControllerActionInvoker.cs
@@ -8,8 +8,6 @@
using System.Web.Mvc;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class AsyncControllerActionInvoker : ControllerActionInvoker, IAsyncActionInvoker {
private delegate object ExecuteDelegate(ControllerContext controllerContext, IDictionary<string, object> parameters);
View
3 MVC/src/MvcFutures/Mvc/AsyncManager.cs
@@ -2,11 +2,8 @@
using System;
using System.Collections.Generic;
using System.Threading;
- using System.Web;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class AsyncManager {
// default timeout is 30 sec
View
2 MVC/src/MvcFutures/Mvc/AsyncResultWrapper.cs
@@ -1,7 +1,6 @@
namespace Microsoft.Web.Mvc {
using System;
using System.Threading;
- using System.Web;
using Microsoft.Web.Resources;
// This class is used for the following pattern:
@@ -13,7 +12,6 @@
// That is, the EndOuter() method needs to perform some post-processing of the data returned by EndInner().
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class AsyncResultWrapper {
private static AsyncCallback<object> MakeGenericCallback(AsyncCallback callback) {
View
3 MVC/src/MvcFutures/Mvc/AsyncRouteCollectionExtensions.cs
@@ -1,11 +1,8 @@
namespace Microsoft.Web.Mvc {
- using System;
using System.Diagnostics.CodeAnalysis;
- using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class AsyncRouteCollectionExtensions {
[SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "2#",
View
4 MVC/src/MvcFutures/Mvc/AsyncTimeoutAttribute.cs
@@ -1,12 +1,10 @@
namespace Microsoft.Web.Mvc {
using System;
using System.Globalization;
- using System.Web;
using System.Web.Mvc;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class AsyncTimeoutAttribute : ActionFilterAttribute {
// duration is specified in seconds
View
2 MVC/src/MvcFutures/Mvc/BeginInvokeCallback.cs
@@ -1,8 +1,6 @@
namespace Microsoft.Web.Mvc {
using System;
- using System.Web;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public delegate IAsyncResult BeginInvokeCallback(AsyncCallback callback, object state);
}
View
30 MVC/src/MvcFutures/Mvc/BinaryHtmlExtensions.cs
@@ -0,0 +1,30 @@
+namespace Microsoft.Web.Mvc {
+ using System;
+ using System.Data.Linq;
+ using System.Linq.Expressions;
+ using System.Web.Mvc;
+ using System.Web.Mvc.Html;
+ using Microsoft.Web.Mvc.Internal;
+
+ public static class BinaryHtmlExtensions {
+ public static string Hidden(this HtmlHelper htmlHelper, string name, byte[] value) {
+ return htmlHelper.Hidden(name, Convert.ToBase64String(value));
+ }
+
+ public static string Hidden(this HtmlHelper htmlHelper, string name, Binary value) {
+ return htmlHelper.Hidden(name, value.ToArray());
+ }
+
+ public static string HiddenFor<TModel>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, byte[]>> expression) where TModel : class {
+ string inputName = ExpressionHelper.GetInputName(expression);
+ byte[] value = ExpressionInputExtensions.GetValue(htmlHelper, expression);
+ return htmlHelper.Hidden(inputName, value);
+ }
+
+ public static string HiddenFor<TModel>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, Binary>> expression) where TModel : class {
+ string inputName = ExpressionHelper.GetInputName(expression);
+ Binary value = ExpressionInputExtensions.GetValue(htmlHelper, expression);
+ return htmlHelper.Hidden(inputName, value.ToArray());
+ }
+ }
+}
View
2 MVC/src/MvcFutures/Mvc/ButtonBuilder.cs
@@ -1,10 +1,8 @@
namespace Microsoft.Web.Mvc {
using System;
using System.Collections.Generic;
- using System.Web;
using System.Web.Mvc;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class ButtonBuilder {
public static TagBuilder SubmitButton(string name, string buttonText, IDictionary<string, object> htmlAttributes) {
TagBuilder buttonTag = new TagBuilder("input");
View
2 MVC/src/MvcFutures/Mvc/ButtonsAndLinkExtensions.cs
@@ -1,11 +1,9 @@
namespace Microsoft.Web.Mvc {
using System;
using System.Collections.Generic;
- using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class ButtonsAndLinkExtensions {
/// <summary>
/// Creates a submit button for your form
View
31 MVC/src/MvcFutures/Mvc/ByteArrayModelBinder.cs
@@ -0,0 +1,31 @@
+namespace Microsoft.Web.Mvc {
+ using System;
+ using System.Web.Mvc;
+
+ // Register via a call in Global.asax.cs to
+ // ModelBinders.Binders.Add(typeof(byte[]), new ByteArrayModelBinder());
+ public class ByteArrayModelBinder : IModelBinder {
+ public virtual object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
+ ValueProviderResult valueResult;
+ bindingContext.ValueProvider.TryGetValue(bindingContext.ModelName, out valueResult);
+
+ // case 1: there was no <input ... /> element containing this data
+ if (valueResult == null) {
+ return null;
+ }
+
+ string value = valueResult.AttemptedValue;
+
+ // case 2: there was an <input ... /> element but it was left blank
+ if (String.IsNullOrEmpty(value)) {
+ return null;
+ }
+
+ // Future proofing. If the byte array is actually an instance of System.Data.Linq.Binary
+ // then we need to remove these quotes put in place by the ToString() method.
+ string realValue = value.Replace("\"", String.Empty);
+ return Convert.FromBase64String(realValue);
+ }
+ }
+
+}
View
1 MVC/src/MvcFutures/Mvc/CacheExtensions.cs
@@ -2,7 +2,6 @@
using System.Web;
using System.Web.Mvc;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class CacheExtensions {
public static object Substitute(this HtmlHelper html, MvcSubstitutionCallback substitutionCallback) {
html.ViewContext.HttpContext.Response.WriteSubstitution(httpContext => substitutionCallback(new HttpContextWrapper(httpContext)));
View
3 MVC/src/MvcFutures/Mvc/ContentTypeAttribute.cs
@@ -1,11 +1,8 @@
namespace Microsoft.Web.Mvc {
using System;
using System.Web.Mvc;
- using System.Web;
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ContentTypeAttribute : ActionFilterAttribute {
public ContentTypeAttribute(string contentType) {
if (String.IsNullOrEmpty(contentType)) {
View
3 MVC/src/MvcFutures/Mvc/Controls/ActionLink.cs
@@ -1,14 +1,11 @@
namespace Microsoft.Web.Mvc.Controls {
using System;
using System.ComponentModel;
- using System.Web;
using System.Web.Routing;
using System.Web.UI;
[ParseChildren(true)]
[PersistChildren(false)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ActionLink : MvcControl {
private string _actionName;
private string _controllerName;
View
146 MVC/src/MvcFutures/Mvc/Controls/DropDownList.cs
@@ -1,18 +1,20 @@
namespace Microsoft.Web.Mvc.Controls {
using System;
+ using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
- using System.Web;
+ using System.Globalization;
+ using System.Linq;
using System.Web.Mvc;
using System.Web.UI;
+ using Microsoft.Web.Resources;
// TODO: Have ListBoxBase class to use with DropDownList and ListBox?
// TODO: Do we need a way to explicitly specify the items? And only get the selected value(s) from ViewData?
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DropDownList : MvcControl {
private string _name;
+ private string _optionLabel;
[DefaultValue("")]
public string Name {
@@ -24,38 +26,135 @@ public class DropDownList : MvcControl {
}
}
- protected override void Render(HtmlTextWriter writer) {
- if (!DesignMode && String.IsNullOrEmpty(Name)) {
- throw new InvalidOperationException("The Name property must be specified.");
+ [DefaultValue("")]
+ public string OptionLabel {
+ get {
+ return _optionLabel ?? String.Empty;
+ }
+ set {
+ _optionLabel = value;
}
+ }
- foreach (var attribute in Attributes) {
- writer.AddAttribute(attribute.Key, attribute.Value);
+ private object GetModelStateValue(string key, Type destinationType) {
+ ModelState modelState;
+ if (ViewData.ModelState.TryGetValue(key, out modelState)) {
+ return modelState.Value.ConvertTo(destinationType, null /* culture */);
}
+ return null;
+ }
- if (!Attributes.ContainsKey("name")) {
- if (!String.IsNullOrEmpty(Name)) {
- writer.AddAttribute(HtmlTextWriterAttribute.Name, Name);
- }
+ private IEnumerable<SelectListItem> GetSelectData(string name) {
+ object o = null;
+ if (ViewData != null) {
+ o = ViewData.Eval(name);
}
- if (!Attributes.ContainsKey("id")) {
- if (!String.IsNullOrEmpty(Name)) {
- writer.AddAttribute(HtmlTextWriterAttribute.Id, Name);
- }
+ if (o == null) {
+ throw new InvalidOperationException(
+ String.Format(
+ CultureInfo.CurrentUICulture,
+ MvcResources.HtmlHelper_MissingSelectData,
+ name,
+ "IEnumerable<SelectListItem>"));
+ }
+ IEnumerable<SelectListItem> selectList = o as IEnumerable<SelectListItem>;
+ if (selectList == null) {
+ throw new InvalidOperationException(
+ String.Format(
+ CultureInfo.CurrentUICulture,
+ MvcResources.HtmlHelper_WrongSelectDataType,
+ name,
+ o.GetType().FullName,
+ "IEnumerable<SelectListItem>"));
}
+ return selectList;
+ }
- writer.RenderBeginTag(HtmlTextWriterTag.Select);
+ protected override void Render(HtmlTextWriter writer) {
+ if (!DesignMode && String.IsNullOrEmpty(Name)) {
+ throw new InvalidOperationException(MvcResources.CommonControls_NameRequired);
+ }
if (DesignMode) {
+ writer.RenderBeginTag(HtmlTextWriterTag.Select);
writer.RenderBeginTag(HtmlTextWriterTag.Option);
- writer.WriteEncodedText("Sample Item");
+ if (String.IsNullOrEmpty(OptionLabel)) {
+ writer.WriteEncodedText("Sample Item");
+ }
+ else {
+ writer.WriteEncodedText(OptionLabel);
+ }
+ writer.RenderEndTag();
writer.RenderEndTag();
}
else {
- IEnumerable<SelectListItem> items = ListBoxHelper.GetSelectData<SelectList>(ViewData, Name);
+ // TODO: Move this to the base class once it exists
+ bool allowMultiple = false;
- foreach (var listItem in items) {
- if (!String.IsNullOrEmpty(listItem.Value)) {
+ SortedDictionary<string, string> attrs = new SortedDictionary<string, string>();
+
+ foreach (KeyValuePair<string, string> attribute in Attributes) {
+ attrs.Add(attribute.Key, attribute.Value);
+ }
+
+ attrs.Add("name", Name);
+ if (!String.IsNullOrEmpty(ID)) {
+ attrs.Add("id", ID);
+ }
+ if (allowMultiple) {
+ attrs.Add("multiple", "multiple");
+ }
+
+ // If there are any errors for a named field, we add the css attribute.
+ ModelState modelState;
+ if (ViewData.ModelState.TryGetValue(Name, out modelState)) {
+ if (modelState.Errors.Count > 0) {
+ string currentValue;
+
+ if (attrs.TryGetValue("class", out currentValue)) {
+ attrs["class"] = HtmlHelper.ValidationInputCssClassName + " " + currentValue;
+ }
+ else {
+ attrs["class"] = HtmlHelper.ValidationInputCssClassName;
+ }
+ }
+ }
+
+ foreach (KeyValuePair<string, string> attribute in attrs) {
+ writer.AddAttribute(attribute.Key, Convert.ToString(attribute.Value, CultureInfo.CurrentCulture));
+ }
+
+ writer.RenderBeginTag(HtmlTextWriterTag.Select);
+
+ // Use ViewData to get the list of items
+ IEnumerable<SelectListItem> selectList = GetSelectData(Name);
+
+ object defaultValue = (allowMultiple) ? GetModelStateValue(Name, typeof(string[])) : GetModelStateValue(Name, typeof(string));
+
+ if (defaultValue != null) {
+ IEnumerable defaultValues = (allowMultiple) ? defaultValue as IEnumerable : new[] { defaultValue };
+ IEnumerable<string> values = from object value in defaultValues select Convert.ToString(value, CultureInfo.CurrentCulture);
+ HashSet<string> selectedValues = new HashSet<string>(values, StringComparer.OrdinalIgnoreCase);
+ List<SelectListItem> newSelectList = new List<SelectListItem>();
+
+ foreach (SelectListItem item in selectList) {
+ item.Selected = (item.Value != null) ? selectedValues.Contains(item.Value) : selectedValues.Contains(item.Text);
+ newSelectList.Add(item);
+ }
+ selectList = newSelectList;
+ }
+
+ // Render the option label if it exists
+ if (!String.IsNullOrEmpty(OptionLabel)) {
+ writer.AddAttribute(HtmlTextWriterAttribute.Value, String.Empty);
+ writer.RenderBeginTag(HtmlTextWriterTag.Option);
+ writer.WriteEncodedText(OptionLabel);
+ writer.RenderEndTag();
+ }
+
+ // Render out the list items
+ foreach (SelectListItem listItem in selectList) {
+ if (listItem.Value != null) {
writer.AddAttribute(HtmlTextWriterAttribute.Value, listItem.Value);
}
if (listItem.Selected) {
@@ -65,9 +164,10 @@ public class DropDownList : MvcControl {
writer.WriteEncodedText(listItem.Text);
writer.RenderEndTag();
}
- }
- writer.RenderEndTag();
+
+ writer.RenderEndTag();
+ }
}
}
}
View
3 MVC/src/MvcFutures/Mvc/Controls/Hidden.cs
@@ -1,8 +1,5 @@
namespace Microsoft.Web.Mvc.Controls {
- using System.Web;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class Hidden : MvcInputControl {
public Hidden() :
base("hidden") {
View
45 MVC/src/MvcFutures/Mvc/Controls/Label.cs
@@ -4,10 +4,10 @@
using System.Globalization;
using System.Web;
using System.Web.UI;
+ using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class Label : MvcControl {
+ private string _format;
private string _name;
private int _truncateLength = -1;
private string _truncateText = "...";
@@ -19,6 +19,16 @@ public class Label : MvcControl {
}
[DefaultValue("")]
+ public string Format {
+ get {
+ return _format ?? String.Empty;
+ }
+ set {
+ _format = value;
+ }
+ }
+
+ [DefaultValue("")]
public string Name {
get {
return _name ?? String.Empty;
@@ -55,36 +65,41 @@ public class Label : MvcControl {
protected override void Render(HtmlTextWriter writer) {
if (!DesignMode && String.IsNullOrEmpty(Name)) {
- throw new InvalidOperationException("The Name property must be specified.");
+ throw new InvalidOperationException(MvcResources.CommonControls_NameRequired);
}
- string value = String.Empty;
+ string stringValue = String.Empty;
if (ViewData != null) {
- value = Convert.ToString(ViewData.Eval(Name), CultureInfo.InvariantCulture);
- }
+ object rawValue = ViewData.Eval(Name);
- if (!Attributes.ContainsKey("name")) {
- writer.AddAttribute(HtmlTextWriterAttribute.Name, Name);
+ if (String.IsNullOrEmpty(Format)) {
+ stringValue = Convert.ToString(rawValue, CultureInfo.CurrentCulture);
+ }
+ else {
+ stringValue = String.Format(CultureInfo.CurrentCulture, Format, rawValue);
+ }
}
- if (!Attributes.ContainsKey("id")) {
- writer.AddAttribute(HtmlTextWriterAttribute.Id, Name);
+
+ writer.AddAttribute(HtmlTextWriterAttribute.Name, Name);
+ if (!String.IsNullOrEmpty(ID)) {
+ writer.AddAttribute(HtmlTextWriterAttribute.Id, ID);
}
bool wasTruncated = false;
- if ((TruncateLength >= 0) && (value.Length > TruncateLength)) {
- value = value.Substring(0, TruncateLength);
+ if ((TruncateLength >= 0) && (stringValue.Length > TruncateLength)) {
+ stringValue = stringValue.Substring(0, TruncateLength);
wasTruncated = true;
}
switch (EncodeType) {
case EncodeType.Html:
- writer.Write(HttpUtility.HtmlEncode(value));
+ writer.Write(HttpUtility.HtmlEncode(stringValue));
break;
case EncodeType.HtmlAttribute:
- writer.Write(HttpUtility.HtmlAttributeEncode(value));
+ writer.Write(HttpUtility.HtmlAttributeEncode(stringValue));
break;
case EncodeType.None:
- writer.Write(value);
+ writer.Write(stringValue);
break;
}
View
35 MVC/src/MvcFutures/Mvc/Controls/ListBoxHelper.cs
@@ -1,35 +0,0 @@
-namespace Microsoft.Web.Mvc.Controls {
- using System;
- using System.Globalization;
- using System.Web;
- using System.Web.Mvc;
-
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- public static class ListBoxHelper {
- public static TList GetSelectData<TList>(ViewDataDictionary viewData, string name) where TList : MultiSelectList {
- object o = null;
- if (viewData != null) {
- o = viewData.Eval(name);
- }
- if (o == null) {
- throw new InvalidOperationException(
- String.Format(
- CultureInfo.CurrentUICulture,
- "There is no ViewData item with the key '{0}' of type '{1}'.",
- name,
- typeof(TList)));
- }
- TList selectList = o as TList;
- if (selectList == null) {
- throw new InvalidOperationException(
- String.Format(
- CultureInfo.CurrentUICulture,
- "The ViewData item with the key '{0}' is of type '{1}' but needs to be of type '{2}'.",
- name,
- o.GetType().FullName,
- typeof(TList)));
- }
- return selectList;
- }
- }
-}
View
6 MVC/src/MvcFutures/Mvc/Controls/MvcControl.cs
@@ -2,15 +2,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
- using System.Web;
using System.Web.Mvc;
using System.Web.UI;
// TODO: Consider using custom HTML writer instead of the default one to get prettier rendering
- // TOOD: Should the attributes be in a list instead of a dictionary? The unit tests can break if the order changes
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public abstract class MvcControl : Control, IAttributeAccessor {
private IDictionary<string, string> _attributes;
private IViewDataContainer _viewDataContainer;
@@ -78,7 +74,7 @@ public abstract class MvcControl : Control, IAttributeAccessor {
private void EnsureAttributes() {
if (_attributes == null) {
- _attributes = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+ _attributes = new SortedDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
}
View
96 MVC/src/MvcFutures/Mvc/Controls/MvcInputControl.cs
@@ -1,22 +1,33 @@
namespace Microsoft.Web.Mvc.Controls {
using System;
+ using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
- using System.Web;
+ using System.Web.Mvc;
using System.Web.UI;
+ using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public abstract class MvcInputControl : MvcControl {
+ private string _format;
private string _name;
protected MvcInputControl(string inputType) {
if (String.IsNullOrEmpty(inputType)) {
- throw new ArgumentException("Null or empty", "inputType");
+ throw new ArgumentException(MvcResources.Common_NullOrEmpty, "inputType");
}
InputType = inputType;
}
+ [DefaultValue("")]
+ public string Format {
+ get {
+ return _format ?? String.Empty;
+ }
+ set {
+ _format = value;
+ }
+ }
+
[Browsable(false)]
public string InputType {
get;
@@ -33,40 +44,85 @@ public abstract class MvcInputControl : MvcControl {
}
}
+ private ModelState GetModelState() {
+ return ViewData.ModelState[Name];
+ }
+
+ private object GetModelStateValue(string key, Type destinationType) {
+ ModelState modelState = GetModelState();
+ if (modelState != null) {
+ return modelState.Value.ConvertTo(destinationType, null /* culture */);
+ }
+ return null;
+ }
+
protected override void Render(HtmlTextWriter writer) {
if (!DesignMode && String.IsNullOrEmpty(Name)) {
- throw new InvalidOperationException("The Name property must be specified.");
+ throw new InvalidOperationException(MvcResources.CommonControls_NameRequired);
}
- foreach (var attribute in Attributes) {
- writer.AddAttribute(attribute.Key, attribute.Value);
+ SortedDictionary<string, string> attrs = new SortedDictionary<string, string>();
+
+ foreach (KeyValuePair<string, string> attribute in Attributes) {
+ attrs.Add(attribute.Key, attribute.Value);
}
if (!Attributes.ContainsKey("type")) {
- writer.AddAttribute(HtmlTextWriterAttribute.Type, InputType);
+ attrs.Add("type", InputType);
}
- if (!Attributes.ContainsKey("name")) {
- writer.AddAttribute(HtmlTextWriterAttribute.Name, Name);
+ attrs.Add("name", Name);
+ if (!String.IsNullOrEmpty(ID)) {
+ attrs.Add("id", ID);
}
- if (!Attributes.ContainsKey("id")) {
- writer.AddAttribute(HtmlTextWriterAttribute.Id, Name);
+
+
+ if (DesignMode) {
+ // Use a dummy value in design mode
+ attrs.Add("value", "TextBox");
}
+ else {
+ string attemptedValue = (string)GetModelStateValue(Name, typeof(string));
- if (!Attributes.ContainsKey("value")) {
- string value = null;
- if (DesignMode) {
- value = "Text";
+ if (attemptedValue != null) {
+ // Never format the attempted value since it was already formatted in the previous request
+ attrs.Add("value", attemptedValue);
}
else {
- if (ViewData != null) {
- value = Convert.ToString(ViewData.Eval(Name), CultureInfo.InvariantCulture);
+ // Use an explicit value attribute if it is available. Otherwise get it from ViewData.
+ string attributeValue;
+ Attributes.TryGetValue("value", out attributeValue);
+ object rawValue = attributeValue ?? ViewData.Eval(Name);
+ string stringValue;
+
+ if (String.IsNullOrEmpty(Format)) {
+ stringValue = Convert.ToString(rawValue, CultureInfo.CurrentCulture);
+ }
+ else {
+ stringValue = String.Format(CultureInfo.CurrentCulture, Format, rawValue);
}
+
+ // The HtmlTextWriter will automatically encode this value
+ attrs.Add("value", stringValue);
}
- if (!String.IsNullOrEmpty(value)) {
- writer.AddAttribute(HtmlTextWriterAttribute.Value, value);
+
+ // If there are any errors for a named field, we add the CSS attribute.
+ ModelState modelState = GetModelState();
+ if ((modelState != null) && (modelState.Errors.Count > 0)) {
+ string currentValue;
+
+ if (attrs.TryGetValue("class", out currentValue)) {
+ attrs["class"] = HtmlHelper.ValidationInputCssClassName + " " + currentValue;
+ }
+ else {
+ attrs["class"] = HtmlHelper.ValidationInputCssClassName;
+ }
}
}
+ foreach (KeyValuePair<string, string> attribute in attrs) {
+ writer.AddAttribute(attribute.Key, Convert.ToString(attribute.Value, CultureInfo.CurrentCulture));
+ }
+
writer.RenderBeginTag(HtmlTextWriterTag.Input);
writer.RenderEndTag();
View
3 MVC/src/MvcFutures/Mvc/Controls/Password.cs
@@ -1,8 +1,5 @@
namespace Microsoft.Web.Mvc.Controls {
- using System.Web;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class Password : MvcInputControl {
public Password() :
base("password") {
View
5 MVC/src/MvcFutures/Mvc/Controls/Repeater.cs
@@ -2,14 +2,11 @@
using System;
using System.Collections;
using System.ComponentModel;
- using System.Web;
using System.Web.Mvc;
using System.Web.UI;
[ParseChildren(true)]
[PersistChildren(false)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class Repeater : MvcControl {
private string _name;
@@ -60,6 +57,8 @@ public class Repeater : MvcControl {
};
ItemTemplate.InstantiateIn(repeaterItem);
containerControl.Controls.Add(repeaterItem);
+
+ index++;
}
}
View
3 MVC/src/MvcFutures/Mvc/Controls/RepeaterItem.cs
@@ -1,10 +1,7 @@
namespace Microsoft.Web.Mvc.Controls {
- using System.Web;
using System.Web.Mvc;
using System.Web.UI;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class RepeaterItem : Control, IDataItemContainer, IViewDataContainer {
private object _dataItem;
private int _itemIndex;
View
7 MVC/src/MvcFutures/Mvc/Controls/RouteValues.cs
@@ -1,13 +1,8 @@
namespace Microsoft.Web.Mvc.Controls {
using System;
using System.Collections.Generic;
- using System.Web;
using System.Web.UI;
- // TOOD: Should the attributes be in a list instead of a dictionary? The unit tests can break if the order changes
-
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class RouteValues : IAttributeAccessor {
private IDictionary<string, string> _attributes;
@@ -20,7 +15,7 @@ public class RouteValues : IAttributeAccessor {
private void EnsureAttributes() {
if (_attributes == null) {
- _attributes = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
+ _attributes = new SortedDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
}
View
3 MVC/src/MvcFutures/Mvc/Controls/TextBox.cs
@@ -1,8 +1,5 @@
namespace Microsoft.Web.Mvc.Controls {
- using System.Web;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class TextBox : MvcInputControl {
public TextBox() :
base("text") {
View
2 MVC/src/MvcFutures/Mvc/CookieTempDataProvider.cs
@@ -6,8 +6,6 @@
using System.Web;
using System.Web.Mvc;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class CookieTempDataProvider : ITempDataProvider {
internal const string TempDataCookieKey = "__ControllerTempData";
HttpContextBase _httpContext;
View
65 MVC/src/MvcFutures/Mvc/ExpressionInputExtensions.cs
@@ -3,19 +3,17 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq.Expressions;
- using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
using Microsoft.Web.Mvc.Internal;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class ExpressionInputExtensions {
private const int TextAreaRows = 2;
private const int TextAreaColumns = 20;
public static string TextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) where TModel : class {
- return htmlHelper.TextBoxFor(expression, new RouteValueDictionary());
+ return htmlHelper.TextBoxFor(expression, (IDictionary<string, object>)null);
}
public static string TextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) where TModel : class {
@@ -33,7 +31,7 @@ public static class ExpressionInputExtensions {
}
public static string TextAreaFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) where TModel : class {
- return htmlHelper.TextAreaFor(expression, TextAreaRows, TextAreaColumns, new RouteValueDictionary());
+ return htmlHelper.TextAreaFor(expression, TextAreaRows, TextAreaColumns, (IDictionary<string, object>)null);
}
public static string TextAreaFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) where TModel : class {
@@ -54,7 +52,64 @@ public static class ExpressionInputExtensions {
return htmlHelper.TextArea(inputName, Convert.ToString(value, CultureInfo.CurrentCulture), rows, columns, htmlAttributes);
}
- private static TProperty GetValue<TModel, TProperty>(HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) where TModel : class {
+ public static string HiddenFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) where TModel : class {
+ return htmlHelper.HiddenFor(expression, (IDictionary<string, object>)null);
+ }
+
+ public static string HiddenFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) where TModel : class {
+ return htmlHelper.HiddenFor(expression, new RouteValueDictionary(htmlAttributes));
+ }
+
+ public static string HiddenFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IDictionary<string, object> htmlAttributes) where TModel : class {
+ string inputName = ExpressionHelper.GetInputName(expression);
+ TProperty value = GetValue(htmlHelper, expression);
+ return htmlHelper.Hidden(inputName, value, htmlAttributes);
+ }
+
+ public static string DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList) where TModel : class {
+ return htmlHelper.DropDownListFor(expression, selectList, (IDictionary<string, object>)null);
+ }
+
+ public static string DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, object htmlAttributes) where TModel : class {
+ return htmlHelper.DropDownListFor(expression, selectList, new RouteValueDictionary(htmlAttributes));
+ }
+
+ public static string DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes) where TModel : class {
+ string inputName = ExpressionHelper.GetInputName(expression);
+ return htmlHelper.DropDownList(inputName, selectList, htmlAttributes);
+ }
+
+ public static string DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel) where TModel : class {
+ return htmlHelper.DropDownListFor(expression, selectList, optionLabel, (IDictionary<string, object>)null);
+ }
+
+ public static string DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel, object htmlAttributes) where TModel : class {
+ return htmlHelper.DropDownListFor(expression, selectList, optionLabel, new RouteValueDictionary(htmlAttributes));
+ }
+
+ public static string DropDownListFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, string optionLabel, IDictionary<string, object> htmlAttributes) where TModel : class {
+ string inputName = ExpressionHelper.GetInputName(expression);
+ return htmlHelper.DropDownList(inputName, selectList, optionLabel, htmlAttributes);
+ }
+
+ public static string ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) where TModel : class {
+ return htmlHelper.ValidationMessageFor(expression, null, (IDictionary<string, object>)null);
+ }
+
+ public static string ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string message) where TModel : class {
+ return htmlHelper.ValidationMessageFor(expression, message, (IDictionary<string, object>)null);
+ }
+
+ public static string ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string message, object htmlAttributes) where TModel : class {
+ return htmlHelper.ValidationMessageFor(expression, message, new RouteValueDictionary(htmlAttributes));
+ }
+
+ public static string ValidationMessageFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string message, IDictionary<string, object> htmlAttributes) where TModel : class {
+ string inputName = ExpressionHelper.GetInputName(expression);
+ return htmlHelper.ValidationMessage(inputName, message, htmlAttributes);
+ }
+
+ internal static TProperty GetValue<TModel, TProperty>(HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) where TModel : class {
TModel model = htmlHelper.ViewData.Model;
if (model == null) {
return default(TProperty);
View
2 MVC/src/MvcFutures/Mvc/FileCollectionModelBinder.cs
@@ -8,8 +8,6 @@
using System.Web.Mvc;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class FileCollectionModelBinder : IModelBinder {
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
View
1 MVC/src/MvcFutures/Mvc/FormExtensions.cs
@@ -8,7 +8,6 @@
using System.Web.Mvc.Html;
using System.Web.Routing;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class FormExtensions {
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an Extension Method which allows the user to provide a strongly-typed argument via Expression")]
public static MvcForm BeginForm<TController>(this HtmlHelper helper, Expression<Action<TController>> action) where TController : Controller {
View
3 MVC/src/MvcFutures/Mvc/IAsyncActionDescriptor.cs
@@ -1,11 +1,8 @@
namespace Microsoft.Web.Mvc {
using System;
using System.Collections.Generic;
- using System.Web;
using System.Web.Mvc;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IAsyncActionDescriptor {
IAsyncResult BeginExecute(ControllerContext controllerContext, IDictionary<string, object> parameters, AsyncCallback callback, object state);
View
3 MVC/src/MvcFutures/Mvc/IAsyncActionInvoker.cs
@@ -1,10 +1,7 @@
namespace Microsoft.Web.Mvc {
using System;
- using System.Web;
using System.Web.Mvc;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IAsyncActionInvoker : IActionInvoker {
IAsyncResult BeginInvokeAction(ControllerContext controllerContext, string actionName, AsyncCallback callback, object state);
View
3 MVC/src/MvcFutures/Mvc/IAsyncController.cs
@@ -1,11 +1,8 @@
namespace Microsoft.Web.Mvc {
using System;
- using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IAsyncController : IController {
IAsyncResult BeginExecute(RequestContext requestContext, AsyncCallback callback, object state);
View
4 MVC/src/MvcFutures/Mvc/IAsyncManagerContainer.cs
@@ -1,9 +1,5 @@
namespace Microsoft.Web.Mvc {
- using System;
- using System.Web;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IAsyncManagerContainer {
AsyncManager AsyncManager {
View
2 MVC/src/MvcFutures/Mvc/ImageExtensions.cs
@@ -1,12 +1,10 @@
namespace Microsoft.Web.Mvc {
using System;
using System.Collections.Generic;
- using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class ImageExtensions {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings", MessageId = "1#", Justification = "The return value is not a regular URL since it may contain ~/ ASP.NET-specific characters")]
public static string Image(this HtmlHelper helper, string imageRelativeUrl) {
View
2 MVC/src/MvcFutures/Mvc/LinkBuilder.cs
@@ -2,12 +2,10 @@
using System;
using System.Linq.Expressions;
using System.Reflection;
- using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Microsoft.Web.Mvc.Internal;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class LinkBuilder {
/// <summary>
/// Builds a URL based on the Expression passed in
View
2 MVC/src/MvcFutures/Mvc/LinkExtensions.cs
@@ -1,13 +1,11 @@
namespace Microsoft.Web.Mvc {
using System;
using System.Linq.Expressions;
- using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
using Microsoft.Web.Mvc.Internal;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class LinkExtensions {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1055:UriReturnValuesShouldNotBeStrings", Justification = "This is a UI method and is required to use strings as Uri"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "This is an Extension Method which allows the user to provide a strongly-typed argument via Expression")]
public static string BuildUrlFromExpression<TController>(this HtmlHelper helper, Expression<Action<TController>> action) where TController : Controller {
View
30 MVC/src/MvcFutures/Mvc/LinqBinaryModelBinder.cs
@@ -1,35 +1,17 @@
namespace Microsoft.Web.Mvc {
- using System;
using System.Data.Linq;
- using System.Web;
using System.Web.Mvc;
-
+
// Register via a call in Global.asax.cs to
// ModelBinders.Binders.Add(typeof(Binary), new LinqBinaryModelBinder());
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- public class LinqBinaryModelBinder : IModelBinder {
- public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
- ValueProviderResult valueResult;
- bindingContext.ValueProvider.TryGetValue(bindingContext.ModelName, out valueResult);
-
- // case 1: there was no <input ... /> element containing this data
- if (valueResult == null) {
- return null;
- }
-
- string value = valueResult.AttemptedValue;
-
- // case 2: there was an <input ... /> element but it was left blank
- if (String.IsNullOrEmpty(value)) {
+ public class LinqBinaryModelBinder : ByteArrayModelBinder {
+ public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) {
+ byte[] byteValue = (byte[])base.BindModel(controllerContext, bindingContext);
+ if (byteValue == null) {
return null;
}
- // Future proofing. Right now, Binary.ToString() includes quotes around
- // the base64 encoded value. This may get fixed in the future.
- string realValue = value.Replace("\"", string.Empty);
- var byteValue = new Binary(Convert.FromBase64String(realValue));
- return byteValue;
+ return new Binary(byteValue);
}
}
}
View
3 MVC/src/MvcFutures/Mvc/MailToExtensions.cs
@@ -1,12 +1,9 @@
namespace Microsoft.Web.Mvc {
using System;
- using System.Linq;
using System.Collections.Generic;
- using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class MailToExtensions {
public static string Mailto(this HtmlHelper helper, string linkText, string emailAddress) {
return Mailto(helper, linkText, emailAddress, null, null, null, null, (IDictionary<string, object>)null);
View
2 MVC/src/MvcFutures/Mvc/MvcAsyncHandler.cs
@@ -7,8 +7,6 @@
using System.Web.Routing;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class MvcAsyncHandler : MvcHandler, IHttpAsyncHandler {
private delegate void ExecuteDelegate(RequestContext requestContext);
View
3 MVC/src/MvcFutures/Mvc/MvcAsyncRouteHandler.cs
@@ -1,11 +1,8 @@
namespace Microsoft.Web.Mvc {
- using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class MvcAsyncRouteHandler : MvcRouteHandler {
protected override IHttpHandler GetHttpHandler(RequestContext requestContext) {
View
2 MVC/src/MvcFutures/Mvc/MvcHttpAsyncHandler.cs
@@ -4,8 +4,6 @@
using System.Web;
using System.Web.Mvc;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class MvcHttpAsyncHandler : MvcHttpHandler, IHttpAsyncHandler {
private delegate void ProcessRequestDelegate(HttpContext context);
View
1 MVC/src/MvcFutures/Mvc/MvcSubstitutionCallback.cs
@@ -1,6 +1,5 @@
namespace Microsoft.Web.Mvc {
using System.Web;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public delegate string MvcSubstitutionCallback(HttpContextBase httpContext);
}
View
3 MVC/src/MvcFutures/Mvc/NoAsyncTimeoutAttribute.cs
@@ -1,9 +1,6 @@
namespace Microsoft.Web.Mvc {
- using System;
using System.Threading;
- using System.Web;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class NoAsyncTimeoutAttribute : AsyncTimeoutAttribute {
public NoAsyncTimeoutAttribute()
View
2 MVC/src/MvcFutures/Mvc/ObjectAsyncResult`1.cs
@@ -1,13 +1,11 @@
namespace Microsoft.Web.Mvc {
using System;
- using System.Web;
using System.Threading;
// This class is used to generate a Begin/End wrapper that returns a known object.
// Default implementation uses built-in BeginInvoke / EndInvoke - we need to check performance
// of these built-in methods.
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class ObjectAsyncResult<T> {
private readonly Func<T> _itemThunk;
View
3 MVC/src/MvcFutures/Mvc/OutstandingAsyncOperations.cs
@@ -1,10 +1,7 @@
namespace Microsoft.Web.Mvc {
using System;
using System.Threading;
- using System.Web;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class OutstandingAsyncOperations {
private int _count;
View
2 MVC/src/MvcFutures/Mvc/RadioExtensions.cs
@@ -4,13 +4,11 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
- using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class RadioListExtensions {
public static string[] RadioButtonList(this HtmlHelper htmlHelper, string name) {
return RadioButtonList(htmlHelper, name, (IDictionary<string, object>)null);
View
3 MVC/src/MvcFutures/Mvc/ReflectedAsyncControllerDescriptor.cs
@@ -1,11 +1,8 @@
namespace Microsoft.Web.Mvc {
using System;
- using System.Web;
using System.Web.Mvc;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ReflectedAsyncControllerDescriptor : ControllerDescriptor {
private static readonly ActionDescriptor[] _emptyCanonicalActions = new ActionDescriptor[0];
View
3 MVC/src/MvcFutures/Mvc/ReflectedAsyncPatternActionDescriptor.cs
@@ -5,12 +5,9 @@
using System.Linq;
using System.Reflection;
using System.Threading;
- using System.Web;
using System.Web.Mvc;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ReflectedAsyncPatternActionDescriptor : AsyncActionDescriptor {
private readonly string _actionName;
View
3 MVC/src/MvcFutures/Mvc/ReflectedDelegatePatternActionDescriptor.cs
@@ -5,12 +5,9 @@
using System.Linq;
using System.Reflection;
using System.Threading;
- using System.Web;
using System.Web.Mvc;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ReflectedDelegatePatternActionDescriptor : AsyncActionDescriptor {
private readonly string _actionName;
View
3 MVC/src/MvcFutures/Mvc/ReflectedEventPatternActionDescriptor.cs
@@ -5,12 +5,9 @@
using System.Linq;
using System.Reflection;
using System.Threading;
- using System.Web;
using System.Web.Mvc;
using Microsoft.Web.Resources;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ReflectedEventPatternActionDescriptor : AsyncActionDescriptor {
private readonly string _actionName;
View
40 MVC/src/MvcFutures/Mvc/RequireSslAttribute.cs
@@ -0,0 +1,40 @@
+namespace Microsoft.Web.Mvc {
+ using System;
+ using System.Net;
+ using System.Web;
+ using System.Web.Mvc;
+ using Microsoft.Web.Resources;
+
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
+ public sealed class RequireSslAttribute : FilterAttribute, IAuthorizationFilter {
+
+ public bool Redirect {
+ get;
+ set;
+ }
+
+ public void OnAuthorization(AuthorizationContext filterContext) {
+ if (filterContext == null) {
+ throw new ArgumentNullException("filterContext");
+ }
+
+ if (!filterContext.HttpContext.Request.IsSecureConnection) {
+ // request is not SSL-protected, so throw or redirect
+ if (Redirect) {
+ // form new URL
+ UriBuilder builder = new UriBuilder() {
+ Scheme = "https",
+ Host = filterContext.HttpContext.Request.Url.Host,
+ // use the RawUrl since it works with URL Rewriting
+ Path = filterContext.HttpContext.Request.RawUrl
+ };
+ filterContext.Result = new RedirectResult(builder.ToString());
+ }
+ else {
+ throw new HttpException((int)HttpStatusCode.Forbidden, MvcResources.RequireSslAttribute_MustUseSsl);
+ }
+ }
+ }
+
+ }
+}
View
3 MVC/src/MvcFutures/Mvc/SingleFireEvent.cs
@@ -1,9 +1,6 @@
namespace Microsoft.Web.Mvc {
- using System;
using System.Threading;
- using System.Web;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SingleFireEvent {
private int _hasFired; // 0 = false, 1 = true
View
2 MVC/src/MvcFutures/Mvc/SkipBindingAttribute.cs
@@ -1,9 +1,7 @@
namespace Microsoft.Web.Mvc {
using System;
- using System.Web;
using System.Web.Mvc;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
public sealed class SkipBindingAttribute : CustomModelBinderAttribute {
private static readonly NullBinder _nullBinder = new NullBinder();
View
1 MVC/src/MvcFutures/Mvc/ViewExtensions.cs
@@ -6,7 +6,6 @@
using System.Web.Routing;
using Microsoft.Web.Mvc.Internal;
- [AspNetHostingPermission(System.Security.Permissions.SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class ViewExtensions {
public static void RenderRoute(this HtmlHelper helper, RouteValueDictionary routeValues) {
View
11 MVC/src/MvcFutures/MvcFutures.csproj
@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.30729</ProductVersion>
+ <ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{D3CF7430-6DA4-42B0-BD90-CA39D16687B2}</ProjectGuid>
<OutputType>Library</OutputType>
@@ -46,6 +46,9 @@
<HintPath>..\..\ReferenceAssemblies\System.Web.Abstractions.dll</HintPath>
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
+ <Reference Include="System.Web.Extensions">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
<Reference Include="System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\ReferenceAssemblies\System.Web.Routing.dll</HintPath>
@@ -56,6 +59,7 @@
<ItemGroup>
<Compile Include="Internal\ExpressionHelper.cs" />
<Compile Include="Mvc\ActionDescriptorCreator.cs" />
+ <Compile Include="Mvc\AjaxExtensions.cs" />
<Compile Include="Mvc\AsyncActionDescriptor.cs" />
<Compile Include="Mvc\AsyncActionMethodSelector.cs" />
<Compile Include="Mvc\AsyncCallback`1.cs" />
@@ -67,7 +71,11 @@
<Compile Include="Mvc\AsyncRouteCollectionExtensions.cs" />
<Compile Include="Mvc\AsyncTimeoutAttribute.cs" />
<Compile Include="Mvc\BeginInvokeCallback.cs" />
+ <Compile Include="Mvc\BinaryHtmlExtensions.cs" />
+ <Compile Include="Mvc\ByteArrayModelBinder.cs" />
<Compile Include="Mvc\ContinuationListnener.cs" />
+ <Compile Include="Mvc\AcceptAjaxAttribute.cs" />
+ <Compile Include="Mvc\RequireSslAttribute.cs" />
<Compile Include="Mvc\DescriptorUtil.cs" />
<Compile Include="Mvc\IAsyncActionDescriptor.cs" />
<Compile Include="Mvc\IAsyncActionInvoker.cs" />
@@ -99,7 +107,6 @@
<Compile Include="Mvc\Controls\DropDownList.cs" />
<Compile Include="Mvc\Controls\Hidden.cs" />
<Compile Include="Mvc\Controls\Label.cs" />
- <Compile Include="Mvc\Controls\ListBoxHelper.cs" />
<Compile Include="Mvc\Controls\MvcControl.cs" />
<Compile Include="Mvc\Controls\MvcInputControl.cs" />
<Compile Include="Mvc\Controls\Password.cs" />
View
3 MVC/src/MvcFutures/Properties/AssemblyInfo.cs
@@ -37,9 +37,8 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.40112.0")]
+[assembly: AssemblyFileVersion("1.0.40310.0")]
-[assembly: AllowPartiallyTrustedCallers]
[assembly: CLSCompliant(true)]