24 writes to ViewData
Microsoft.AspNetCore.Mvc.Razor (1)
RazorPagePropertyActivator.cs (1)
48context.ViewData = CreateViewDataDictionary(context);
Microsoft.AspNetCore.Mvc.Razor.Test (11)
Compilation\RazorPagePropertyActivatorTest.cs (6)
66ViewData = original, 95ViewData = original, 124ViewData = original, 153ViewData = original, 182ViewData = original, 206ViewData = original,
RazorPageCreateModelExpressionTest.cs (3)
30viewContext.ViewData = viewData; 55viewContext.ViewData = viewData; 109viewContext.ViewData = viewData;
RazorViewTest.cs (2)
83c.ViewData = viewData; 126c.ViewData = viewData;
Microsoft.AspNetCore.Mvc.RazorPages.Test (6)
Infrastructure\DefaultPageFactoryProviderTest.cs (1)
230ViewData = pageContext.ViewData,
PageTest.cs (5)
1718ViewData = viewData 1743ViewData = viewData 1768ViewData = viewData, 1790ViewData = viewData, 1812ViewData = viewData,
Microsoft.AspNetCore.Mvc.TagHelpers.Test (1)
LabelTagHelperTest.cs (1)
297viewContext.ViewData = viewData;
Microsoft.AspNetCore.Mvc.ViewFeatures (3)
Rendering\ViewContext.cs (3)
34ViewData = new ViewDataDictionary(new EmptyModelMetadataProvider(), ModelState); 64ViewData = viewData; 106ViewData = viewData;
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (2)
Rendering\HtmlHelperTest.cs (1)
338viewContext.ViewData = new ViewDataDictionary(viewContext.ViewData);
Rendering\ViewContextTests.cs (1)
33context.ViewData = replacementViewData;
155 references to ViewData
Identity.ExternalClaims (1)
Pages\Account\Manage\ManageNavPages.cs (1)
32var activePage = viewContext.ViewData["ActivePage"] as string
Microsoft.AspNetCore.Identity.UI (4)
Areas\Identity\Pages\V4\Account\Manage\ManageNavPages.cs (2)
116var activePage = viewContext.ViewData["ActivePage"] as string 175var activePage = viewContext.ViewData["ActivePage"] as string
Areas\Identity\Pages\V5\Account\Manage\ManageNavPages.cs (2)
116var activePage = viewContext.ViewData["ActivePage"] as string 175var activePage = viewContext.ViewData["ActivePage"] as string
Microsoft.AspNetCore.Mvc.Razor (5)
RazorPagePropertyActivator.cs (5)
61if (context.ViewData == null) 66else if (context.ViewData.GetType() != _viewDataDictionaryType) 69return _nestedFactory(context.ViewData); 72return context.ViewData; 97valueAccessor = context => context.ViewData;
Microsoft.AspNetCore.Mvc.Razor.Test (21)
DefaultTagHelperFactoryTest.cs (1)
37viewContext.ViewData.Add("TestData", viewDataValue);
Infrastructure\DefaultTagHelperActivatorTest.cs (1)
29viewContext.ViewData.Add("TestData", viewDataValue);
RazorPageActivatorTest.cs (8)
65Assert.Same(viewContext.ViewData, instance.ViewData); 103Assert.NotNull(viewContext.ViewData); 130Assert.Same(viewContext.ViewData, instance.ViewData); 133Assert.NotSame(viewData, viewContext.ViewData); 186Assert.Same(viewContext.ViewData, page.ViewData); 187Assert.NotSame(viewData, viewContext.ViewData); 189Assert.IsType<ViewDataDictionary<Guid>>(viewContext.ViewData); 190Assert.Equal("value", viewContext.ViewData["key"]);
RazorPageCreateModelExpressionTest.cs (9)
24var modelExplorer = viewContext.ViewData.ModelExplorer.GetExplorerForProperty( 26var viewData = new ViewDataDictionary<string>(viewContext.ViewData) 49var modelExplorer = viewContext.ViewData.ModelExplorer.GetExplorerForProperty( 51var viewData = new ViewDataDictionary<string>(viewContext.ViewData) 108var viewData = new ViewDataDictionary<RecursiveModel>(viewContext.ViewData); 278ViewData = (ViewDataDictionary<string>)viewContext.ViewData, 288ViewData = (ViewDataDictionary<RecursiveModel>)viewContext.ViewData, 298ViewData = (ViewDataDictionary<RazorPageCreateModelExpressionModel>)viewContext.ViewData, 365return ModelExpressionProvider.CreateModelExpression(ViewData, m => ViewContext.ViewData.Model);
RazorViewTest.cs (2)
65Assert.Same(viewData, v.ViewContext.ViewData); 103Assert.Same(viewData, v.ViewContext.ViewData);
Microsoft.AspNetCore.Mvc.RazorPages (3)
PageBase.cs (3)
1185var viewData = new ViewDataDictionary(MetadataProvider, ViewContext.ViewData.ModelState) 1241ViewData = ViewContext.ViewData, 1263ViewData = ViewContext.ViewData,
Microsoft.AspNetCore.Mvc.RazorPages.Test (4)
Infrastructure\PageActionInvokerTest.cs (4)
200Assert.IsType<ViewDataDictionary<TestPage>>(page.ViewContext.ViewData); 201Assert.Same(page, page.ViewContext.ViewData.Model); 206Assert.Same(page.ViewContext.ViewData, pageResult.ViewData); 262Assert.Same(page.ViewContext.ViewData, pageResult.ViewData);
Microsoft.AspNetCore.Mvc.TagHelpers (6)
InputTagHelper.cs (1)
213string.IsNullOrEmpty(ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix) &&
PartialTagHelper.cs (2)
177return ViewContext.ViewData.Model; 201var baseViewData = ViewData ?? ViewContext.ViewData;
SelectTagHelper.cs (1)
136string.IsNullOrEmpty(ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix) &&
TextAreaTagHelper.cs (1)
74string.IsNullOrEmpty(ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix) &&
ValidationMessageTagHelper.cs (1)
64string.IsNullOrEmpty(ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix) &&
Microsoft.AspNetCore.Mvc.TagHelpers.Test (20)
PartialTagHelperTest.cs (17)
91viewContext.ViewData.Model = expectedModel; 235viewContext.ViewData["key"] = expected; 241v.Writer.Write(v.ViewData["key"]); 279viewContext.ViewData["key"] = "ViewContext"; 285v.Writer.Write(v.ViewData["key"]); 326viewContext.ViewData.Model = new object(); 332var actual = Assert.IsType<PropertyModel>(v.ViewData.Model); 373viewContext.ViewData.Model = new object(); 379Assert.Null(v.ViewData.Model); 420viewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "order.items[0]"; 426Assert.Equal(expected, v.ViewData.TemplateInfo.HtmlFieldPrefix); 449Assert.Equal("order.items[0]", viewContext.ViewData.TemplateInfo.HtmlFieldPrefix); 460viewContext.ViewData.Model = model; 466Assert.Same(model, v.ViewData.Model); 499viewContext.ViewData.Model = model; 500viewContext.ViewData.TemplateInfo.HtmlFieldPrefix = expected; 506Assert.Equal(expected, v.ViewData.TemplateInfo.HtmlFieldPrefix);
SelectTagHelperTest.cs (2)
498viewContext.ViewData.TemplateInfo.HtmlFieldPrefix = nameAndId.Name; 581viewContext.ViewData.TemplateInfo.HtmlFieldPrefix = propertyName;
ValidationSummaryTagHelperTest.cs (1)
172viewContext.ViewData.TemplateInfo.HtmlFieldPrefix = prefix;
Microsoft.AspNetCore.Mvc.ViewFeatures (38)
DefaultEditorTemplates.cs (1)
222value: htmlHelper.ViewContext.ViewData.TemplateInfo.FormattedModelValue.ToString(),
DefaultHtmlGenerator.cs (21)
562ExpressionMetadataProvider.FromStringExpression(expression, viewContext.ViewData, _metadataProvider); 582if (viewContext.ViewData.ModelState.TryGetValue(fullName, out var entry)) 632viewContext.ViewData.ModelState.TryGetValue(fullName, out var entry); 665AddPlaceholderAttribute(viewContext.ViewData, tagBuilder, modelExplorer, expression); 666AddMaxLengthAttribute(viewContext.ViewData, tagBuilder, modelExplorer, expression); 735if (!viewContext.ViewData.ModelState.ContainsKey(fullName) && formContext == null) 740var tryGetModelStateResult = viewContext.ViewData.ModelState.TryGetValue(fullName, out var entry); 779viewContext.ViewData, 810var viewData = viewContext.ViewData; 918rawValue = viewContext.ViewData.Eval(expression); 955ExpressionMetadataProvider.FromStringExpression(expression, viewContext.ViewData, _metadataProvider); 1030return Convert.ToString(viewContext.ViewData.Eval(key, format), CultureInfo.CurrentCulture); 1066if (viewContext.ViewData.ModelState.TryGetValue(key, out var entry) && entry.RawValue != null) 1176AddPlaceholderAttribute(viewContext.ViewData, tagBuilder, modelExplorer, expression); 1181AddMaxLengthAttribute(viewContext.ViewData, tagBuilder, modelExplorer, expression); 1262if (viewContext.ViewData.ModelState.TryGetValue(fullName, out var entry) && entry.Errors.Count > 0) 1373viewContext.ViewData, 1410return Convert.ToBoolean(viewContext.ViewData.Eval(key), CultureInfo.InvariantCulture); 1415return Convert.ToString(viewContext.ViewData.Eval(key), CultureInfo.CurrentCulture); 1494var value = viewContext.ViewData.Eval(expression); 1497if (value == null || value == viewContext.ViewData.Model)
HtmlHelper.cs (1)
113public ViewDataDictionary ViewData => ViewContext.ViewData;
HtmlHelperOfT.cs (8)
52if (viewContext.ViewData == null) 55nameof(ViewContext.ViewData), 60ViewData = viewContext.ViewData as ViewDataDictionary<TModel>; 70var runtimeType = viewContext.ViewData.ModelMetadata.ModelType; 73ViewData = new ViewDataDictionary<TModel>(viewContext.ViewData, viewContext.ViewData.Model); 81nameof(ViewContext.ViewData), 82viewContext.ViewData.GetType().FullName,
NameAndIdProvider.cs (1)
130var htmlFieldPrefix = viewContext.ViewData.TemplateInfo.HtmlFieldPrefix;
Rendering\ViewContext.cs (1)
168_viewBag = new DynamicViewData(() => ViewData);
ValidationHtmlAttributeProvider.cs (1)
67var fullName = viewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expression);
ViewComponentResultExecutor.cs (1)
139viewDataValuesProvider?.ProvideViewDataValues(viewContext.ViewData);
ViewComponents\ViewComponentContext.cs (2)
61new ViewDataDictionary<object>(viewContext.ViewData), 103public ViewDataDictionary ViewData => ViewContext.ViewData;
ViewExecutor.cs (1)
236viewDataValuesProvider?.ProvideViewDataValues(viewContext.ViewData);
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (51)
DefaultHtmlGeneratorTest.cs (8)
499viewContext.ViewData[nameof(Model.Name)] = Enumerable.Empty<SelectListItem>(); 522viewContext.ViewData[nameof(Model.Name)] = value; 589viewContext.ViewData[nameof(Model.Name)] = "ignored ViewData value"; 617viewContext.ViewData[nameof(Model.Name)] = "ignored ViewData value"; 665viewContext.ViewData[nameof(Model.Name)] = "ignored ViewData value"; 693viewContext.ViewData[nameof(Model.Name)] = rawValue; 771viewContext.ViewData[nameof(Model.Collection)] = new[] { "ignored ViewData value" }; 800viewContext.ViewData[nameof(Model.Collection)] = rawValue;
Rendering\DefaultTemplatesUtilities.cs (1)
311await v.Writer.WriteAsync(FormatOutput(v.ViewData.ModelExplorer));
Rendering\HtmlHelperCheckboxTest.cs (4)
486helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 506helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 527helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 731helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix";
Rendering\HtmlHelperDisplayExtensionsTest.cs (13)
52.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData["SomeProperty"].ToString())) 135.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData.TemplateInfo.FormattedModelValue.ToString())) 161.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData.TemplateInfo.FormattedModelValue.ToString())) 187.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData["SomeProperty"].ToString())) 215.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData.TemplateInfo.HtmlFieldPrefix)) 243.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData["SomeProperty"].ToString())) 290.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData["SomeProperty"].ToString())) 321.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData.TemplateInfo.FormattedModelValue.ToString())) 362.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData.TemplateInfo.FormattedModelValue.ToString())) 387.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData.TemplateInfo.HtmlFieldPrefix)) 415.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData["SomeProperty"].ToString())) 462.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData["SomeProperty"].ToString())) 489.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData.TemplateInfo.HtmlFieldPrefix))
Rendering\HtmlHelperEditorExtensionsTest.cs (2)
19.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData.TemplateInfo.FormattedModelValue.ToString())) 45.Callback((ViewContext v) => v.Writer.WriteAsync(v.ViewData.TemplateInfo.FormattedModelValue.ToString()))
Rendering\HtmlHelperHiddenTest.cs (6)
342helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 357helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 375helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 406helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 683helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 702helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix";
Rendering\HtmlHelperPasswordTest.cs (4)
100helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 118helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 133helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix"; 275helper.ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix";
Rendering\HtmlHelperTest.cs (3)
319var expectedMessage = $"Property '{nameof(ViewContext.ViewData)}' is of type " + 338viewContext.ViewData = new ViewDataDictionary(viewContext.ViewData); 340var expectedMessage = $"Property '{nameof(ViewContext.ViewData)}' is of type " +
Rendering\ViewContextTests.cs (5)
37Assert.NotSame(originalViewData, context.ViewData); 38Assert.Same(replacementViewData, context.ViewData); 41Assert.Equal("property", context.ViewData["Another"]); 57var viewData = new ViewDataDictionary(originalContext.ViewData); 77Assert.Same(viewData, context.ViewData);
ViewComponents\ViewComponentContextTest.cs (1)
51Assert.Same(viewComponentContext.ViewContext.ViewData, viewComponentContext.ViewData);
ViewComponentTests.cs (3)
226Assert.NotNull(viewComponent.ViewContext.ViewData); 230Assert.Empty(viewComponent.ViewContext.ViewData); 233Assert.Same(viewComponent.ViewData, viewComponent.ViewContext.ViewData);
ViewExecutorTest.cs (1)
182viewDataNull = v.ViewData == null;
RazorWebSite (2)
Services\BackSlashExpander.cs (1)
17if (context.ActionContext is ViewContext viewContext && (string)viewContext.ViewData["back-slash"] == "true")
Services\TestBodyTagHelperComponent.cs (1)
40ViewContext.ViewData["TestData"] = "NewValue";