У меня на странице есть этот HTML-код:
@using MyHelpers
@model FluentHtmlHelpers.Models.SampleAlertModel
@{
ViewBag.Title = "Strongly Typed";
}
Strongly Typed
Html.AlertFor(m => m.AlertBoxText).Success()
@Html.AlertFor(m => m.AlertBoxText).Success()
Html.AlertFor(m => m.AlertBoxText, m => m.AlertBoxStyle)
@Html.AlertFor(m => m.AlertBoxText, m => m.AlertBoxStyle)
SampleAlertModel:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyHelpers;
namespace FluentHtmlHelpers.Models
{
public class SampleAlertModel
{
public string AlertBoxText { get; set; }
public MyHelpers.AlertStyle AlertBoxStyle { get; set; }
}
}
>AlertHtmlHelper:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
namespace MyHelpers
{
///
/// Generates an Alert message
///
public static class AlertHtmlHelper
{
///
/// Generates an Alert message
///
public static AlertBox Alert(this IHtmlHelper html,
string text,
AlertStyle alertStyle = AlertStyle.Default,
bool hideCloseButton = false,
object htmlAttributes = null
)
{
return new AlertBox(text, alertStyle, hideCloseButton, htmlAttributes);
}
// Strongly typed
///
/// Generates an Alert message
///
public static AlertBox AlertFor(this IHtmlHelper html,
Expression expression,
AlertStyle alertStyle = AlertStyle.Default,
bool hideCloseButton = false,
object htmlAttributes = null
)
{
var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, html.ViewData, html.MetadataProvider);
return new AlertBox((string)metadata.Model, alertStyle, hideCloseButton, htmlAttributes);
}
///
/// Generates an Alert message
///
public static AlertBox AlertFor(this IHtmlHelper html,
Expression textExpression,
Expression styleExpression,
bool hideCloseButton = false,
object htmlAttributes = null
)
{
var text = (string) ExpressionMetadataProvider.FromLambdaExpression(textExpression, html.ViewData, html.MetadataProvider).Model;
var alertStyle = (AlertStyle)ExpressionMetadataProvider.FromLambdaExpression(styleExpression, html.ViewData, html.MetadataProvider).Model;
return new AlertBox(text, alertStyle,hideCloseButton, htmlAttributes);
}
}
}
Но я получаю эту ошибку:
TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ExpressionMetadataProvider' from assembly 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Подробнее здесь: https://stackoverflow.com/questions/793 ... ewfeatures
Не удалось загрузить тип при использовании Microsoft.AspNetCore.Mvc.ViewFeatures. ⇐ C#
Место общения программистов C#
1736071804
Anonymous
У меня на странице есть этот HTML-код:
@using MyHelpers
@model FluentHtmlHelpers.Models.SampleAlertModel
@{
ViewBag.Title = "Strongly Typed";
}
Strongly Typed
Html.AlertFor(m => m.AlertBoxText).Success()
@Html.AlertFor(m => m.AlertBoxText).Success()
Html.AlertFor(m => m.AlertBoxText, m => m.AlertBoxStyle)
@Html.AlertFor(m => m.AlertBoxText, m => m.AlertBoxStyle)
SampleAlertModel:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyHelpers;
namespace FluentHtmlHelpers.Models
{
public class SampleAlertModel
{
public string AlertBoxText { get; set; }
public MyHelpers.AlertStyle AlertBoxStyle { get; set; }
}
}
>AlertHtmlHelper:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
namespace MyHelpers
{
///
/// Generates an Alert message
///
public static class AlertHtmlHelper
{
///
/// Generates an Alert message
///
public static AlertBox Alert(this IHtmlHelper html,
string text,
AlertStyle alertStyle = AlertStyle.Default,
bool hideCloseButton = false,
object htmlAttributes = null
)
{
return new AlertBox(text, alertStyle, hideCloseButton, htmlAttributes);
}
// Strongly typed
///
/// Generates an Alert message
///
public static AlertBox AlertFor(this IHtmlHelper html,
Expression expression,
AlertStyle alertStyle = AlertStyle.Default,
bool hideCloseButton = false,
object htmlAttributes = null
)
{
var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, html.ViewData, html.MetadataProvider);
return new AlertBox((string)metadata.Model, alertStyle, hideCloseButton, htmlAttributes);
}
///
/// Generates an Alert message
///
public static AlertBox AlertFor(this IHtmlHelper html,
Expression textExpression,
Expression styleExpression,
bool hideCloseButton = false,
object htmlAttributes = null
)
{
var text = (string) ExpressionMetadataProvider.FromLambdaExpression(textExpression, html.ViewData, html.MetadataProvider).Model;
var alertStyle = (AlertStyle)ExpressionMetadataProvider.FromLambdaExpression(styleExpression, html.ViewData, html.MetadataProvider).Model;
return new AlertBox(text, alertStyle,hideCloseButton, htmlAttributes);
}
}
}
Но я получаю эту ошибку:
TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ExpressionMetadataProvider' from assembly 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Подробнее здесь: [url]https://stackoverflow.com/questions/79330528/could-not-load-type-when-using-microsoft-aspnetcore-mvc-viewfeatures[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия