- @await Component.InvokeAsync("Tags", 15)
+
Tags from View():
+ @await Component.InvokeAsync("Tags", 5, "View")
+
Tags from Content():
+
@await Component.InvokeAsync("Tags", 5, "Content")
+
Tags from Json():
+
@await Component.InvokeAsync("Tags", 5, "Json")
'@ViewBag.Title' should match page heading (still)
diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionResults/RedirectResult.cs b/src/Microsoft.AspNet.Mvc.Core/ActionResults/RedirectResult.cs
index 60c692d3ec..a9c9d86b1d 100644
--- a/src/Microsoft.AspNet.Mvc.Core/ActionResults/RedirectResult.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/ActionResults/RedirectResult.cs
@@ -3,6 +3,7 @@
using System;
using Microsoft.AspNet.Mvc.Core;
+using Microsoft.Framework.DependencyInjection;
namespace Microsoft.AspNet.Mvc
{
@@ -30,10 +31,18 @@ namespace Microsoft.AspNet.Mvc
public override void ExecuteResult([NotNull] ActionContext context)
{
- // It is redirected directly to the input URL.
- // We would use the context to construct the full URL,
- // only when relative URLs are supported. (Issue - WEBFX-202)
- context.HttpContext.Response.Redirect(Url, Permanent);
+ var destinationUrl = Url;
+ var urlHelper = context.HttpContext
+ .RequestServices
+ .GetService
();
+
+ // IsLocalUrl is called to handle Urls starting with '~/'.
+ if (urlHelper.IsLocalUrl(destinationUrl))
+ {
+ destinationUrl = urlHelper.Content(Url);
+ }
+
+ context.HttpContext.Response.Redirect(destinationUrl, Permanent);
}
}
}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs
index 232ced77a4..9746106e1d 100644
--- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs
@@ -443,13 +443,16 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
///
- public HtmlString ValidationMessage(string expression, string message, object htmlAttributes)
+ public HtmlString ValidationMessage(string expression, string message, object htmlAttributes, string tag)
{
- return GenerateValidationMessage(expression, message, htmlAttributes);
+ return GenerateValidationMessage(expression, message, htmlAttributes, tag);
}
///
- public virtual HtmlString ValidationSummary(bool excludePropertyErrors, string message, IDictionary htmlAttributes)
+ public virtual HtmlString ValidationSummary(bool excludePropertyErrors,
+ string message,
+ IDictionary htmlAttributes,
+ string tag)
{
var formContext = ViewContext.ClientValidationEnabled ? ViewContext.FormContext : null;
@@ -464,16 +467,20 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
}
- string messageSpan;
+ string wrappedMessage;
if (!string.IsNullOrEmpty(message))
{
- var spanTag = new TagBuilder("span");
- spanTag.SetInnerText(message);
- messageSpan = spanTag.ToString(TagRenderMode.Normal) + Environment.NewLine;
+ if (string.IsNullOrEmpty(tag))
+ {
+ tag = ViewContext.ValidationSummaryMessageElement;
+ }
+ var messageTag = new TagBuilder(tag);
+ messageTag.SetInnerText(message);
+ wrappedMessage = messageTag.ToString(TagRenderMode.Normal) + Environment.NewLine;
}
else
{
- messageSpan = null;
+ wrappedMessage = null;
}
var htmlSummary = new StringBuilder();
@@ -516,7 +523,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
divBuilder.AddCssClass(HtmlHelper.ValidationSummaryCssClassName);
}
- divBuilder.InnerHtml = messageSpan + unorderedList.ToString(TagRenderMode.Normal);
+ divBuilder.InnerHtml = wrappedMessage + unorderedList.ToString(TagRenderMode.Normal);
if (formContext != null)
{
@@ -1261,8 +1268,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
return tagBuilder.ToHtmlString(TagRenderMode.SelfClosing);
}
- protected virtual HtmlString GenerateValidationMessage(string expression, string message,
- object htmlAttributes)
+ protected virtual HtmlString GenerateValidationMessage(string expression,
+ string message,
+ object htmlAttributes,
+ string tag)
{
var modelName = ViewData.TemplateInfo.GetFullHtmlFieldName(expression);
if (string.IsNullOrEmpty(modelName))
@@ -1294,7 +1303,11 @@ namespace Microsoft.AspNet.Mvc.Rendering
// Even if there are no model errors, we generate the span and add the validation message
// if formContext is not null.
- var builder = new TagBuilder("span");
+ if (string.IsNullOrEmpty(tag))
+ {
+ tag = ViewContext.ValidationMessageElement;
+ }
+ var builder = new TagBuilder(tag);
builder.MergeAttributes(AnonymousObjectToHtmlAttributes(htmlAttributes));
// Only the style of the span is changed according to the errors if message is null or empty.
diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs
index 16d88f75eb..0008e5ce29 100644
--- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs
@@ -229,9 +229,14 @@ namespace Microsoft.AspNet.Mvc.Rendering
///
public HtmlString ValidationMessageFor([NotNull] Expression> expression,
- string message, object htmlAttributes)
+ string message,
+ object htmlAttributes,
+ string tag)
{
- return GenerateValidationMessage(ExpressionHelper.GetExpressionText(expression), message, htmlAttributes);
+ return GenerateValidationMessage(ExpressionHelper.GetExpressionText(expression),
+ message,
+ htmlAttributes,
+ tag);
}
///
diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs
index edbcba84ae..0f751bfbc1 100644
--- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs
@@ -12,95 +12,202 @@ namespace Microsoft.AspNet.Mvc.Rendering
public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper,
string expression)
{
- return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: null);
+ return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: null, tag: null);
}
public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper,
- string expression, string message)
+ string expression,
+ string message)
{
- return htmlHelper.ValidationMessage(expression, message, htmlAttributes: null);
+ return htmlHelper.ValidationMessage(expression, message, htmlAttributes: null, tag: null);
}
public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper,
- string expression, object htmlAttributes)
+ string expression,
+ object htmlAttributes)
{
- return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: htmlAttributes);
+ return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: htmlAttributes, tag: null);
}
public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper,
- string expression, string message, object htmlAttributes)
+ string expression,
+ string message,
+ string tag)
{
- return htmlHelper.ValidationMessage(expression, message, htmlAttributes);
+ return htmlHelper.ValidationMessage(expression, message, htmlAttributes: null, tag: tag);
+ }
+
+ public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper,
+ string expression,
+ string message,
+ object htmlAttributes)
+ {
+ return htmlHelper.ValidationMessage(expression, message, htmlAttributes, tag: null);
+ }
+
+ public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper,
+ string expression,
+ string message,
+ object htmlAttributes,
+ string tag)
+ {
+ return htmlHelper.ValidationMessage(expression, message, htmlAttributes, tag);
}
public static HtmlString ValidationMessageFor([NotNull] this IHtmlHelper htmlHelper,
[NotNull] Expression> expression)
{
- return htmlHelper.ValidationMessageFor(expression, message: null, htmlAttributes: null);
+ return htmlHelper.ValidationMessageFor(expression, message: null, htmlAttributes: null, tag: null);
}
public static HtmlString ValidationMessageFor([NotNull] this IHtmlHelper htmlHelper,
- [NotNull] Expression> expression, string message)
+ [NotNull] Expression> expression,
+ string message)
{
- return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null);
+ return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null, tag: null);
}
public static HtmlString ValidationMessageFor([NotNull] this IHtmlHelper htmlHelper,
- [NotNull] Expression> expression, string message, object htmlAttributes)
+ [NotNull] Expression> expression,
+ string message,
+ object htmlAttributes)
{
- return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes);
+ return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes, tag: null);
+ }
+
+ public static HtmlString ValidationMessageFor([NotNull] this IHtmlHelper htmlHelper,
+ [NotNull] Expression> expression,
+ string message,
+ string tag)
+ {
+ return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null, tag: tag);
+ }
+
+ public static HtmlString ValidationMessageFor([NotNull] this IHtmlHelper htmlHelper,
+ [NotNull] Expression> expression,
+ string message,
+ object htmlAttributes,
+ string tag)
+ {
+ return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes, tag);
}
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper)
{
- return ValidationSummary(htmlHelper, excludePropertyErrors: false);
+ return htmlHelper.ValidationSummary(excludePropertyErrors: false,
+ message: null,
+ htmlAttributes: null,
+ tag: null);
}
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, bool excludePropertyErrors)
{
- return ValidationSummary(htmlHelper, excludePropertyErrors, message: null);
+ return htmlHelper.ValidationSummary(excludePropertyErrors,
+ message: null,
+ htmlAttributes: null,
+ tag: null);
}
public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message)
{
- return ValidationSummary(htmlHelper, excludePropertyErrors: false, message: message,
- htmlAttributes: (object)null);
+ return htmlHelper.ValidationSummary(excludePropertyErrors: false,
+ message: message,
+ htmlAttributes: null,
+ tag: null);
}
- public static HtmlString ValidationSummary(
- [NotNull] this IHtmlHelper htmlHelper,
+ public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message, string tag)
+ {
+ return htmlHelper.ValidationSummary(excludePropertyErrors: false,
+ message: message,
+ htmlAttributes: null,
+ tag: tag);
+ }
+
+ public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper,
bool excludePropertyErrors,
string message)
{
- return ValidationSummary(htmlHelper, excludePropertyErrors, message, htmlAttributes: (object)null);
+ return htmlHelper.ValidationSummary(excludePropertyErrors,
+ message,
+ htmlAttributes: null,
+ tag: null);
}
- public static HtmlString ValidationSummary(
- [NotNull] this IHtmlHelper htmlHelper,
+ public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper,
string message,
object htmlAttributes)
{
- return ValidationSummary(htmlHelper, excludePropertyErrors: false, message: message,
- htmlAttributes: HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
+ return htmlHelper.ValidationSummary(excludePropertyErrors: false,
+ message: message,
+ htmlAttributes: HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes),
+ tag: null);
}
- public static HtmlString ValidationSummary(
- [NotNull] this IHtmlHelper htmlHelper,
+ public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper,
+ string message,
+ object htmlAttributes,
+ string tag)
+ {
+ return htmlHelper.ValidationSummary(excludePropertyErrors: false,
+ message: message,
+ htmlAttributes: HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes),
+ tag: tag);
+ }
+
+ public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper,
+ bool excludePropertyErrors,
+ string message,
+ string tag)
+ {
+ return htmlHelper.ValidationSummary(excludePropertyErrors,
+ message,
+ htmlAttributes: null,
+ tag: tag);
+ }
+
+ public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper,
bool excludePropertyErrors,
string message,
object htmlAttributes)
{
- return htmlHelper.ValidationSummary(excludePropertyErrors, message,
- HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));
+ return htmlHelper.ValidationSummary(excludePropertyErrors,
+ message,
+ HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes),
+ tag: null);
}
- public static HtmlString ValidationSummary(
- [NotNull] this IHtmlHelper htmlHelper,
+ public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper,
+ bool excludePropertyErrors,
+ string message,
+ object htmlAttributes,
+ string tag)
+ {
+ return htmlHelper.ValidationSummary(excludePropertyErrors,
+ message,
+ HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes),
+ tag);
+ }
+
+ public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper,
string message,
IDictionary htmlAttributes)
{
- return htmlHelper.ValidationSummary(excludePropertyErrors: false, message: message,
- htmlAttributes: htmlAttributes);
+ return htmlHelper.ValidationSummary(excludePropertyErrors: false,
+ message: message,
+ htmlAttributes: htmlAttributes,
+ tag: null);
+ }
+
+ public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper,
+ string message,
+ IDictionary htmlAttributes,
+ string tag)
+ {
+ return htmlHelper.ValidationSummary(excludePropertyErrors: false,
+ message: message,
+ htmlAttributes: htmlAttributes,
+ tag: tag);
}
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs
index 3c81a06c39..dd7ef26d2a 100644
--- a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs
@@ -447,8 +447,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An object that contains the HTML attributes to set for the element.
/// Alternatively, an instance containing the HTML attributes.
///
+ /// The tag to wrap the in the generated HTML.
+ /// Its default value is .
/// An that contains the validation message
- HtmlString ValidationMessage(string modelName, string message, object htmlAttributes);
+ HtmlString ValidationMessage(string modelName, string message, object htmlAttributes, string tag);
///
/// Returns an unordered list (ul element) of validation messages that are in the
@@ -458,12 +460,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// have the summary display all errors.
/// The message to display with the validation summary.
/// A dictionary that contains the HTML attributes for the element.
+ /// The tag to wrap the in the generated HTML.
+ /// Its default value is .
/// An that contains an unordered list (ul element) of validation messages.
///
HtmlString ValidationSummary(
bool excludePropertyErrors,
string message,
- IDictionary htmlAttributes);
+ IDictionary htmlAttributes,
+ string tag);
///
/// Returns the model value for the given expression .
diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs
index 1f537dc549..7b934507cd 100644
--- a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs
@@ -253,9 +253,13 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An object that contains the HTML attributes to set for the element.
/// Alternatively, an /// instance containing the HTML attributes.
///
+ /// The tag to wrap the in the generated HTML.
+ /// Its default value is .
/// An that contains the validation message
HtmlString ValidationMessageFor([NotNull] Expression> expression,
- string message, object htmlAttributes);
+ string message,
+ object htmlAttributes,
+ string tag);
///
/// Returns the model value for the given expression .
diff --git a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentResultHelper.cs b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentResultHelper.cs
index 5ba316e75d..4fde664ca3 100644
--- a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentResultHelper.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/DefaultViewComponentResultHelper.cs
@@ -14,17 +14,17 @@ namespace Microsoft.AspNet.Mvc
_viewEngine = viewEngine;
}
- public IViewComponentResult Content([NotNull] string content)
+ public virtual ContentViewComponentResult Content([NotNull] string content)
{
return new ContentViewComponentResult(content);
}
- public IViewComponentResult Json([NotNull] object value)
+ public virtual JsonViewComponentResult Json([NotNull] object value)
{
return new JsonViewComponentResult(value);
}
- public IViewComponentResult View([NotNull] string viewName, [NotNull] ViewDataDictionary viewData)
+ public virtual ViewViewComponentResult View([NotNull] string viewName, [NotNull] ViewDataDictionary viewData)
{
return new ViewViewComponentResult(_viewEngine, viewName, viewData);
}
diff --git a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentResultHelper.cs b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentResultHelper.cs
index fc4569bc45..5be2e44f5e 100644
--- a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentResultHelper.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/IViewComponentResultHelper.cs
@@ -7,10 +7,10 @@ namespace Microsoft.AspNet.Mvc
{
public interface IViewComponentResultHelper
{
- IViewComponentResult Content([NotNull] string content);
+ ContentViewComponentResult Content([NotNull] string content);
- IViewComponentResult Json([NotNull] object value);
+ JsonViewComponentResult Json([NotNull] object value);
- IViewComponentResult View([NotNull] string viewName, [NotNull] ViewDataDictionary viewData);
+ ViewViewComponentResult View([NotNull] string viewName, [NotNull] ViewDataDictionary viewData);
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/ViewComponent.cs b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/ViewComponent.cs
index 734ab88e12..3504f51efd 100644
--- a/src/Microsoft.AspNet.Mvc.Core/ViewComponents/ViewComponent.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/ViewComponents/ViewComponent.cs
@@ -35,27 +35,37 @@ namespace Microsoft.AspNet.Mvc
public ViewDataDictionary ViewData { get; set; }
+ public ContentViewComponentResult Content(string content)
+ {
+ return Result.Content(content);
+ }
+
public void Initialize(IViewComponentResultHelper result)
{
Result = result;
}
- public IViewComponentResult View()
+ public JsonViewComponentResult Json(object value)
+ {
+ return Result.Json(value);
+ }
+
+ public ViewViewComponentResult View()
{
return View